babylon.module.d.ts 5.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915
  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. * Gets the list of observers
  4360. */
  4361. readonly observers: Array<Observer<T>>;
  4362. /**
  4363. * Creates a new observable
  4364. * @param onObserverAdded defines a callback to call when a new observer is added
  4365. */
  4366. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4367. /**
  4368. * Create a new Observer with the specified callback
  4369. * @param callback the callback that will be executed for that Observer
  4370. * @param mask the mask used to filter observers
  4371. * @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.
  4372. * @param scope optional scope for the callback to be called from
  4373. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4374. * @returns the new observer created for the callback
  4375. */
  4376. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4377. /**
  4378. * Create a new Observer with the specified callback and unregisters after the next notification
  4379. * @param callback the callback that will be executed for that Observer
  4380. * @returns the new observer created for the callback
  4381. */
  4382. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4383. /**
  4384. * Remove an Observer from the Observable object
  4385. * @param observer the instance of the Observer to remove
  4386. * @returns false if it doesn't belong to this Observable
  4387. */
  4388. remove(observer: Nullable<Observer<T>>): boolean;
  4389. /**
  4390. * Remove a callback from the Observable object
  4391. * @param callback the callback to remove
  4392. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4393. * @returns false if it doesn't belong to this Observable
  4394. */
  4395. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4396. private _deferUnregister;
  4397. private _remove;
  4398. /**
  4399. * Moves the observable to the top of the observer list making it get called first when notified
  4400. * @param observer the observer to move
  4401. */
  4402. makeObserverTopPriority(observer: Observer<T>): void;
  4403. /**
  4404. * Moves the observable to the bottom of the observer list making it get called last when notified
  4405. * @param observer the observer to move
  4406. */
  4407. makeObserverBottomPriority(observer: Observer<T>): void;
  4408. /**
  4409. * Notify all Observers by calling their respective callback with the given data
  4410. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4411. * @param eventData defines the data to send to all observers
  4412. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4413. * @param target defines the original target of the state
  4414. * @param currentTarget defines the current target of the state
  4415. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4416. */
  4417. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4418. /**
  4419. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4420. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4421. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4422. * and it is crucial that all callbacks will be executed.
  4423. * The order of the callbacks is kept, callbacks are not executed parallel.
  4424. *
  4425. * @param eventData The data to be sent to each callback
  4426. * @param mask is used to filter observers defaults to -1
  4427. * @param target defines the callback target (see EventState)
  4428. * @param currentTarget defines he current object in the bubbling phase
  4429. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4430. */
  4431. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4432. /**
  4433. * Notify a specific observer
  4434. * @param observer defines the observer to notify
  4435. * @param eventData defines the data to be sent to each callback
  4436. * @param mask is used to filter observers defaults to -1
  4437. */
  4438. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4439. /**
  4440. * Gets a boolean indicating if the observable has at least one observer
  4441. * @returns true is the Observable has at least one Observer registered
  4442. */
  4443. hasObservers(): boolean;
  4444. /**
  4445. * Clear the list of observers
  4446. */
  4447. clear(): void;
  4448. /**
  4449. * Clone the current observable
  4450. * @returns a new observable
  4451. */
  4452. clone(): Observable<T>;
  4453. /**
  4454. * Does this observable handles observer registered with a given mask
  4455. * @param mask defines the mask to be tested
  4456. * @return whether or not one observer registered with the given mask is handeled
  4457. **/
  4458. hasSpecificMask(mask?: number): boolean;
  4459. }
  4460. }
  4461. declare module "babylonjs/Misc/filesInputStore" {
  4462. /**
  4463. * Class used to help managing file picking and drag'n'drop
  4464. * File Storage
  4465. */
  4466. export class FilesInputStore {
  4467. /**
  4468. * List of files ready to be loaded
  4469. */
  4470. static FilesToLoad: {
  4471. [key: string]: File;
  4472. };
  4473. }
  4474. }
  4475. declare module "babylonjs/Engines/constants" {
  4476. /** Defines the cross module used constants to avoid circular dependncies */
  4477. export class Constants {
  4478. /** Defines that alpha blending is disabled */
  4479. static readonly ALPHA_DISABLE: number;
  4480. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4481. static readonly ALPHA_ADD: number;
  4482. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4483. static readonly ALPHA_COMBINE: number;
  4484. /** Defines that alpha blending to DEST - SRC * DEST */
  4485. static readonly ALPHA_SUBTRACT: number;
  4486. /** Defines that alpha blending to SRC * DEST */
  4487. static readonly ALPHA_MULTIPLY: number;
  4488. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4489. static readonly ALPHA_MAXIMIZED: number;
  4490. /** Defines that alpha blending to SRC + DEST */
  4491. static readonly ALPHA_ONEONE: number;
  4492. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4493. static readonly ALPHA_PREMULTIPLIED: number;
  4494. /**
  4495. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4496. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4497. */
  4498. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4499. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4500. static readonly ALPHA_INTERPOLATE: number;
  4501. /**
  4502. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4503. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4504. */
  4505. static readonly ALPHA_SCREENMODE: number;
  4506. /** Defines that the ressource is not delayed*/
  4507. static readonly DELAYLOADSTATE_NONE: number;
  4508. /** Defines that the ressource was successfully delay loaded */
  4509. static readonly DELAYLOADSTATE_LOADED: number;
  4510. /** Defines that the ressource is currently delay loading */
  4511. static readonly DELAYLOADSTATE_LOADING: number;
  4512. /** Defines that the ressource is delayed and has not started loading */
  4513. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4514. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4515. static readonly NEVER: number;
  4516. /** 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 */
  4517. static readonly ALWAYS: number;
  4518. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4519. static readonly LESS: number;
  4520. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4521. static readonly EQUAL: number;
  4522. /** 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 */
  4523. static readonly LEQUAL: number;
  4524. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4525. static readonly GREATER: number;
  4526. /** 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 */
  4527. static readonly GEQUAL: number;
  4528. /** 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 */
  4529. static readonly NOTEQUAL: number;
  4530. /** Passed to stencilOperation to specify that stencil value must be kept */
  4531. static readonly KEEP: number;
  4532. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4533. static readonly REPLACE: number;
  4534. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4535. static readonly INCR: number;
  4536. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4537. static readonly DECR: number;
  4538. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4539. static readonly INVERT: number;
  4540. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4541. static readonly INCR_WRAP: number;
  4542. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4543. static readonly DECR_WRAP: number;
  4544. /** Texture is not repeating outside of 0..1 UVs */
  4545. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4546. /** Texture is repeating outside of 0..1 UVs */
  4547. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4548. /** Texture is repeating and mirrored */
  4549. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4550. /** ALPHA */
  4551. static readonly TEXTUREFORMAT_ALPHA: number;
  4552. /** LUMINANCE */
  4553. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4554. /** LUMINANCE_ALPHA */
  4555. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4556. /** RGB */
  4557. static readonly TEXTUREFORMAT_RGB: number;
  4558. /** RGBA */
  4559. static readonly TEXTUREFORMAT_RGBA: number;
  4560. /** RED */
  4561. static readonly TEXTUREFORMAT_RED: number;
  4562. /** RED (2nd reference) */
  4563. static readonly TEXTUREFORMAT_R: number;
  4564. /** RG */
  4565. static readonly TEXTUREFORMAT_RG: number;
  4566. /** RED_INTEGER */
  4567. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4568. /** RED_INTEGER (2nd reference) */
  4569. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4570. /** RG_INTEGER */
  4571. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4572. /** RGB_INTEGER */
  4573. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4574. /** RGBA_INTEGER */
  4575. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4576. /** UNSIGNED_BYTE */
  4577. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4578. /** UNSIGNED_BYTE (2nd reference) */
  4579. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4580. /** FLOAT */
  4581. static readonly TEXTURETYPE_FLOAT: number;
  4582. /** HALF_FLOAT */
  4583. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4584. /** BYTE */
  4585. static readonly TEXTURETYPE_BYTE: number;
  4586. /** SHORT */
  4587. static readonly TEXTURETYPE_SHORT: number;
  4588. /** UNSIGNED_SHORT */
  4589. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4590. /** INT */
  4591. static readonly TEXTURETYPE_INT: number;
  4592. /** UNSIGNED_INT */
  4593. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4594. /** UNSIGNED_SHORT_4_4_4_4 */
  4595. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4596. /** UNSIGNED_SHORT_5_5_5_1 */
  4597. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4598. /** UNSIGNED_SHORT_5_6_5 */
  4599. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4600. /** UNSIGNED_INT_2_10_10_10_REV */
  4601. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4602. /** UNSIGNED_INT_24_8 */
  4603. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4604. /** UNSIGNED_INT_10F_11F_11F_REV */
  4605. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4606. /** UNSIGNED_INT_5_9_9_9_REV */
  4607. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4608. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4609. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4610. /** nearest is mag = nearest and min = nearest and mip = linear */
  4611. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4612. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4613. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4614. /** Trilinear is mag = linear and min = linear and mip = linear */
  4615. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4616. /** nearest is mag = nearest and min = nearest and mip = linear */
  4617. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4618. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4619. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4620. /** Trilinear is mag = linear and min = linear and mip = linear */
  4621. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4622. /** mag = nearest and min = nearest and mip = nearest */
  4623. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4624. /** mag = nearest and min = linear and mip = nearest */
  4625. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4626. /** mag = nearest and min = linear and mip = linear */
  4627. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4628. /** mag = nearest and min = linear and mip = none */
  4629. static readonly TEXTURE_NEAREST_LINEAR: number;
  4630. /** mag = nearest and min = nearest and mip = none */
  4631. static readonly TEXTURE_NEAREST_NEAREST: number;
  4632. /** mag = linear and min = nearest and mip = nearest */
  4633. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4634. /** mag = linear and min = nearest and mip = linear */
  4635. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4636. /** mag = linear and min = linear and mip = none */
  4637. static readonly TEXTURE_LINEAR_LINEAR: number;
  4638. /** mag = linear and min = nearest and mip = none */
  4639. static readonly TEXTURE_LINEAR_NEAREST: number;
  4640. /** Explicit coordinates mode */
  4641. static readonly TEXTURE_EXPLICIT_MODE: number;
  4642. /** Spherical coordinates mode */
  4643. static readonly TEXTURE_SPHERICAL_MODE: number;
  4644. /** Planar coordinates mode */
  4645. static readonly TEXTURE_PLANAR_MODE: number;
  4646. /** Cubic coordinates mode */
  4647. static readonly TEXTURE_CUBIC_MODE: number;
  4648. /** Projection coordinates mode */
  4649. static readonly TEXTURE_PROJECTION_MODE: number;
  4650. /** Skybox coordinates mode */
  4651. static readonly TEXTURE_SKYBOX_MODE: number;
  4652. /** Inverse Cubic coordinates mode */
  4653. static readonly TEXTURE_INVCUBIC_MODE: number;
  4654. /** Equirectangular coordinates mode */
  4655. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4656. /** Equirectangular Fixed coordinates mode */
  4657. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4658. /** Equirectangular Fixed Mirrored coordinates mode */
  4659. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4660. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4661. static readonly SCALEMODE_FLOOR: number;
  4662. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4663. static readonly SCALEMODE_NEAREST: number;
  4664. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4665. static readonly SCALEMODE_CEILING: number;
  4666. /**
  4667. * The dirty texture flag value
  4668. */
  4669. static readonly MATERIAL_TextureDirtyFlag: number;
  4670. /**
  4671. * The dirty light flag value
  4672. */
  4673. static readonly MATERIAL_LightDirtyFlag: number;
  4674. /**
  4675. * The dirty fresnel flag value
  4676. */
  4677. static readonly MATERIAL_FresnelDirtyFlag: number;
  4678. /**
  4679. * The dirty attribute flag value
  4680. */
  4681. static readonly MATERIAL_AttributesDirtyFlag: number;
  4682. /**
  4683. * The dirty misc flag value
  4684. */
  4685. static readonly MATERIAL_MiscDirtyFlag: number;
  4686. /**
  4687. * The all dirty flag value
  4688. */
  4689. static readonly MATERIAL_AllDirtyFlag: number;
  4690. /**
  4691. * Returns the triangle fill mode
  4692. */
  4693. static readonly MATERIAL_TriangleFillMode: number;
  4694. /**
  4695. * Returns the wireframe mode
  4696. */
  4697. static readonly MATERIAL_WireFrameFillMode: number;
  4698. /**
  4699. * Returns the point fill mode
  4700. */
  4701. static readonly MATERIAL_PointFillMode: number;
  4702. /**
  4703. * Returns the point list draw mode
  4704. */
  4705. static readonly MATERIAL_PointListDrawMode: number;
  4706. /**
  4707. * Returns the line list draw mode
  4708. */
  4709. static readonly MATERIAL_LineListDrawMode: number;
  4710. /**
  4711. * Returns the line loop draw mode
  4712. */
  4713. static readonly MATERIAL_LineLoopDrawMode: number;
  4714. /**
  4715. * Returns the line strip draw mode
  4716. */
  4717. static readonly MATERIAL_LineStripDrawMode: number;
  4718. /**
  4719. * Returns the triangle strip draw mode
  4720. */
  4721. static readonly MATERIAL_TriangleStripDrawMode: number;
  4722. /**
  4723. * Returns the triangle fan draw mode
  4724. */
  4725. static readonly MATERIAL_TriangleFanDrawMode: number;
  4726. /**
  4727. * Stores the clock-wise side orientation
  4728. */
  4729. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4730. /**
  4731. * Stores the counter clock-wise side orientation
  4732. */
  4733. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4734. /**
  4735. * Nothing
  4736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4737. */
  4738. static readonly ACTION_NothingTrigger: number;
  4739. /**
  4740. * On pick
  4741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4742. */
  4743. static readonly ACTION_OnPickTrigger: number;
  4744. /**
  4745. * On left pick
  4746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4747. */
  4748. static readonly ACTION_OnLeftPickTrigger: number;
  4749. /**
  4750. * On right pick
  4751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4752. */
  4753. static readonly ACTION_OnRightPickTrigger: number;
  4754. /**
  4755. * On center pick
  4756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4757. */
  4758. static readonly ACTION_OnCenterPickTrigger: number;
  4759. /**
  4760. * On pick down
  4761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4762. */
  4763. static readonly ACTION_OnPickDownTrigger: number;
  4764. /**
  4765. * On double pick
  4766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4767. */
  4768. static readonly ACTION_OnDoublePickTrigger: number;
  4769. /**
  4770. * On pick up
  4771. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4772. */
  4773. static readonly ACTION_OnPickUpTrigger: number;
  4774. /**
  4775. * On pick out.
  4776. * This trigger will only be raised if you also declared a OnPickDown
  4777. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4778. */
  4779. static readonly ACTION_OnPickOutTrigger: number;
  4780. /**
  4781. * On long press
  4782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4783. */
  4784. static readonly ACTION_OnLongPressTrigger: number;
  4785. /**
  4786. * On pointer over
  4787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4788. */
  4789. static readonly ACTION_OnPointerOverTrigger: number;
  4790. /**
  4791. * On pointer out
  4792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4793. */
  4794. static readonly ACTION_OnPointerOutTrigger: number;
  4795. /**
  4796. * On every frame
  4797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4798. */
  4799. static readonly ACTION_OnEveryFrameTrigger: number;
  4800. /**
  4801. * On intersection enter
  4802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4803. */
  4804. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4805. /**
  4806. * On intersection exit
  4807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4808. */
  4809. static readonly ACTION_OnIntersectionExitTrigger: number;
  4810. /**
  4811. * On key down
  4812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4813. */
  4814. static readonly ACTION_OnKeyDownTrigger: number;
  4815. /**
  4816. * On key up
  4817. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4818. */
  4819. static readonly ACTION_OnKeyUpTrigger: number;
  4820. /**
  4821. * Billboard mode will only apply to Y axis
  4822. */
  4823. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4824. /**
  4825. * Billboard mode will apply to all axes
  4826. */
  4827. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4828. /**
  4829. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4830. */
  4831. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4832. /**
  4833. * Gets or sets base Assets URL
  4834. */
  4835. static PARTICLES_BaseAssetsUrl: string;
  4836. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4837. * Test order :
  4838. * Is the bounding sphere outside the frustum ?
  4839. * If not, are the bounding box vertices outside the frustum ?
  4840. * It not, then the cullable object is in the frustum.
  4841. */
  4842. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4843. /** Culling strategy : Bounding Sphere Only.
  4844. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4845. * It's also less accurate than the standard because some not visible objects can still be selected.
  4846. * Test : is the bounding sphere outside the frustum ?
  4847. * If not, then the cullable object is in the frustum.
  4848. */
  4849. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4850. /** Culling strategy : Optimistic Inclusion.
  4851. * This in an inclusion test first, then the standard exclusion test.
  4852. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4853. * 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.
  4854. * Anyway, it's as accurate as the standard strategy.
  4855. * Test :
  4856. * Is the cullable object bounding sphere center in the frustum ?
  4857. * If not, apply the default culling strategy.
  4858. */
  4859. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4860. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4861. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4862. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4863. * 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.
  4864. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4865. * Test :
  4866. * Is the cullable object bounding sphere center in the frustum ?
  4867. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4868. */
  4869. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4870. /**
  4871. * No logging while loading
  4872. */
  4873. static readonly SCENELOADER_NO_LOGGING: number;
  4874. /**
  4875. * Minimal logging while loading
  4876. */
  4877. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4878. /**
  4879. * Summary logging while loading
  4880. */
  4881. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4882. /**
  4883. * Detailled logging while loading
  4884. */
  4885. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4886. }
  4887. }
  4888. declare module "babylonjs/Misc/domManagement" {
  4889. /**
  4890. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4891. * Babylon.js
  4892. */
  4893. export class DomManagement {
  4894. /**
  4895. * Checks if the window object exists
  4896. * @returns true if the window object exists
  4897. */
  4898. static IsWindowObjectExist(): boolean;
  4899. /**
  4900. * Extracts text content from a DOM element hierarchy
  4901. * @param element defines the root element
  4902. * @returns a string
  4903. */
  4904. static GetDOMTextContent(element: HTMLElement): string;
  4905. }
  4906. }
  4907. declare module "babylonjs/Misc/logger" {
  4908. /**
  4909. * Logger used througouht the application to allow configuration of
  4910. * the log level required for the messages.
  4911. */
  4912. export class Logger {
  4913. /**
  4914. * No log
  4915. */
  4916. static readonly NoneLogLevel: number;
  4917. /**
  4918. * Only message logs
  4919. */
  4920. static readonly MessageLogLevel: number;
  4921. /**
  4922. * Only warning logs
  4923. */
  4924. static readonly WarningLogLevel: number;
  4925. /**
  4926. * Only error logs
  4927. */
  4928. static readonly ErrorLogLevel: number;
  4929. /**
  4930. * All logs
  4931. */
  4932. static readonly AllLogLevel: number;
  4933. private static _LogCache;
  4934. /**
  4935. * Gets a value indicating the number of loading errors
  4936. * @ignorenaming
  4937. */
  4938. static errorsCount: number;
  4939. /**
  4940. * Callback called when a new log is added
  4941. */
  4942. static OnNewCacheEntry: (entry: string) => void;
  4943. private static _AddLogEntry;
  4944. private static _FormatMessage;
  4945. private static _LogDisabled;
  4946. private static _LogEnabled;
  4947. private static _WarnDisabled;
  4948. private static _WarnEnabled;
  4949. private static _ErrorDisabled;
  4950. private static _ErrorEnabled;
  4951. /**
  4952. * Log a message to the console
  4953. */
  4954. static Log: (message: string) => void;
  4955. /**
  4956. * Write a warning message to the console
  4957. */
  4958. static Warn: (message: string) => void;
  4959. /**
  4960. * Write an error message to the console
  4961. */
  4962. static Error: (message: string) => void;
  4963. /**
  4964. * Gets current log cache (list of logs)
  4965. */
  4966. static readonly LogCache: string;
  4967. /**
  4968. * Clears the log cache
  4969. */
  4970. static ClearLogCache(): void;
  4971. /**
  4972. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4973. */
  4974. static LogLevels: number;
  4975. }
  4976. }
  4977. declare module "babylonjs/Misc/typeStore" {
  4978. /** @hidden */
  4979. export class _TypeStore {
  4980. /** @hidden */
  4981. static RegisteredTypes: {
  4982. [key: string]: Object;
  4983. };
  4984. /** @hidden */
  4985. static GetClass(fqdn: string): any;
  4986. }
  4987. }
  4988. declare module "babylonjs/Misc/deepCopier" {
  4989. /**
  4990. * Class containing a set of static utilities functions for deep copy.
  4991. */
  4992. export class DeepCopier {
  4993. /**
  4994. * Tries to copy an object by duplicating every property
  4995. * @param source defines the source object
  4996. * @param destination defines the target object
  4997. * @param doNotCopyList defines a list of properties to avoid
  4998. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4999. */
  5000. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  5001. }
  5002. }
  5003. declare module "babylonjs/Misc/precisionDate" {
  5004. /**
  5005. * Class containing a set of static utilities functions for precision date
  5006. */
  5007. export class PrecisionDate {
  5008. /**
  5009. * Gets either window.performance.now() if supported or Date.now() else
  5010. */
  5011. static readonly Now: number;
  5012. }
  5013. }
  5014. declare module "babylonjs/Misc/devTools" {
  5015. /** @hidden */
  5016. export class _DevTools {
  5017. static WarnImport(name: string): string;
  5018. }
  5019. }
  5020. declare module "babylonjs/Misc/webRequest" {
  5021. /**
  5022. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  5023. */
  5024. export class WebRequest {
  5025. private _xhr;
  5026. /**
  5027. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5028. * i.e. when loading files, where the server/service expects an Authorization header
  5029. */
  5030. static CustomRequestHeaders: {
  5031. [key: string]: string;
  5032. };
  5033. /**
  5034. * Add callback functions in this array to update all the requests before they get sent to the network
  5035. */
  5036. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5037. private _injectCustomRequestHeaders;
  5038. /**
  5039. * Gets or sets a function to be called when loading progress changes
  5040. */
  5041. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5042. /**
  5043. * Returns client's state
  5044. */
  5045. readonly readyState: number;
  5046. /**
  5047. * Returns client's status
  5048. */
  5049. readonly status: number;
  5050. /**
  5051. * Returns client's status as a text
  5052. */
  5053. readonly statusText: string;
  5054. /**
  5055. * Returns client's response
  5056. */
  5057. readonly response: any;
  5058. /**
  5059. * Returns client's response url
  5060. */
  5061. readonly responseURL: string;
  5062. /**
  5063. * Returns client's response as text
  5064. */
  5065. readonly responseText: string;
  5066. /**
  5067. * Gets or sets the expected response type
  5068. */
  5069. responseType: XMLHttpRequestResponseType;
  5070. /** @hidden */
  5071. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5072. /** @hidden */
  5073. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5074. /**
  5075. * Cancels any network activity
  5076. */
  5077. abort(): void;
  5078. /**
  5079. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5080. * @param body defines an optional request body
  5081. */
  5082. send(body?: Document | BodyInit | null): void;
  5083. /**
  5084. * Sets the request method, request URL
  5085. * @param method defines the method to use (GET, POST, etc..)
  5086. * @param url defines the url to connect with
  5087. */
  5088. open(method: string, url: string): void;
  5089. }
  5090. }
  5091. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5092. /**
  5093. * Class used to evalaute queries containing `and` and `or` operators
  5094. */
  5095. export class AndOrNotEvaluator {
  5096. /**
  5097. * Evaluate a query
  5098. * @param query defines the query to evaluate
  5099. * @param evaluateCallback defines the callback used to filter result
  5100. * @returns true if the query matches
  5101. */
  5102. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5103. private static _HandleParenthesisContent;
  5104. private static _SimplifyNegation;
  5105. }
  5106. }
  5107. declare module "babylonjs/Misc/tags" {
  5108. /**
  5109. * Class used to store custom tags
  5110. */
  5111. export class Tags {
  5112. /**
  5113. * Adds support for tags on the given object
  5114. * @param obj defines the object to use
  5115. */
  5116. static EnableFor(obj: any): void;
  5117. /**
  5118. * Removes tags support
  5119. * @param obj defines the object to use
  5120. */
  5121. static DisableFor(obj: any): void;
  5122. /**
  5123. * Gets a boolean indicating if the given object has tags
  5124. * @param obj defines the object to use
  5125. * @returns a boolean
  5126. */
  5127. static HasTags(obj: any): boolean;
  5128. /**
  5129. * Gets the tags available on a given object
  5130. * @param obj defines the object to use
  5131. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5132. * @returns the tags
  5133. */
  5134. static GetTags(obj: any, asString?: boolean): any;
  5135. /**
  5136. * Adds tags to an object
  5137. * @param obj defines the object to use
  5138. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5139. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5140. */
  5141. static AddTagsTo(obj: any, tagsString: string): void;
  5142. /**
  5143. * @hidden
  5144. */
  5145. static _AddTagTo(obj: any, tag: string): void;
  5146. /**
  5147. * Removes specific tags from a specific object
  5148. * @param obj defines the object to use
  5149. * @param tagsString defines the tags to remove
  5150. */
  5151. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5152. /**
  5153. * @hidden
  5154. */
  5155. static _RemoveTagFrom(obj: any, tag: string): void;
  5156. /**
  5157. * Defines if tags hosted on an object match a given query
  5158. * @param obj defines the object to use
  5159. * @param tagsQuery defines the tag query
  5160. * @returns a boolean
  5161. */
  5162. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5163. }
  5164. }
  5165. declare module "babylonjs/Materials/materialDefines" {
  5166. /**
  5167. * Manages the defines for the Material
  5168. */
  5169. export class MaterialDefines {
  5170. /** @hidden */
  5171. protected _keys: string[];
  5172. private _isDirty;
  5173. /** @hidden */
  5174. _renderId: number;
  5175. /** @hidden */
  5176. _areLightsDirty: boolean;
  5177. /** @hidden */
  5178. _areAttributesDirty: boolean;
  5179. /** @hidden */
  5180. _areTexturesDirty: boolean;
  5181. /** @hidden */
  5182. _areFresnelDirty: boolean;
  5183. /** @hidden */
  5184. _areMiscDirty: boolean;
  5185. /** @hidden */
  5186. _areImageProcessingDirty: boolean;
  5187. /** @hidden */
  5188. _normals: boolean;
  5189. /** @hidden */
  5190. _uvs: boolean;
  5191. /** @hidden */
  5192. _needNormals: boolean;
  5193. /** @hidden */
  5194. _needUVs: boolean;
  5195. [id: string]: any;
  5196. /**
  5197. * Specifies if the material needs to be re-calculated
  5198. */
  5199. readonly isDirty: boolean;
  5200. /**
  5201. * Marks the material to indicate that it has been re-calculated
  5202. */
  5203. markAsProcessed(): void;
  5204. /**
  5205. * Marks the material to indicate that it needs to be re-calculated
  5206. */
  5207. markAsUnprocessed(): void;
  5208. /**
  5209. * Marks the material to indicate all of its defines need to be re-calculated
  5210. */
  5211. markAllAsDirty(): void;
  5212. /**
  5213. * Marks the material to indicate that image processing needs to be re-calculated
  5214. */
  5215. markAsImageProcessingDirty(): void;
  5216. /**
  5217. * Marks the material to indicate the lights need to be re-calculated
  5218. */
  5219. markAsLightDirty(): void;
  5220. /**
  5221. * Marks the attribute state as changed
  5222. */
  5223. markAsAttributesDirty(): void;
  5224. /**
  5225. * Marks the texture state as changed
  5226. */
  5227. markAsTexturesDirty(): void;
  5228. /**
  5229. * Marks the fresnel state as changed
  5230. */
  5231. markAsFresnelDirty(): void;
  5232. /**
  5233. * Marks the misc state as changed
  5234. */
  5235. markAsMiscDirty(): void;
  5236. /**
  5237. * Rebuilds the material defines
  5238. */
  5239. rebuild(): void;
  5240. /**
  5241. * Specifies if two material defines are equal
  5242. * @param other - A material define instance to compare to
  5243. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5244. */
  5245. isEqual(other: MaterialDefines): boolean;
  5246. /**
  5247. * Clones this instance's defines to another instance
  5248. * @param other - material defines to clone values to
  5249. */
  5250. cloneTo(other: MaterialDefines): void;
  5251. /**
  5252. * Resets the material define values
  5253. */
  5254. reset(): void;
  5255. /**
  5256. * Converts the material define values to a string
  5257. * @returns - String of material define information
  5258. */
  5259. toString(): string;
  5260. }
  5261. }
  5262. declare module "babylonjs/Engines/IPipelineContext" {
  5263. /**
  5264. * Class used to store and describe the pipeline context associated with an effect
  5265. */
  5266. export interface IPipelineContext {
  5267. /**
  5268. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5269. */
  5270. isAsync: boolean;
  5271. /**
  5272. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5273. */
  5274. isReady: boolean;
  5275. /** @hidden */
  5276. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5277. }
  5278. }
  5279. declare module "babylonjs/Meshes/dataBuffer" {
  5280. /**
  5281. * Class used to store gfx data (like WebGLBuffer)
  5282. */
  5283. export class DataBuffer {
  5284. /**
  5285. * Gets or sets the number of objects referencing this buffer
  5286. */
  5287. references: number;
  5288. /** Gets or sets the size of the underlying buffer */
  5289. capacity: number;
  5290. /**
  5291. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5292. */
  5293. is32Bits: boolean;
  5294. /**
  5295. * Gets the underlying buffer
  5296. */
  5297. readonly underlyingResource: any;
  5298. }
  5299. }
  5300. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  5301. /** @hidden */
  5302. export interface IShaderProcessor {
  5303. attributeProcessor?: (attribute: string) => string;
  5304. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  5305. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  5306. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  5307. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  5308. lineProcessor?: (line: string, isFragment: boolean) => string;
  5309. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5310. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5311. }
  5312. }
  5313. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  5314. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  5315. /** @hidden */
  5316. export interface ProcessingOptions {
  5317. defines: string[];
  5318. indexParameters: any;
  5319. isFragment: boolean;
  5320. shouldUseHighPrecisionShader: boolean;
  5321. supportsUniformBuffers: boolean;
  5322. shadersRepository: string;
  5323. includesShadersStore: {
  5324. [key: string]: string;
  5325. };
  5326. processor?: IShaderProcessor;
  5327. version: string;
  5328. platformName: string;
  5329. lookForClosingBracketForUniformBuffer?: boolean;
  5330. }
  5331. }
  5332. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  5333. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5334. /** @hidden */
  5335. export class ShaderCodeNode {
  5336. line: string;
  5337. children: ShaderCodeNode[];
  5338. additionalDefineKey?: string;
  5339. additionalDefineValue?: string;
  5340. isValid(preprocessors: {
  5341. [key: string]: string;
  5342. }): boolean;
  5343. process(preprocessors: {
  5344. [key: string]: string;
  5345. }, options: ProcessingOptions): string;
  5346. }
  5347. }
  5348. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  5349. /** @hidden */
  5350. export class ShaderCodeCursor {
  5351. private _lines;
  5352. lineIndex: number;
  5353. readonly currentLine: string;
  5354. readonly canRead: boolean;
  5355. lines: string[];
  5356. }
  5357. }
  5358. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  5359. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  5360. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5361. /** @hidden */
  5362. export class ShaderCodeConditionNode extends ShaderCodeNode {
  5363. process(preprocessors: {
  5364. [key: string]: string;
  5365. }, options: ProcessingOptions): string;
  5366. }
  5367. }
  5368. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  5369. /** @hidden */
  5370. export class ShaderDefineExpression {
  5371. isTrue(preprocessors: {
  5372. [key: string]: string;
  5373. }): boolean;
  5374. }
  5375. }
  5376. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  5377. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  5378. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5379. /** @hidden */
  5380. export class ShaderCodeTestNode extends ShaderCodeNode {
  5381. testExpression: ShaderDefineExpression;
  5382. isValid(preprocessors: {
  5383. [key: string]: string;
  5384. }): boolean;
  5385. }
  5386. }
  5387. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  5388. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5389. /** @hidden */
  5390. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  5391. define: string;
  5392. not: boolean;
  5393. constructor(define: string, not?: boolean);
  5394. isTrue(preprocessors: {
  5395. [key: string]: string;
  5396. }): boolean;
  5397. }
  5398. }
  5399. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  5400. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5401. /** @hidden */
  5402. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  5403. leftOperand: ShaderDefineExpression;
  5404. rightOperand: ShaderDefineExpression;
  5405. isTrue(preprocessors: {
  5406. [key: string]: string;
  5407. }): boolean;
  5408. }
  5409. }
  5410. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  5411. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5412. /** @hidden */
  5413. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  5414. leftOperand: ShaderDefineExpression;
  5415. rightOperand: ShaderDefineExpression;
  5416. isTrue(preprocessors: {
  5417. [key: string]: string;
  5418. }): boolean;
  5419. }
  5420. }
  5421. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  5422. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5423. /** @hidden */
  5424. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  5425. define: string;
  5426. operand: string;
  5427. testValue: string;
  5428. constructor(define: string, operand: string, testValue: string);
  5429. isTrue(preprocessors: {
  5430. [key: string]: string;
  5431. }): boolean;
  5432. }
  5433. }
  5434. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  5435. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5436. /** @hidden */
  5437. export class ShaderProcessor {
  5438. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5439. private static _ProcessPrecision;
  5440. private static _ExtractOperation;
  5441. private static _BuildSubExpression;
  5442. private static _BuildExpression;
  5443. private static _MoveCursorWithinIf;
  5444. private static _MoveCursor;
  5445. private static _EvaluatePreProcessors;
  5446. private static _PreparePreProcessors;
  5447. private static _ProcessShaderConversion;
  5448. private static _ProcessIncludes;
  5449. }
  5450. }
  5451. declare module "babylonjs/Misc/performanceMonitor" {
  5452. /**
  5453. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5454. */
  5455. export class PerformanceMonitor {
  5456. private _enabled;
  5457. private _rollingFrameTime;
  5458. private _lastFrameTimeMs;
  5459. /**
  5460. * constructor
  5461. * @param frameSampleSize The number of samples required to saturate the sliding window
  5462. */
  5463. constructor(frameSampleSize?: number);
  5464. /**
  5465. * Samples current frame
  5466. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5467. */
  5468. sampleFrame(timeMs?: number): void;
  5469. /**
  5470. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5471. */
  5472. readonly averageFrameTime: number;
  5473. /**
  5474. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5475. */
  5476. readonly averageFrameTimeVariance: number;
  5477. /**
  5478. * Returns the frame time of the most recent frame
  5479. */
  5480. readonly instantaneousFrameTime: number;
  5481. /**
  5482. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5483. */
  5484. readonly averageFPS: number;
  5485. /**
  5486. * Returns the average framerate in frames per second using the most recent frame time
  5487. */
  5488. readonly instantaneousFPS: number;
  5489. /**
  5490. * Returns true if enough samples have been taken to completely fill the sliding window
  5491. */
  5492. readonly isSaturated: boolean;
  5493. /**
  5494. * Enables contributions to the sliding window sample set
  5495. */
  5496. enable(): void;
  5497. /**
  5498. * Disables contributions to the sliding window sample set
  5499. * Samples will not be interpolated over the disabled period
  5500. */
  5501. disable(): void;
  5502. /**
  5503. * Returns true if sampling is enabled
  5504. */
  5505. readonly isEnabled: boolean;
  5506. /**
  5507. * Resets performance monitor
  5508. */
  5509. reset(): void;
  5510. }
  5511. /**
  5512. * RollingAverage
  5513. *
  5514. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5515. */
  5516. export class RollingAverage {
  5517. /**
  5518. * Current average
  5519. */
  5520. average: number;
  5521. /**
  5522. * Current variance
  5523. */
  5524. variance: number;
  5525. protected _samples: Array<number>;
  5526. protected _sampleCount: number;
  5527. protected _pos: number;
  5528. protected _m2: number;
  5529. /**
  5530. * constructor
  5531. * @param length The number of samples required to saturate the sliding window
  5532. */
  5533. constructor(length: number);
  5534. /**
  5535. * Adds a sample to the sample set
  5536. * @param v The sample value
  5537. */
  5538. add(v: number): void;
  5539. /**
  5540. * Returns previously added values or null if outside of history or outside the sliding window domain
  5541. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5542. * @return Value previously recorded with add() or null if outside of range
  5543. */
  5544. history(i: number): number;
  5545. /**
  5546. * Returns true if enough samples have been taken to completely fill the sliding window
  5547. * @return true if sample-set saturated
  5548. */
  5549. isSaturated(): boolean;
  5550. /**
  5551. * Resets the rolling average (equivalent to 0 samples taken so far)
  5552. */
  5553. reset(): void;
  5554. /**
  5555. * Wraps a value around the sample range boundaries
  5556. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5557. * @return Wrapped position in sample range
  5558. */
  5559. protected _wrapPosition(i: number): number;
  5560. }
  5561. }
  5562. declare module "babylonjs/Misc/stringDictionary" {
  5563. import { Nullable } from "babylonjs/types";
  5564. /**
  5565. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5566. * The underlying implementation relies on an associative array to ensure the best performances.
  5567. * The value can be anything including 'null' but except 'undefined'
  5568. */
  5569. export class StringDictionary<T> {
  5570. /**
  5571. * This will clear this dictionary and copy the content from the 'source' one.
  5572. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5573. * @param source the dictionary to take the content from and copy to this dictionary
  5574. */
  5575. copyFrom(source: StringDictionary<T>): void;
  5576. /**
  5577. * Get a value based from its key
  5578. * @param key the given key to get the matching value from
  5579. * @return the value if found, otherwise undefined is returned
  5580. */
  5581. get(key: string): T | undefined;
  5582. /**
  5583. * Get a value from its key or add it if it doesn't exist.
  5584. * This method will ensure you that a given key/data will be present in the dictionary.
  5585. * @param key the given key to get the matching value from
  5586. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5587. * The factory will only be invoked if there's no data for the given key.
  5588. * @return the value corresponding to the key.
  5589. */
  5590. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5591. /**
  5592. * Get a value from its key if present in the dictionary otherwise add it
  5593. * @param key the key to get the value from
  5594. * @param val if there's no such key/value pair in the dictionary add it with this value
  5595. * @return the value corresponding to the key
  5596. */
  5597. getOrAdd(key: string, val: T): T;
  5598. /**
  5599. * Check if there's a given key in the dictionary
  5600. * @param key the key to check for
  5601. * @return true if the key is present, false otherwise
  5602. */
  5603. contains(key: string): boolean;
  5604. /**
  5605. * Add a new key and its corresponding value
  5606. * @param key the key to add
  5607. * @param value the value corresponding to the key
  5608. * @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
  5609. */
  5610. add(key: string, value: T): boolean;
  5611. /**
  5612. * Update a specific value associated to a key
  5613. * @param key defines the key to use
  5614. * @param value defines the value to store
  5615. * @returns true if the value was updated (or false if the key was not found)
  5616. */
  5617. set(key: string, value: T): boolean;
  5618. /**
  5619. * Get the element of the given key and remove it from the dictionary
  5620. * @param key defines the key to search
  5621. * @returns the value associated with the key or null if not found
  5622. */
  5623. getAndRemove(key: string): Nullable<T>;
  5624. /**
  5625. * Remove a key/value from the dictionary.
  5626. * @param key the key to remove
  5627. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5628. */
  5629. remove(key: string): boolean;
  5630. /**
  5631. * Clear the whole content of the dictionary
  5632. */
  5633. clear(): void;
  5634. /**
  5635. * Gets the current count
  5636. */
  5637. readonly count: number;
  5638. /**
  5639. * Execute a callback on each key/val of the dictionary.
  5640. * Note that you can remove any element in this dictionary in the callback implementation
  5641. * @param callback the callback to execute on a given key/value pair
  5642. */
  5643. forEach(callback: (key: string, val: T) => void): void;
  5644. /**
  5645. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5646. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5647. * Note that you can remove any element in this dictionary in the callback implementation
  5648. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5649. * @returns the first item
  5650. */
  5651. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5652. private _count;
  5653. private _data;
  5654. }
  5655. }
  5656. declare module "babylonjs/Misc/promise" {
  5657. /**
  5658. * Helper class that provides a small promise polyfill
  5659. */
  5660. export class PromisePolyfill {
  5661. /**
  5662. * Static function used to check if the polyfill is required
  5663. * If this is the case then the function will inject the polyfill to window.Promise
  5664. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5665. */
  5666. static Apply(force?: boolean): void;
  5667. }
  5668. }
  5669. declare module "babylonjs/Meshes/buffer" {
  5670. import { Nullable, DataArray } from "babylonjs/types";
  5671. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  5672. /**
  5673. * Class used to store data that will be store in GPU memory
  5674. */
  5675. export class Buffer {
  5676. private _engine;
  5677. private _buffer;
  5678. /** @hidden */
  5679. _data: Nullable<DataArray>;
  5680. private _updatable;
  5681. private _instanced;
  5682. /**
  5683. * Gets the byte stride.
  5684. */
  5685. readonly byteStride: number;
  5686. /**
  5687. * Constructor
  5688. * @param engine the engine
  5689. * @param data the data to use for this buffer
  5690. * @param updatable whether the data is updatable
  5691. * @param stride the stride (optional)
  5692. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5693. * @param instanced whether the buffer is instanced (optional)
  5694. * @param useBytes set to true if the stride in in bytes (optional)
  5695. */
  5696. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5697. /**
  5698. * Create a new VertexBuffer based on the current buffer
  5699. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5700. * @param offset defines offset in the buffer (0 by default)
  5701. * @param size defines the size in floats of attributes (position is 3 for instance)
  5702. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5703. * @param instanced defines if the vertex buffer contains indexed data
  5704. * @param useBytes defines if the offset and stride are in bytes
  5705. * @returns the new vertex buffer
  5706. */
  5707. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5708. /**
  5709. * Gets a boolean indicating if the Buffer is updatable?
  5710. * @returns true if the buffer is updatable
  5711. */
  5712. isUpdatable(): boolean;
  5713. /**
  5714. * Gets current buffer's data
  5715. * @returns a DataArray or null
  5716. */
  5717. getData(): Nullable<DataArray>;
  5718. /**
  5719. * Gets underlying native buffer
  5720. * @returns underlying native buffer
  5721. */
  5722. getBuffer(): Nullable<DataBuffer>;
  5723. /**
  5724. * Gets the stride in float32 units (i.e. byte stride / 4).
  5725. * May not be an integer if the byte stride is not divisible by 4.
  5726. * DEPRECATED. Use byteStride instead.
  5727. * @returns the stride in float32 units
  5728. */
  5729. getStrideSize(): number;
  5730. /**
  5731. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5732. * @param data defines the data to store
  5733. */
  5734. create(data?: Nullable<DataArray>): void;
  5735. /** @hidden */
  5736. _rebuild(): void;
  5737. /**
  5738. * Update current buffer data
  5739. * @param data defines the data to store
  5740. */
  5741. update(data: DataArray): void;
  5742. /**
  5743. * Updates the data directly.
  5744. * @param data the new data
  5745. * @param offset the new offset
  5746. * @param vertexCount the vertex count (optional)
  5747. * @param useBytes set to true if the offset is in bytes
  5748. */
  5749. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5750. /**
  5751. * Release all resources
  5752. */
  5753. dispose(): void;
  5754. }
  5755. /**
  5756. * Specialized buffer used to store vertex data
  5757. */
  5758. export class VertexBuffer {
  5759. /** @hidden */
  5760. _buffer: Buffer;
  5761. private _kind;
  5762. private _size;
  5763. private _ownsBuffer;
  5764. private _instanced;
  5765. private _instanceDivisor;
  5766. /**
  5767. * The byte type.
  5768. */
  5769. static readonly BYTE: number;
  5770. /**
  5771. * The unsigned byte type.
  5772. */
  5773. static readonly UNSIGNED_BYTE: number;
  5774. /**
  5775. * The short type.
  5776. */
  5777. static readonly SHORT: number;
  5778. /**
  5779. * The unsigned short type.
  5780. */
  5781. static readonly UNSIGNED_SHORT: number;
  5782. /**
  5783. * The integer type.
  5784. */
  5785. static readonly INT: number;
  5786. /**
  5787. * The unsigned integer type.
  5788. */
  5789. static readonly UNSIGNED_INT: number;
  5790. /**
  5791. * The float type.
  5792. */
  5793. static readonly FLOAT: number;
  5794. /**
  5795. * Gets or sets the instance divisor when in instanced mode
  5796. */
  5797. instanceDivisor: number;
  5798. /**
  5799. * Gets the byte stride.
  5800. */
  5801. readonly byteStride: number;
  5802. /**
  5803. * Gets the byte offset.
  5804. */
  5805. readonly byteOffset: number;
  5806. /**
  5807. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5808. */
  5809. readonly normalized: boolean;
  5810. /**
  5811. * Gets the data type of each component in the array.
  5812. */
  5813. readonly type: number;
  5814. /**
  5815. * Constructor
  5816. * @param engine the engine
  5817. * @param data the data to use for this vertex buffer
  5818. * @param kind the vertex buffer kind
  5819. * @param updatable whether the data is updatable
  5820. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5821. * @param stride the stride (optional)
  5822. * @param instanced whether the buffer is instanced (optional)
  5823. * @param offset the offset of the data (optional)
  5824. * @param size the number of components (optional)
  5825. * @param type the type of the component (optional)
  5826. * @param normalized whether the data contains normalized data (optional)
  5827. * @param useBytes set to true if stride and offset are in bytes (optional)
  5828. */
  5829. 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);
  5830. /** @hidden */
  5831. _rebuild(): void;
  5832. /**
  5833. * Returns the kind of the VertexBuffer (string)
  5834. * @returns a string
  5835. */
  5836. getKind(): string;
  5837. /**
  5838. * Gets a boolean indicating if the VertexBuffer is updatable?
  5839. * @returns true if the buffer is updatable
  5840. */
  5841. isUpdatable(): boolean;
  5842. /**
  5843. * Gets current buffer's data
  5844. * @returns a DataArray or null
  5845. */
  5846. getData(): Nullable<DataArray>;
  5847. /**
  5848. * Gets underlying native buffer
  5849. * @returns underlying native buffer
  5850. */
  5851. getBuffer(): Nullable<DataBuffer>;
  5852. /**
  5853. * Gets the stride in float32 units (i.e. byte stride / 4).
  5854. * May not be an integer if the byte stride is not divisible by 4.
  5855. * DEPRECATED. Use byteStride instead.
  5856. * @returns the stride in float32 units
  5857. */
  5858. getStrideSize(): number;
  5859. /**
  5860. * Returns the offset as a multiple of the type byte length.
  5861. * DEPRECATED. Use byteOffset instead.
  5862. * @returns the offset in bytes
  5863. */
  5864. getOffset(): number;
  5865. /**
  5866. * Returns the number of components per vertex attribute (integer)
  5867. * @returns the size in float
  5868. */
  5869. getSize(): number;
  5870. /**
  5871. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5872. * @returns true if this buffer is instanced
  5873. */
  5874. getIsInstanced(): boolean;
  5875. /**
  5876. * Returns the instancing divisor, zero for non-instanced (integer).
  5877. * @returns a number
  5878. */
  5879. getInstanceDivisor(): number;
  5880. /**
  5881. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5882. * @param data defines the data to store
  5883. */
  5884. create(data?: DataArray): void;
  5885. /**
  5886. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5887. * This function will create a new buffer if the current one is not updatable
  5888. * @param data defines the data to store
  5889. */
  5890. update(data: DataArray): void;
  5891. /**
  5892. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5893. * Returns the directly updated WebGLBuffer.
  5894. * @param data the new data
  5895. * @param offset the new offset
  5896. * @param useBytes set to true if the offset is in bytes
  5897. */
  5898. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5899. /**
  5900. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5901. */
  5902. dispose(): void;
  5903. /**
  5904. * Enumerates each value of this vertex buffer as numbers.
  5905. * @param count the number of values to enumerate
  5906. * @param callback the callback function called for each value
  5907. */
  5908. forEach(count: number, callback: (value: number, index: number) => void): void;
  5909. /**
  5910. * Positions
  5911. */
  5912. static readonly PositionKind: string;
  5913. /**
  5914. * Normals
  5915. */
  5916. static readonly NormalKind: string;
  5917. /**
  5918. * Tangents
  5919. */
  5920. static readonly TangentKind: string;
  5921. /**
  5922. * Texture coordinates
  5923. */
  5924. static readonly UVKind: string;
  5925. /**
  5926. * Texture coordinates 2
  5927. */
  5928. static readonly UV2Kind: string;
  5929. /**
  5930. * Texture coordinates 3
  5931. */
  5932. static readonly UV3Kind: string;
  5933. /**
  5934. * Texture coordinates 4
  5935. */
  5936. static readonly UV4Kind: string;
  5937. /**
  5938. * Texture coordinates 5
  5939. */
  5940. static readonly UV5Kind: string;
  5941. /**
  5942. * Texture coordinates 6
  5943. */
  5944. static readonly UV6Kind: string;
  5945. /**
  5946. * Colors
  5947. */
  5948. static readonly ColorKind: string;
  5949. /**
  5950. * Matrix indices (for bones)
  5951. */
  5952. static readonly MatricesIndicesKind: string;
  5953. /**
  5954. * Matrix weights (for bones)
  5955. */
  5956. static readonly MatricesWeightsKind: string;
  5957. /**
  5958. * Additional matrix indices (for bones)
  5959. */
  5960. static readonly MatricesIndicesExtraKind: string;
  5961. /**
  5962. * Additional matrix weights (for bones)
  5963. */
  5964. static readonly MatricesWeightsExtraKind: string;
  5965. /**
  5966. * Deduces the stride given a kind.
  5967. * @param kind The kind string to deduce
  5968. * @returns The deduced stride
  5969. */
  5970. static DeduceStride(kind: string): number;
  5971. /**
  5972. * Gets the byte length of the given type.
  5973. * @param type the type
  5974. * @returns the number of bytes
  5975. */
  5976. static GetTypeByteLength(type: number): number;
  5977. /**
  5978. * Enumerates each value of the given parameters as numbers.
  5979. * @param data the data to enumerate
  5980. * @param byteOffset the byte offset of the data
  5981. * @param byteStride the byte stride of the data
  5982. * @param componentCount the number of components per element
  5983. * @param componentType the type of the component
  5984. * @param count the number of values to enumerate
  5985. * @param normalized whether the data is normalized
  5986. * @param callback the callback function called for each value
  5987. */
  5988. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5989. private static _GetFloatValue;
  5990. }
  5991. }
  5992. declare module "babylonjs/Maths/sphericalPolynomial" {
  5993. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5994. /**
  5995. * Class representing spherical harmonics coefficients to the 3rd degree
  5996. */
  5997. export class SphericalHarmonics {
  5998. /**
  5999. * Defines whether or not the harmonics have been prescaled for rendering.
  6000. */
  6001. preScaled: boolean;
  6002. /**
  6003. * The l0,0 coefficients of the spherical harmonics
  6004. */
  6005. l00: Vector3;
  6006. /**
  6007. * The l1,-1 coefficients of the spherical harmonics
  6008. */
  6009. l1_1: Vector3;
  6010. /**
  6011. * The l1,0 coefficients of the spherical harmonics
  6012. */
  6013. l10: Vector3;
  6014. /**
  6015. * The l1,1 coefficients of the spherical harmonics
  6016. */
  6017. l11: Vector3;
  6018. /**
  6019. * The l2,-2 coefficients of the spherical harmonics
  6020. */
  6021. l2_2: Vector3;
  6022. /**
  6023. * The l2,-1 coefficients of the spherical harmonics
  6024. */
  6025. l2_1: Vector3;
  6026. /**
  6027. * The l2,0 coefficients of the spherical harmonics
  6028. */
  6029. l20: Vector3;
  6030. /**
  6031. * The l2,1 coefficients of the spherical harmonics
  6032. */
  6033. l21: Vector3;
  6034. /**
  6035. * The l2,2 coefficients of the spherical harmonics
  6036. */
  6037. l22: Vector3;
  6038. /**
  6039. * Adds a light to the spherical harmonics
  6040. * @param direction the direction of the light
  6041. * @param color the color of the light
  6042. * @param deltaSolidAngle the delta solid angle of the light
  6043. */
  6044. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  6045. /**
  6046. * Scales the spherical harmonics by the given amount
  6047. * @param scale the amount to scale
  6048. */
  6049. scaleInPlace(scale: number): void;
  6050. /**
  6051. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  6052. *
  6053. * ```
  6054. * E_lm = A_l * L_lm
  6055. * ```
  6056. *
  6057. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  6058. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  6059. * the scaling factors are given in equation 9.
  6060. */
  6061. convertIncidentRadianceToIrradiance(): void;
  6062. /**
  6063. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  6064. *
  6065. * ```
  6066. * L = (1/pi) * E * rho
  6067. * ```
  6068. *
  6069. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  6070. */
  6071. convertIrradianceToLambertianRadiance(): void;
  6072. /**
  6073. * Integrates the reconstruction coefficients directly in to the SH preventing further
  6074. * required operations at run time.
  6075. *
  6076. * This is simply done by scaling back the SH with Ylm constants parameter.
  6077. * The trigonometric part being applied by the shader at run time.
  6078. */
  6079. preScaleForRendering(): void;
  6080. /**
  6081. * Constructs a spherical harmonics from an array.
  6082. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  6083. * @returns the spherical harmonics
  6084. */
  6085. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  6086. /**
  6087. * Gets the spherical harmonics from polynomial
  6088. * @param polynomial the spherical polynomial
  6089. * @returns the spherical harmonics
  6090. */
  6091. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  6092. }
  6093. /**
  6094. * Class representing spherical polynomial coefficients to the 3rd degree
  6095. */
  6096. export class SphericalPolynomial {
  6097. private _harmonics;
  6098. /**
  6099. * The spherical harmonics used to create the polynomials.
  6100. */
  6101. readonly preScaledHarmonics: SphericalHarmonics;
  6102. /**
  6103. * The x coefficients of the spherical polynomial
  6104. */
  6105. x: Vector3;
  6106. /**
  6107. * The y coefficients of the spherical polynomial
  6108. */
  6109. y: Vector3;
  6110. /**
  6111. * The z coefficients of the spherical polynomial
  6112. */
  6113. z: Vector3;
  6114. /**
  6115. * The xx coefficients of the spherical polynomial
  6116. */
  6117. xx: Vector3;
  6118. /**
  6119. * The yy coefficients of the spherical polynomial
  6120. */
  6121. yy: Vector3;
  6122. /**
  6123. * The zz coefficients of the spherical polynomial
  6124. */
  6125. zz: Vector3;
  6126. /**
  6127. * The xy coefficients of the spherical polynomial
  6128. */
  6129. xy: Vector3;
  6130. /**
  6131. * The yz coefficients of the spherical polynomial
  6132. */
  6133. yz: Vector3;
  6134. /**
  6135. * The zx coefficients of the spherical polynomial
  6136. */
  6137. zx: Vector3;
  6138. /**
  6139. * Adds an ambient color to the spherical polynomial
  6140. * @param color the color to add
  6141. */
  6142. addAmbient(color: Color3): void;
  6143. /**
  6144. * Scales the spherical polynomial by the given amount
  6145. * @param scale the amount to scale
  6146. */
  6147. scaleInPlace(scale: number): void;
  6148. /**
  6149. * Gets the spherical polynomial from harmonics
  6150. * @param harmonics the spherical harmonics
  6151. * @returns the spherical polynomial
  6152. */
  6153. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  6154. /**
  6155. * Constructs a spherical polynomial from an array.
  6156. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  6157. * @returns the spherical polynomial
  6158. */
  6159. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  6160. }
  6161. }
  6162. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  6163. import { Nullable } from "babylonjs/types";
  6164. /**
  6165. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  6166. */
  6167. export interface CubeMapInfo {
  6168. /**
  6169. * The pixel array for the front face.
  6170. * This is stored in format, left to right, up to down format.
  6171. */
  6172. front: Nullable<ArrayBufferView>;
  6173. /**
  6174. * The pixel array for the back face.
  6175. * This is stored in format, left to right, up to down format.
  6176. */
  6177. back: Nullable<ArrayBufferView>;
  6178. /**
  6179. * The pixel array for the left face.
  6180. * This is stored in format, left to right, up to down format.
  6181. */
  6182. left: Nullable<ArrayBufferView>;
  6183. /**
  6184. * The pixel array for the right face.
  6185. * This is stored in format, left to right, up to down format.
  6186. */
  6187. right: Nullable<ArrayBufferView>;
  6188. /**
  6189. * The pixel array for the up face.
  6190. * This is stored in format, left to right, up to down format.
  6191. */
  6192. up: Nullable<ArrayBufferView>;
  6193. /**
  6194. * The pixel array for the down face.
  6195. * This is stored in format, left to right, up to down format.
  6196. */
  6197. down: Nullable<ArrayBufferView>;
  6198. /**
  6199. * The size of the cubemap stored.
  6200. *
  6201. * Each faces will be size * size pixels.
  6202. */
  6203. size: number;
  6204. /**
  6205. * The format of the texture.
  6206. *
  6207. * RGBA, RGB.
  6208. */
  6209. format: number;
  6210. /**
  6211. * The type of the texture data.
  6212. *
  6213. * UNSIGNED_INT, FLOAT.
  6214. */
  6215. type: number;
  6216. /**
  6217. * Specifies whether the texture is in gamma space.
  6218. */
  6219. gammaSpace: boolean;
  6220. }
  6221. /**
  6222. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6223. */
  6224. export class PanoramaToCubeMapTools {
  6225. private static FACE_FRONT;
  6226. private static FACE_BACK;
  6227. private static FACE_RIGHT;
  6228. private static FACE_LEFT;
  6229. private static FACE_DOWN;
  6230. private static FACE_UP;
  6231. /**
  6232. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6233. *
  6234. * @param float32Array The source data.
  6235. * @param inputWidth The width of the input panorama.
  6236. * @param inputHeight The height of the input panorama.
  6237. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6238. * @return The cubemap data
  6239. */
  6240. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6241. private static CreateCubemapTexture;
  6242. private static CalcProjectionSpherical;
  6243. }
  6244. }
  6245. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  6246. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6247. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6248. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  6249. /**
  6250. * Helper class dealing with the extraction of spherical polynomial dataArray
  6251. * from a cube map.
  6252. */
  6253. export class CubeMapToSphericalPolynomialTools {
  6254. private static FileFaces;
  6255. /**
  6256. * Converts a texture to the according Spherical Polynomial data.
  6257. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6258. *
  6259. * @param texture The texture to extract the information from.
  6260. * @return The Spherical Polynomial data.
  6261. */
  6262. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6263. /**
  6264. * Converts a cubemap to the according Spherical Polynomial data.
  6265. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6266. *
  6267. * @param cubeInfo The Cube map to extract the information from.
  6268. * @return The Spherical Polynomial data.
  6269. */
  6270. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6271. }
  6272. }
  6273. declare module "babylonjs/Engines/engineStore" {
  6274. import { Nullable } from "babylonjs/types";
  6275. import { Engine } from "babylonjs/Engines/engine";
  6276. import { Scene } from "babylonjs/scene";
  6277. /**
  6278. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6279. * during the life time of the application.
  6280. */
  6281. export class EngineStore {
  6282. /** Gets the list of created engines */
  6283. static Instances: import("babylonjs/Engines/engine").Engine[];
  6284. /** @hidden */
  6285. static _LastCreatedScene: Nullable<Scene>;
  6286. /**
  6287. * Gets the latest created engine
  6288. */
  6289. static readonly LastCreatedEngine: Nullable<Engine>;
  6290. /**
  6291. * Gets the latest created scene
  6292. */
  6293. static readonly LastCreatedScene: Nullable<Scene>;
  6294. }
  6295. }
  6296. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6297. /**
  6298. * Define options used to create a render target texture
  6299. */
  6300. export class RenderTargetCreationOptions {
  6301. /**
  6302. * Specifies is mipmaps must be generated
  6303. */
  6304. generateMipMaps?: boolean;
  6305. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6306. generateDepthBuffer?: boolean;
  6307. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6308. generateStencilBuffer?: boolean;
  6309. /** Defines texture type (int by default) */
  6310. type?: number;
  6311. /** Defines sampling mode (trilinear by default) */
  6312. samplingMode?: number;
  6313. /** Defines format (RGBA by default) */
  6314. format?: number;
  6315. }
  6316. }
  6317. declare module "babylonjs/States/alphaCullingState" {
  6318. /**
  6319. * @hidden
  6320. **/
  6321. export class _AlphaState {
  6322. private _isAlphaBlendDirty;
  6323. private _isBlendFunctionParametersDirty;
  6324. private _isBlendEquationParametersDirty;
  6325. private _isBlendConstantsDirty;
  6326. private _alphaBlend;
  6327. private _blendFunctionParameters;
  6328. private _blendEquationParameters;
  6329. private _blendConstants;
  6330. /**
  6331. * Initializes the state.
  6332. */
  6333. constructor();
  6334. readonly isDirty: boolean;
  6335. alphaBlend: boolean;
  6336. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6337. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6338. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6339. reset(): void;
  6340. apply(gl: WebGLRenderingContext): void;
  6341. }
  6342. }
  6343. declare module "babylonjs/States/depthCullingState" {
  6344. import { Nullable } from "babylonjs/types";
  6345. /**
  6346. * @hidden
  6347. **/
  6348. export class _DepthCullingState {
  6349. private _isDepthTestDirty;
  6350. private _isDepthMaskDirty;
  6351. private _isDepthFuncDirty;
  6352. private _isCullFaceDirty;
  6353. private _isCullDirty;
  6354. private _isZOffsetDirty;
  6355. private _isFrontFaceDirty;
  6356. private _depthTest;
  6357. private _depthMask;
  6358. private _depthFunc;
  6359. private _cull;
  6360. private _cullFace;
  6361. private _zOffset;
  6362. private _frontFace;
  6363. /**
  6364. * Initializes the state.
  6365. */
  6366. constructor();
  6367. readonly isDirty: boolean;
  6368. zOffset: number;
  6369. cullFace: Nullable<number>;
  6370. cull: Nullable<boolean>;
  6371. depthFunc: Nullable<number>;
  6372. depthMask: boolean;
  6373. depthTest: boolean;
  6374. frontFace: Nullable<number>;
  6375. reset(): void;
  6376. apply(gl: WebGLRenderingContext): void;
  6377. }
  6378. }
  6379. declare module "babylonjs/States/stencilState" {
  6380. /**
  6381. * @hidden
  6382. **/
  6383. export class _StencilState {
  6384. /** 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 */
  6385. static readonly ALWAYS: number;
  6386. /** Passed to stencilOperation to specify that stencil value must be kept */
  6387. static readonly KEEP: number;
  6388. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6389. static readonly REPLACE: number;
  6390. private _isStencilTestDirty;
  6391. private _isStencilMaskDirty;
  6392. private _isStencilFuncDirty;
  6393. private _isStencilOpDirty;
  6394. private _stencilTest;
  6395. private _stencilMask;
  6396. private _stencilFunc;
  6397. private _stencilFuncRef;
  6398. private _stencilFuncMask;
  6399. private _stencilOpStencilFail;
  6400. private _stencilOpDepthFail;
  6401. private _stencilOpStencilDepthPass;
  6402. readonly isDirty: boolean;
  6403. stencilFunc: number;
  6404. stencilFuncRef: number;
  6405. stencilFuncMask: number;
  6406. stencilOpStencilFail: number;
  6407. stencilOpDepthFail: number;
  6408. stencilOpStencilDepthPass: number;
  6409. stencilMask: number;
  6410. stencilTest: boolean;
  6411. constructor();
  6412. reset(): void;
  6413. apply(gl: WebGLRenderingContext): void;
  6414. }
  6415. }
  6416. declare module "babylonjs/States/index" {
  6417. export * from "babylonjs/States/alphaCullingState";
  6418. export * from "babylonjs/States/depthCullingState";
  6419. export * from "babylonjs/States/stencilState";
  6420. }
  6421. declare module "babylonjs/Instrumentation/timeToken" {
  6422. import { Nullable } from "babylonjs/types";
  6423. /**
  6424. * @hidden
  6425. **/
  6426. export class _TimeToken {
  6427. _startTimeQuery: Nullable<WebGLQuery>;
  6428. _endTimeQuery: Nullable<WebGLQuery>;
  6429. _timeElapsedQuery: Nullable<WebGLQuery>;
  6430. _timeElapsedQueryEnded: boolean;
  6431. }
  6432. }
  6433. declare module "babylonjs/Materials/Textures/internalTexture" {
  6434. import { Observable } from "babylonjs/Misc/observable";
  6435. import { Nullable, int } from "babylonjs/types";
  6436. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6437. import { Engine } from "babylonjs/Engines/engine";
  6438. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6439. /**
  6440. * Class used to store data associated with WebGL texture data for the engine
  6441. * This class should not be used directly
  6442. */
  6443. export class InternalTexture {
  6444. /** @hidden */
  6445. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6446. /**
  6447. * The source of the texture data is unknown
  6448. */
  6449. static DATASOURCE_UNKNOWN: number;
  6450. /**
  6451. * Texture data comes from an URL
  6452. */
  6453. static DATASOURCE_URL: number;
  6454. /**
  6455. * Texture data is only used for temporary storage
  6456. */
  6457. static DATASOURCE_TEMP: number;
  6458. /**
  6459. * Texture data comes from raw data (ArrayBuffer)
  6460. */
  6461. static DATASOURCE_RAW: number;
  6462. /**
  6463. * Texture content is dynamic (video or dynamic texture)
  6464. */
  6465. static DATASOURCE_DYNAMIC: number;
  6466. /**
  6467. * Texture content is generated by rendering to it
  6468. */
  6469. static DATASOURCE_RENDERTARGET: number;
  6470. /**
  6471. * Texture content is part of a multi render target process
  6472. */
  6473. static DATASOURCE_MULTIRENDERTARGET: number;
  6474. /**
  6475. * Texture data comes from a cube data file
  6476. */
  6477. static DATASOURCE_CUBE: number;
  6478. /**
  6479. * Texture data comes from a raw cube data
  6480. */
  6481. static DATASOURCE_CUBERAW: number;
  6482. /**
  6483. * Texture data come from a prefiltered cube data file
  6484. */
  6485. static DATASOURCE_CUBEPREFILTERED: number;
  6486. /**
  6487. * Texture content is raw 3D data
  6488. */
  6489. static DATASOURCE_RAW3D: number;
  6490. /**
  6491. * Texture content is a depth texture
  6492. */
  6493. static DATASOURCE_DEPTHTEXTURE: number;
  6494. /**
  6495. * Texture data comes from a raw cube data encoded with RGBD
  6496. */
  6497. static DATASOURCE_CUBERAW_RGBD: number;
  6498. /**
  6499. * Defines if the texture is ready
  6500. */
  6501. isReady: boolean;
  6502. /**
  6503. * Defines if the texture is a cube texture
  6504. */
  6505. isCube: boolean;
  6506. /**
  6507. * Defines if the texture contains 3D data
  6508. */
  6509. is3D: boolean;
  6510. /**
  6511. * Defines if the texture contains multiview data
  6512. */
  6513. isMultiview: boolean;
  6514. /**
  6515. * Gets the URL used to load this texture
  6516. */
  6517. url: string;
  6518. /**
  6519. * Gets the sampling mode of the texture
  6520. */
  6521. samplingMode: number;
  6522. /**
  6523. * Gets a boolean indicating if the texture needs mipmaps generation
  6524. */
  6525. generateMipMaps: boolean;
  6526. /**
  6527. * Gets the number of samples used by the texture (WebGL2+ only)
  6528. */
  6529. samples: number;
  6530. /**
  6531. * Gets the type of the texture (int, float...)
  6532. */
  6533. type: number;
  6534. /**
  6535. * Gets the format of the texture (RGB, RGBA...)
  6536. */
  6537. format: number;
  6538. /**
  6539. * Observable called when the texture is loaded
  6540. */
  6541. onLoadedObservable: Observable<InternalTexture>;
  6542. /**
  6543. * Gets the width of the texture
  6544. */
  6545. width: number;
  6546. /**
  6547. * Gets the height of the texture
  6548. */
  6549. height: number;
  6550. /**
  6551. * Gets the depth of the texture
  6552. */
  6553. depth: number;
  6554. /**
  6555. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6556. */
  6557. baseWidth: number;
  6558. /**
  6559. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6560. */
  6561. baseHeight: number;
  6562. /**
  6563. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6564. */
  6565. baseDepth: number;
  6566. /**
  6567. * Gets a boolean indicating if the texture is inverted on Y axis
  6568. */
  6569. invertY: boolean;
  6570. /** @hidden */
  6571. _invertVScale: boolean;
  6572. /** @hidden */
  6573. _associatedChannel: number;
  6574. /** @hidden */
  6575. _dataSource: number;
  6576. /** @hidden */
  6577. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6578. /** @hidden */
  6579. _bufferView: Nullable<ArrayBufferView>;
  6580. /** @hidden */
  6581. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6582. /** @hidden */
  6583. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6584. /** @hidden */
  6585. _size: number;
  6586. /** @hidden */
  6587. _extension: string;
  6588. /** @hidden */
  6589. _files: Nullable<string[]>;
  6590. /** @hidden */
  6591. _workingCanvas: Nullable<HTMLCanvasElement>;
  6592. /** @hidden */
  6593. _workingContext: Nullable<CanvasRenderingContext2D>;
  6594. /** @hidden */
  6595. _framebuffer: Nullable<WebGLFramebuffer>;
  6596. /** @hidden */
  6597. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6598. /** @hidden */
  6599. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6600. /** @hidden */
  6601. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6602. /** @hidden */
  6603. _attachments: Nullable<number[]>;
  6604. /** @hidden */
  6605. _cachedCoordinatesMode: Nullable<number>;
  6606. /** @hidden */
  6607. _cachedWrapU: Nullable<number>;
  6608. /** @hidden */
  6609. _cachedWrapV: Nullable<number>;
  6610. /** @hidden */
  6611. _cachedWrapR: Nullable<number>;
  6612. /** @hidden */
  6613. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6614. /** @hidden */
  6615. _isDisabled: boolean;
  6616. /** @hidden */
  6617. _compression: Nullable<string>;
  6618. /** @hidden */
  6619. _generateStencilBuffer: boolean;
  6620. /** @hidden */
  6621. _generateDepthBuffer: boolean;
  6622. /** @hidden */
  6623. _comparisonFunction: number;
  6624. /** @hidden */
  6625. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6626. /** @hidden */
  6627. _lodGenerationScale: number;
  6628. /** @hidden */
  6629. _lodGenerationOffset: number;
  6630. /** @hidden */
  6631. _colorTextureArray: Nullable<WebGLTexture>;
  6632. /** @hidden */
  6633. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6634. /** @hidden */
  6635. _lodTextureHigh: Nullable<BaseTexture>;
  6636. /** @hidden */
  6637. _lodTextureMid: Nullable<BaseTexture>;
  6638. /** @hidden */
  6639. _lodTextureLow: Nullable<BaseTexture>;
  6640. /** @hidden */
  6641. _isRGBD: boolean;
  6642. /** @hidden */
  6643. _linearSpecularLOD: boolean;
  6644. /** @hidden */
  6645. _irradianceTexture: Nullable<BaseTexture>;
  6646. /** @hidden */
  6647. _webGLTexture: Nullable<WebGLTexture>;
  6648. /** @hidden */
  6649. _references: number;
  6650. private _engine;
  6651. /**
  6652. * Gets the Engine the texture belongs to.
  6653. * @returns The babylon engine
  6654. */
  6655. getEngine(): Engine;
  6656. /**
  6657. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6658. */
  6659. readonly dataSource: number;
  6660. /**
  6661. * Creates a new InternalTexture
  6662. * @param engine defines the engine to use
  6663. * @param dataSource defines the type of data that will be used
  6664. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6665. */
  6666. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6667. /**
  6668. * Increments the number of references (ie. the number of Texture that point to it)
  6669. */
  6670. incrementReferences(): void;
  6671. /**
  6672. * Change the size of the texture (not the size of the content)
  6673. * @param width defines the new width
  6674. * @param height defines the new height
  6675. * @param depth defines the new depth (1 by default)
  6676. */
  6677. updateSize(width: int, height: int, depth?: int): void;
  6678. /** @hidden */
  6679. _rebuild(): void;
  6680. /** @hidden */
  6681. _swapAndDie(target: InternalTexture): void;
  6682. /**
  6683. * Dispose the current allocated resources
  6684. */
  6685. dispose(): void;
  6686. }
  6687. }
  6688. declare module "babylonjs/Animations/easing" {
  6689. /**
  6690. * This represents the main contract an easing function should follow.
  6691. * Easing functions are used throughout the animation system.
  6692. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6693. */
  6694. export interface IEasingFunction {
  6695. /**
  6696. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6697. * of the easing function.
  6698. * The link below provides some of the most common examples of easing functions.
  6699. * @see https://easings.net/
  6700. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6701. * @returns the corresponding value on the curve defined by the easing function
  6702. */
  6703. ease(gradient: number): number;
  6704. }
  6705. /**
  6706. * Base class used for every default easing function.
  6707. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6708. */
  6709. export class EasingFunction implements IEasingFunction {
  6710. /**
  6711. * Interpolation follows the mathematical formula associated with the easing function.
  6712. */
  6713. static readonly EASINGMODE_EASEIN: number;
  6714. /**
  6715. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6716. */
  6717. static readonly EASINGMODE_EASEOUT: number;
  6718. /**
  6719. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6720. */
  6721. static readonly EASINGMODE_EASEINOUT: number;
  6722. private _easingMode;
  6723. /**
  6724. * Sets the easing mode of the current function.
  6725. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6726. */
  6727. setEasingMode(easingMode: number): void;
  6728. /**
  6729. * Gets the current easing mode.
  6730. * @returns the easing mode
  6731. */
  6732. getEasingMode(): number;
  6733. /**
  6734. * @hidden
  6735. */
  6736. easeInCore(gradient: number): number;
  6737. /**
  6738. * Given an input gradient between 0 and 1, this returns the corresponding value
  6739. * of the easing function.
  6740. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6741. * @returns the corresponding value on the curve defined by the easing function
  6742. */
  6743. ease(gradient: number): number;
  6744. }
  6745. /**
  6746. * Easing function with a circle shape (see link below).
  6747. * @see https://easings.net/#easeInCirc
  6748. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6749. */
  6750. export class CircleEase extends EasingFunction implements IEasingFunction {
  6751. /** @hidden */
  6752. easeInCore(gradient: number): number;
  6753. }
  6754. /**
  6755. * Easing function with a ease back shape (see link below).
  6756. * @see https://easings.net/#easeInBack
  6757. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6758. */
  6759. export class BackEase extends EasingFunction implements IEasingFunction {
  6760. /** Defines the amplitude of the function */
  6761. amplitude: number;
  6762. /**
  6763. * Instantiates a back ease easing
  6764. * @see https://easings.net/#easeInBack
  6765. * @param amplitude Defines the amplitude of the function
  6766. */
  6767. constructor(
  6768. /** Defines the amplitude of the function */
  6769. amplitude?: number);
  6770. /** @hidden */
  6771. easeInCore(gradient: number): number;
  6772. }
  6773. /**
  6774. * Easing function with a bouncing shape (see link below).
  6775. * @see https://easings.net/#easeInBounce
  6776. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6777. */
  6778. export class BounceEase extends EasingFunction implements IEasingFunction {
  6779. /** Defines the number of bounces */
  6780. bounces: number;
  6781. /** Defines the amplitude of the bounce */
  6782. bounciness: number;
  6783. /**
  6784. * Instantiates a bounce easing
  6785. * @see https://easings.net/#easeInBounce
  6786. * @param bounces Defines the number of bounces
  6787. * @param bounciness Defines the amplitude of the bounce
  6788. */
  6789. constructor(
  6790. /** Defines the number of bounces */
  6791. bounces?: number,
  6792. /** Defines the amplitude of the bounce */
  6793. bounciness?: number);
  6794. /** @hidden */
  6795. easeInCore(gradient: number): number;
  6796. }
  6797. /**
  6798. * Easing function with a power of 3 shape (see link below).
  6799. * @see https://easings.net/#easeInCubic
  6800. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6801. */
  6802. export class CubicEase extends EasingFunction implements IEasingFunction {
  6803. /** @hidden */
  6804. easeInCore(gradient: number): number;
  6805. }
  6806. /**
  6807. * Easing function with an elastic shape (see link below).
  6808. * @see https://easings.net/#easeInElastic
  6809. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6810. */
  6811. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6812. /** Defines the number of oscillations*/
  6813. oscillations: number;
  6814. /** Defines the amplitude of the oscillations*/
  6815. springiness: number;
  6816. /**
  6817. * Instantiates an elastic easing function
  6818. * @see https://easings.net/#easeInElastic
  6819. * @param oscillations Defines the number of oscillations
  6820. * @param springiness Defines the amplitude of the oscillations
  6821. */
  6822. constructor(
  6823. /** Defines the number of oscillations*/
  6824. oscillations?: number,
  6825. /** Defines the amplitude of the oscillations*/
  6826. springiness?: number);
  6827. /** @hidden */
  6828. easeInCore(gradient: number): number;
  6829. }
  6830. /**
  6831. * Easing function with an exponential shape (see link below).
  6832. * @see https://easings.net/#easeInExpo
  6833. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6834. */
  6835. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6836. /** Defines the exponent of the function */
  6837. exponent: number;
  6838. /**
  6839. * Instantiates an exponential easing function
  6840. * @see https://easings.net/#easeInExpo
  6841. * @param exponent Defines the exponent of the function
  6842. */
  6843. constructor(
  6844. /** Defines the exponent of the function */
  6845. exponent?: number);
  6846. /** @hidden */
  6847. easeInCore(gradient: number): number;
  6848. }
  6849. /**
  6850. * Easing function with a power shape (see link below).
  6851. * @see https://easings.net/#easeInQuad
  6852. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6853. */
  6854. export class PowerEase extends EasingFunction implements IEasingFunction {
  6855. /** Defines the power of the function */
  6856. power: number;
  6857. /**
  6858. * Instantiates an power base easing function
  6859. * @see https://easings.net/#easeInQuad
  6860. * @param power Defines the power of the function
  6861. */
  6862. constructor(
  6863. /** Defines the power of the function */
  6864. power?: number);
  6865. /** @hidden */
  6866. easeInCore(gradient: number): number;
  6867. }
  6868. /**
  6869. * Easing function with a power of 2 shape (see link below).
  6870. * @see https://easings.net/#easeInQuad
  6871. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6872. */
  6873. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6874. /** @hidden */
  6875. easeInCore(gradient: number): number;
  6876. }
  6877. /**
  6878. * Easing function with a power of 4 shape (see link below).
  6879. * @see https://easings.net/#easeInQuart
  6880. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6881. */
  6882. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6883. /** @hidden */
  6884. easeInCore(gradient: number): number;
  6885. }
  6886. /**
  6887. * Easing function with a power of 5 shape (see link below).
  6888. * @see https://easings.net/#easeInQuint
  6889. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6890. */
  6891. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6892. /** @hidden */
  6893. easeInCore(gradient: number): number;
  6894. }
  6895. /**
  6896. * Easing function with a sin shape (see link below).
  6897. * @see https://easings.net/#easeInSine
  6898. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6899. */
  6900. export class SineEase extends EasingFunction implements IEasingFunction {
  6901. /** @hidden */
  6902. easeInCore(gradient: number): number;
  6903. }
  6904. /**
  6905. * Easing function with a bezier shape (see link below).
  6906. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6907. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6908. */
  6909. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6910. /** Defines the x component of the start tangent in the bezier curve */
  6911. x1: number;
  6912. /** Defines the y component of the start tangent in the bezier curve */
  6913. y1: number;
  6914. /** Defines the x component of the end tangent in the bezier curve */
  6915. x2: number;
  6916. /** Defines the y component of the end tangent in the bezier curve */
  6917. y2: number;
  6918. /**
  6919. * Instantiates a bezier function
  6920. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6921. * @param x1 Defines the x component of the start tangent in the bezier curve
  6922. * @param y1 Defines the y component of the start tangent in the bezier curve
  6923. * @param x2 Defines the x component of the end tangent in the bezier curve
  6924. * @param y2 Defines the y component of the end tangent in the bezier curve
  6925. */
  6926. constructor(
  6927. /** Defines the x component of the start tangent in the bezier curve */
  6928. x1?: number,
  6929. /** Defines the y component of the start tangent in the bezier curve */
  6930. y1?: number,
  6931. /** Defines the x component of the end tangent in the bezier curve */
  6932. x2?: number,
  6933. /** Defines the y component of the end tangent in the bezier curve */
  6934. y2?: number);
  6935. /** @hidden */
  6936. easeInCore(gradient: number): number;
  6937. }
  6938. }
  6939. declare module "babylonjs/Animations/animationKey" {
  6940. /**
  6941. * Defines an interface which represents an animation key frame
  6942. */
  6943. export interface IAnimationKey {
  6944. /**
  6945. * Frame of the key frame
  6946. */
  6947. frame: number;
  6948. /**
  6949. * Value at the specifies key frame
  6950. */
  6951. value: any;
  6952. /**
  6953. * The input tangent for the cubic hermite spline
  6954. */
  6955. inTangent?: any;
  6956. /**
  6957. * The output tangent for the cubic hermite spline
  6958. */
  6959. outTangent?: any;
  6960. /**
  6961. * The animation interpolation type
  6962. */
  6963. interpolation?: AnimationKeyInterpolation;
  6964. }
  6965. /**
  6966. * Enum for the animation key frame interpolation type
  6967. */
  6968. export enum AnimationKeyInterpolation {
  6969. /**
  6970. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6971. */
  6972. STEP = 1
  6973. }
  6974. }
  6975. declare module "babylonjs/Animations/animationRange" {
  6976. /**
  6977. * Represents the range of an animation
  6978. */
  6979. export class AnimationRange {
  6980. /**The name of the animation range**/
  6981. name: string;
  6982. /**The starting frame of the animation */
  6983. from: number;
  6984. /**The ending frame of the animation*/
  6985. to: number;
  6986. /**
  6987. * Initializes the range of an animation
  6988. * @param name The name of the animation range
  6989. * @param from The starting frame of the animation
  6990. * @param to The ending frame of the animation
  6991. */
  6992. constructor(
  6993. /**The name of the animation range**/
  6994. name: string,
  6995. /**The starting frame of the animation */
  6996. from: number,
  6997. /**The ending frame of the animation*/
  6998. to: number);
  6999. /**
  7000. * Makes a copy of the animation range
  7001. * @returns A copy of the animation range
  7002. */
  7003. clone(): AnimationRange;
  7004. }
  7005. }
  7006. declare module "babylonjs/Animations/animationEvent" {
  7007. /**
  7008. * Composed of a frame, and an action function
  7009. */
  7010. export class AnimationEvent {
  7011. /** The frame for which the event is triggered **/
  7012. frame: number;
  7013. /** The event to perform when triggered **/
  7014. action: (currentFrame: number) => void;
  7015. /** Specifies if the event should be triggered only once**/
  7016. onlyOnce?: boolean | undefined;
  7017. /**
  7018. * Specifies if the animation event is done
  7019. */
  7020. isDone: boolean;
  7021. /**
  7022. * Initializes the animation event
  7023. * @param frame The frame for which the event is triggered
  7024. * @param action The event to perform when triggered
  7025. * @param onlyOnce Specifies if the event should be triggered only once
  7026. */
  7027. constructor(
  7028. /** The frame for which the event is triggered **/
  7029. frame: number,
  7030. /** The event to perform when triggered **/
  7031. action: (currentFrame: number) => void,
  7032. /** Specifies if the event should be triggered only once**/
  7033. onlyOnce?: boolean | undefined);
  7034. /** @hidden */
  7035. _clone(): AnimationEvent;
  7036. }
  7037. }
  7038. declare module "babylonjs/Behaviors/behavior" {
  7039. import { Nullable } from "babylonjs/types";
  7040. /**
  7041. * Interface used to define a behavior
  7042. */
  7043. export interface Behavior<T> {
  7044. /** gets or sets behavior's name */
  7045. name: string;
  7046. /**
  7047. * Function called when the behavior needs to be initialized (after attaching it to a target)
  7048. */
  7049. init(): void;
  7050. /**
  7051. * Called when the behavior is attached to a target
  7052. * @param target defines the target where the behavior is attached to
  7053. */
  7054. attach(target: T): void;
  7055. /**
  7056. * Called when the behavior is detached from its target
  7057. */
  7058. detach(): void;
  7059. }
  7060. /**
  7061. * Interface implemented by classes supporting behaviors
  7062. */
  7063. export interface IBehaviorAware<T> {
  7064. /**
  7065. * Attach a behavior
  7066. * @param behavior defines the behavior to attach
  7067. * @returns the current host
  7068. */
  7069. addBehavior(behavior: Behavior<T>): T;
  7070. /**
  7071. * Remove a behavior from the current object
  7072. * @param behavior defines the behavior to detach
  7073. * @returns the current host
  7074. */
  7075. removeBehavior(behavior: Behavior<T>): T;
  7076. /**
  7077. * Gets a behavior using its name to search
  7078. * @param name defines the name to search
  7079. * @returns the behavior or null if not found
  7080. */
  7081. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  7082. }
  7083. }
  7084. declare module "babylonjs/Collisions/intersectionInfo" {
  7085. import { Nullable } from "babylonjs/types";
  7086. /**
  7087. * @hidden
  7088. */
  7089. export class IntersectionInfo {
  7090. bu: Nullable<number>;
  7091. bv: Nullable<number>;
  7092. distance: number;
  7093. faceId: number;
  7094. subMeshId: number;
  7095. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7096. }
  7097. }
  7098. declare module "babylonjs/Culling/boundingSphere" {
  7099. import { DeepImmutable } from "babylonjs/types";
  7100. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7101. /**
  7102. * Class used to store bounding sphere information
  7103. */
  7104. export class BoundingSphere {
  7105. /**
  7106. * Gets the center of the bounding sphere in local space
  7107. */
  7108. readonly center: Vector3;
  7109. /**
  7110. * Radius of the bounding sphere in local space
  7111. */
  7112. radius: number;
  7113. /**
  7114. * Gets the center of the bounding sphere in world space
  7115. */
  7116. readonly centerWorld: Vector3;
  7117. /**
  7118. * Radius of the bounding sphere in world space
  7119. */
  7120. radiusWorld: number;
  7121. /**
  7122. * Gets the minimum vector in local space
  7123. */
  7124. readonly minimum: Vector3;
  7125. /**
  7126. * Gets the maximum vector in local space
  7127. */
  7128. readonly maximum: Vector3;
  7129. private _worldMatrix;
  7130. private static readonly TmpVector3;
  7131. /**
  7132. * Creates a new bounding sphere
  7133. * @param min defines the minimum vector (in local space)
  7134. * @param max defines the maximum vector (in local space)
  7135. * @param worldMatrix defines the new world matrix
  7136. */
  7137. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7138. /**
  7139. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7140. * @param min defines the new minimum vector (in local space)
  7141. * @param max defines the new maximum vector (in local space)
  7142. * @param worldMatrix defines the new world matrix
  7143. */
  7144. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7145. /**
  7146. * Scale the current bounding sphere by applying a scale factor
  7147. * @param factor defines the scale factor to apply
  7148. * @returns the current bounding box
  7149. */
  7150. scale(factor: number): BoundingSphere;
  7151. /**
  7152. * Gets the world matrix of the bounding box
  7153. * @returns a matrix
  7154. */
  7155. getWorldMatrix(): DeepImmutable<Matrix>;
  7156. /** @hidden */
  7157. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7158. /**
  7159. * Tests if the bounding sphere is intersecting the frustum planes
  7160. * @param frustumPlanes defines the frustum planes to test
  7161. * @returns true if there is an intersection
  7162. */
  7163. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7164. /**
  7165. * Tests if the bounding sphere center is in between the frustum planes.
  7166. * Used for optimistic fast inclusion.
  7167. * @param frustumPlanes defines the frustum planes to test
  7168. * @returns true if the sphere center is in between the frustum planes
  7169. */
  7170. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7171. /**
  7172. * Tests if a point is inside the bounding sphere
  7173. * @param point defines the point to test
  7174. * @returns true if the point is inside the bounding sphere
  7175. */
  7176. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7177. /**
  7178. * Checks if two sphere intersct
  7179. * @param sphere0 sphere 0
  7180. * @param sphere1 sphere 1
  7181. * @returns true if the speres intersect
  7182. */
  7183. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7184. }
  7185. }
  7186. declare module "babylonjs/Culling/boundingBox" {
  7187. import { DeepImmutable } from "babylonjs/types";
  7188. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7189. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7190. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7191. /**
  7192. * Class used to store bounding box information
  7193. */
  7194. export class BoundingBox implements ICullable {
  7195. /**
  7196. * Gets the 8 vectors representing the bounding box in local space
  7197. */
  7198. readonly vectors: Vector3[];
  7199. /**
  7200. * Gets the center of the bounding box in local space
  7201. */
  7202. readonly center: Vector3;
  7203. /**
  7204. * Gets the center of the bounding box in world space
  7205. */
  7206. readonly centerWorld: Vector3;
  7207. /**
  7208. * Gets the extend size in local space
  7209. */
  7210. readonly extendSize: Vector3;
  7211. /**
  7212. * Gets the extend size in world space
  7213. */
  7214. readonly extendSizeWorld: Vector3;
  7215. /**
  7216. * Gets the OBB (object bounding box) directions
  7217. */
  7218. readonly directions: Vector3[];
  7219. /**
  7220. * Gets the 8 vectors representing the bounding box in world space
  7221. */
  7222. readonly vectorsWorld: Vector3[];
  7223. /**
  7224. * Gets the minimum vector in world space
  7225. */
  7226. readonly minimumWorld: Vector3;
  7227. /**
  7228. * Gets the maximum vector in world space
  7229. */
  7230. readonly maximumWorld: Vector3;
  7231. /**
  7232. * Gets the minimum vector in local space
  7233. */
  7234. readonly minimum: Vector3;
  7235. /**
  7236. * Gets the maximum vector in local space
  7237. */
  7238. readonly maximum: Vector3;
  7239. private _worldMatrix;
  7240. private static readonly TmpVector3;
  7241. /**
  7242. * @hidden
  7243. */
  7244. _tag: number;
  7245. /**
  7246. * Creates a new bounding box
  7247. * @param min defines the minimum vector (in local space)
  7248. * @param max defines the maximum vector (in local space)
  7249. * @param worldMatrix defines the new world matrix
  7250. */
  7251. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7252. /**
  7253. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7254. * @param min defines the new minimum vector (in local space)
  7255. * @param max defines the new maximum vector (in local space)
  7256. * @param worldMatrix defines the new world matrix
  7257. */
  7258. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7259. /**
  7260. * Scale the current bounding box by applying a scale factor
  7261. * @param factor defines the scale factor to apply
  7262. * @returns the current bounding box
  7263. */
  7264. scale(factor: number): BoundingBox;
  7265. /**
  7266. * Gets the world matrix of the bounding box
  7267. * @returns a matrix
  7268. */
  7269. getWorldMatrix(): DeepImmutable<Matrix>;
  7270. /** @hidden */
  7271. _update(world: DeepImmutable<Matrix>): void;
  7272. /**
  7273. * Tests if the bounding box is intersecting the frustum planes
  7274. * @param frustumPlanes defines the frustum planes to test
  7275. * @returns true if there is an intersection
  7276. */
  7277. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7278. /**
  7279. * Tests if the bounding box is entirely inside the frustum planes
  7280. * @param frustumPlanes defines the frustum planes to test
  7281. * @returns true if there is an inclusion
  7282. */
  7283. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7284. /**
  7285. * Tests if a point is inside the bounding box
  7286. * @param point defines the point to test
  7287. * @returns true if the point is inside the bounding box
  7288. */
  7289. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7290. /**
  7291. * Tests if the bounding box intersects with a bounding sphere
  7292. * @param sphere defines the sphere to test
  7293. * @returns true if there is an intersection
  7294. */
  7295. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7296. /**
  7297. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7298. * @param min defines the min vector to use
  7299. * @param max defines the max vector to use
  7300. * @returns true if there is an intersection
  7301. */
  7302. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7303. /**
  7304. * Tests if two bounding boxes are intersections
  7305. * @param box0 defines the first box to test
  7306. * @param box1 defines the second box to test
  7307. * @returns true if there is an intersection
  7308. */
  7309. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7310. /**
  7311. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7312. * @param minPoint defines the minimum vector of the bounding box
  7313. * @param maxPoint defines the maximum vector of the bounding box
  7314. * @param sphereCenter defines the sphere center
  7315. * @param sphereRadius defines the sphere radius
  7316. * @returns true if there is an intersection
  7317. */
  7318. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7319. /**
  7320. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7321. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7322. * @param frustumPlanes defines the frustum planes to test
  7323. * @return true if there is an inclusion
  7324. */
  7325. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7326. /**
  7327. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7328. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7329. * @param frustumPlanes defines the frustum planes to test
  7330. * @return true if there is an intersection
  7331. */
  7332. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7333. }
  7334. }
  7335. declare module "babylonjs/Collisions/collider" {
  7336. import { Nullable, IndicesArray } from "babylonjs/types";
  7337. import { Vector3, Plane } from "babylonjs/Maths/math";
  7338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7339. /** @hidden */
  7340. export class Collider {
  7341. /** Define if a collision was found */
  7342. collisionFound: boolean;
  7343. /**
  7344. * Define last intersection point in local space
  7345. */
  7346. intersectionPoint: Vector3;
  7347. /**
  7348. * Define last collided mesh
  7349. */
  7350. collidedMesh: Nullable<AbstractMesh>;
  7351. private _collisionPoint;
  7352. private _planeIntersectionPoint;
  7353. private _tempVector;
  7354. private _tempVector2;
  7355. private _tempVector3;
  7356. private _tempVector4;
  7357. private _edge;
  7358. private _baseToVertex;
  7359. private _destinationPoint;
  7360. private _slidePlaneNormal;
  7361. private _displacementVector;
  7362. /** @hidden */
  7363. _radius: Vector3;
  7364. /** @hidden */
  7365. _retry: number;
  7366. private _velocity;
  7367. private _basePoint;
  7368. private _epsilon;
  7369. /** @hidden */
  7370. _velocityWorldLength: number;
  7371. /** @hidden */
  7372. _basePointWorld: Vector3;
  7373. private _velocityWorld;
  7374. private _normalizedVelocity;
  7375. /** @hidden */
  7376. _initialVelocity: Vector3;
  7377. /** @hidden */
  7378. _initialPosition: Vector3;
  7379. private _nearestDistance;
  7380. private _collisionMask;
  7381. collisionMask: number;
  7382. /**
  7383. * Gets the plane normal used to compute the sliding response (in local space)
  7384. */
  7385. readonly slidePlaneNormal: Vector3;
  7386. /** @hidden */
  7387. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7388. /** @hidden */
  7389. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7390. /** @hidden */
  7391. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7392. /** @hidden */
  7393. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7394. /** @hidden */
  7395. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7396. /** @hidden */
  7397. _getResponse(pos: Vector3, vel: Vector3): void;
  7398. }
  7399. }
  7400. declare module "babylonjs/Culling/boundingInfo" {
  7401. import { DeepImmutable } from "babylonjs/types";
  7402. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7403. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7404. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7405. import { Collider } from "babylonjs/Collisions/collider";
  7406. /**
  7407. * Interface for cullable objects
  7408. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7409. */
  7410. export interface ICullable {
  7411. /**
  7412. * Checks if the object or part of the object is in the frustum
  7413. * @param frustumPlanes Camera near/planes
  7414. * @returns true if the object is in frustum otherwise false
  7415. */
  7416. isInFrustum(frustumPlanes: Plane[]): boolean;
  7417. /**
  7418. * Checks if a cullable object (mesh...) is in the camera frustum
  7419. * Unlike isInFrustum this cheks the full bounding box
  7420. * @param frustumPlanes Camera near/planes
  7421. * @returns true if the object is in frustum otherwise false
  7422. */
  7423. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7424. }
  7425. /**
  7426. * Info for a bounding data of a mesh
  7427. */
  7428. export class BoundingInfo implements ICullable {
  7429. /**
  7430. * Bounding box for the mesh
  7431. */
  7432. readonly boundingBox: BoundingBox;
  7433. /**
  7434. * Bounding sphere for the mesh
  7435. */
  7436. readonly boundingSphere: BoundingSphere;
  7437. private _isLocked;
  7438. private static readonly TmpVector3;
  7439. /**
  7440. * Constructs bounding info
  7441. * @param minimum min vector of the bounding box/sphere
  7442. * @param maximum max vector of the bounding box/sphere
  7443. * @param worldMatrix defines the new world matrix
  7444. */
  7445. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7446. /**
  7447. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7448. * @param min defines the new minimum vector (in local space)
  7449. * @param max defines the new maximum vector (in local space)
  7450. * @param worldMatrix defines the new world matrix
  7451. */
  7452. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7453. /**
  7454. * min vector of the bounding box/sphere
  7455. */
  7456. readonly minimum: Vector3;
  7457. /**
  7458. * max vector of the bounding box/sphere
  7459. */
  7460. readonly maximum: Vector3;
  7461. /**
  7462. * If the info is locked and won't be updated to avoid perf overhead
  7463. */
  7464. isLocked: boolean;
  7465. /**
  7466. * Updates the bounding sphere and box
  7467. * @param world world matrix to be used to update
  7468. */
  7469. update(world: DeepImmutable<Matrix>): void;
  7470. /**
  7471. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7472. * @param center New center of the bounding info
  7473. * @param extend New extend of the bounding info
  7474. * @returns the current bounding info
  7475. */
  7476. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7477. /**
  7478. * Scale the current bounding info by applying a scale factor
  7479. * @param factor defines the scale factor to apply
  7480. * @returns the current bounding info
  7481. */
  7482. scale(factor: number): BoundingInfo;
  7483. /**
  7484. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7485. * @param frustumPlanes defines the frustum to test
  7486. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7487. * @returns true if the bounding info is in the frustum planes
  7488. */
  7489. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7490. /**
  7491. * Gets the world distance between the min and max points of the bounding box
  7492. */
  7493. readonly diagonalLength: number;
  7494. /**
  7495. * Checks if a cullable object (mesh...) is in the camera frustum
  7496. * Unlike isInFrustum this cheks the full bounding box
  7497. * @param frustumPlanes Camera near/planes
  7498. * @returns true if the object is in frustum otherwise false
  7499. */
  7500. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7501. /** @hidden */
  7502. _checkCollision(collider: Collider): boolean;
  7503. /**
  7504. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7505. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7506. * @param point the point to check intersection with
  7507. * @returns if the point intersects
  7508. */
  7509. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7510. /**
  7511. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7512. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7513. * @param boundingInfo the bounding info to check intersection with
  7514. * @param precise if the intersection should be done using OBB
  7515. * @returns if the bounding info intersects
  7516. */
  7517. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7518. }
  7519. }
  7520. declare module "babylonjs/Misc/smartArray" {
  7521. /**
  7522. * Defines an array and its length.
  7523. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7524. */
  7525. export interface ISmartArrayLike<T> {
  7526. /**
  7527. * The data of the array.
  7528. */
  7529. data: Array<T>;
  7530. /**
  7531. * The active length of the array.
  7532. */
  7533. length: number;
  7534. }
  7535. /**
  7536. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7537. */
  7538. export class SmartArray<T> implements ISmartArrayLike<T> {
  7539. /**
  7540. * The full set of data from the array.
  7541. */
  7542. data: Array<T>;
  7543. /**
  7544. * The active length of the array.
  7545. */
  7546. length: number;
  7547. protected _id: number;
  7548. /**
  7549. * Instantiates a Smart Array.
  7550. * @param capacity defines the default capacity of the array.
  7551. */
  7552. constructor(capacity: number);
  7553. /**
  7554. * Pushes a value at the end of the active data.
  7555. * @param value defines the object to push in the array.
  7556. */
  7557. push(value: T): void;
  7558. /**
  7559. * Iterates over the active data and apply the lambda to them.
  7560. * @param func defines the action to apply on each value.
  7561. */
  7562. forEach(func: (content: T) => void): void;
  7563. /**
  7564. * Sorts the full sets of data.
  7565. * @param compareFn defines the comparison function to apply.
  7566. */
  7567. sort(compareFn: (a: T, b: T) => number): void;
  7568. /**
  7569. * Resets the active data to an empty array.
  7570. */
  7571. reset(): void;
  7572. /**
  7573. * Releases all the data from the array as well as the array.
  7574. */
  7575. dispose(): void;
  7576. /**
  7577. * Concats the active data with a given array.
  7578. * @param array defines the data to concatenate with.
  7579. */
  7580. concat(array: any): void;
  7581. /**
  7582. * Returns the position of a value in the active data.
  7583. * @param value defines the value to find the index for
  7584. * @returns the index if found in the active data otherwise -1
  7585. */
  7586. indexOf(value: T): number;
  7587. /**
  7588. * Returns whether an element is part of the active data.
  7589. * @param value defines the value to look for
  7590. * @returns true if found in the active data otherwise false
  7591. */
  7592. contains(value: T): boolean;
  7593. private static _GlobalId;
  7594. }
  7595. /**
  7596. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7597. * The data in this array can only be present once
  7598. */
  7599. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7600. private _duplicateId;
  7601. /**
  7602. * Pushes a value at the end of the active data.
  7603. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7604. * @param value defines the object to push in the array.
  7605. */
  7606. push(value: T): void;
  7607. /**
  7608. * Pushes a value at the end of the active data.
  7609. * If the data is already present, it won t be added again
  7610. * @param value defines the object to push in the array.
  7611. * @returns true if added false if it was already present
  7612. */
  7613. pushNoDuplicate(value: T): boolean;
  7614. /**
  7615. * Resets the active data to an empty array.
  7616. */
  7617. reset(): void;
  7618. /**
  7619. * Concats the active data with a given array.
  7620. * This ensures no dupplicate will be present in the result.
  7621. * @param array defines the data to concatenate with.
  7622. */
  7623. concatWithNoDuplicate(array: any): void;
  7624. }
  7625. }
  7626. declare module "babylonjs/Misc/iInspectable" {
  7627. /**
  7628. * Enum that determines the text-wrapping mode to use.
  7629. */
  7630. export enum InspectableType {
  7631. /**
  7632. * Checkbox for booleans
  7633. */
  7634. Checkbox = 0,
  7635. /**
  7636. * Sliders for numbers
  7637. */
  7638. Slider = 1,
  7639. /**
  7640. * Vector3
  7641. */
  7642. Vector3 = 2,
  7643. /**
  7644. * Quaternions
  7645. */
  7646. Quaternion = 3,
  7647. /**
  7648. * Color3
  7649. */
  7650. Color3 = 4
  7651. }
  7652. /**
  7653. * Interface used to define custom inspectable properties.
  7654. * This interface is used by the inspector to display custom property grids
  7655. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7656. */
  7657. export interface IInspectable {
  7658. /**
  7659. * Gets the label to display
  7660. */
  7661. label: string;
  7662. /**
  7663. * Gets the name of the property to edit
  7664. */
  7665. propertyName: string;
  7666. /**
  7667. * Gets the type of the editor to use
  7668. */
  7669. type: InspectableType;
  7670. /**
  7671. * Gets the minimum value of the property when using in "slider" mode
  7672. */
  7673. min?: number;
  7674. /**
  7675. * Gets the maximum value of the property when using in "slider" mode
  7676. */
  7677. max?: number;
  7678. /**
  7679. * Gets the setp to use when using in "slider" mode
  7680. */
  7681. step?: number;
  7682. }
  7683. }
  7684. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7685. import { Nullable } from "babylonjs/types";
  7686. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7687. /**
  7688. * This represents the required contract to create a new type of texture loader.
  7689. */
  7690. export interface IInternalTextureLoader {
  7691. /**
  7692. * Defines wether the loader supports cascade loading the different faces.
  7693. */
  7694. supportCascades: boolean;
  7695. /**
  7696. * This returns if the loader support the current file information.
  7697. * @param extension defines the file extension of the file being loaded
  7698. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7699. * @param fallback defines the fallback internal texture if any
  7700. * @param isBase64 defines whether the texture is encoded as a base64
  7701. * @param isBuffer defines whether the texture data are stored as a buffer
  7702. * @returns true if the loader can load the specified file
  7703. */
  7704. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7705. /**
  7706. * Transform the url before loading if required.
  7707. * @param rootUrl the url of the texture
  7708. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7709. * @returns the transformed texture
  7710. */
  7711. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7712. /**
  7713. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7714. * @param rootUrl the url of the texture
  7715. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7716. * @returns the fallback texture
  7717. */
  7718. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7719. /**
  7720. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7721. * @param data contains the texture data
  7722. * @param texture defines the BabylonJS internal texture
  7723. * @param createPolynomials will be true if polynomials have been requested
  7724. * @param onLoad defines the callback to trigger once the texture is ready
  7725. * @param onError defines the callback to trigger in case of error
  7726. */
  7727. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7728. /**
  7729. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7730. * @param data contains the texture data
  7731. * @param texture defines the BabylonJS internal texture
  7732. * @param callback defines the method to call once ready to upload
  7733. */
  7734. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7735. }
  7736. }
  7737. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7738. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7739. import { Nullable } from "babylonjs/types";
  7740. import { Scene } from "babylonjs/scene";
  7741. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7742. module "babylonjs/Engines/engine" {
  7743. interface Engine {
  7744. /**
  7745. * Creates a depth stencil cube texture.
  7746. * This is only available in WebGL 2.
  7747. * @param size The size of face edge in the cube texture.
  7748. * @param options The options defining the cube texture.
  7749. * @returns The cube texture
  7750. */
  7751. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7752. /**
  7753. * Creates a cube texture
  7754. * @param rootUrl defines the url where the files to load is located
  7755. * @param scene defines the current scene
  7756. * @param files defines the list of files to load (1 per face)
  7757. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7758. * @param onLoad defines an optional callback raised when the texture is loaded
  7759. * @param onError defines an optional callback raised if there is an issue to load the texture
  7760. * @param format defines the format of the data
  7761. * @param forcedExtension defines the extension to use to pick the right loader
  7762. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7763. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7764. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7765. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7766. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7767. * @returns the cube texture as an InternalTexture
  7768. */
  7769. 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;
  7770. /**
  7771. * Creates a cube texture
  7772. * @param rootUrl defines the url where the files to load is located
  7773. * @param scene defines the current scene
  7774. * @param files defines the list of files to load (1 per face)
  7775. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7776. * @param onLoad defines an optional callback raised when the texture is loaded
  7777. * @param onError defines an optional callback raised if there is an issue to load the texture
  7778. * @param format defines the format of the data
  7779. * @param forcedExtension defines the extension to use to pick the right loader
  7780. * @returns the cube texture as an InternalTexture
  7781. */
  7782. 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;
  7783. /**
  7784. * Creates a cube texture
  7785. * @param rootUrl defines the url where the files to load is located
  7786. * @param scene defines the current scene
  7787. * @param files defines the list of files to load (1 per face)
  7788. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7789. * @param onLoad defines an optional callback raised when the texture is loaded
  7790. * @param onError defines an optional callback raised if there is an issue to load the texture
  7791. * @param format defines the format of the data
  7792. * @param forcedExtension defines the extension to use to pick the right loader
  7793. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7794. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7795. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7796. * @returns the cube texture as an InternalTexture
  7797. */
  7798. 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;
  7799. /** @hidden */
  7800. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7801. /** @hidden */
  7802. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7803. /** @hidden */
  7804. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7805. /** @hidden */
  7806. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7807. }
  7808. }
  7809. }
  7810. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7811. import { Nullable } from "babylonjs/types";
  7812. import { Scene } from "babylonjs/scene";
  7813. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  7814. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7815. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7816. /**
  7817. * Class for creating a cube texture
  7818. */
  7819. export class CubeTexture extends BaseTexture {
  7820. private _delayedOnLoad;
  7821. /**
  7822. * The url of the texture
  7823. */
  7824. url: string;
  7825. /**
  7826. * Gets or sets the center of the bounding box associated with the cube texture.
  7827. * It must define where the camera used to render the texture was set
  7828. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7829. */
  7830. boundingBoxPosition: Vector3;
  7831. private _boundingBoxSize;
  7832. /**
  7833. * Gets or sets the size of the bounding box associated with the cube texture
  7834. * When defined, the cubemap will switch to local mode
  7835. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7836. * @example https://www.babylonjs-playground.com/#RNASML
  7837. */
  7838. /**
  7839. * Returns the bounding box size
  7840. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7841. */
  7842. boundingBoxSize: Vector3;
  7843. protected _rotationY: number;
  7844. /**
  7845. * Sets texture matrix rotation angle around Y axis in radians.
  7846. */
  7847. /**
  7848. * Gets texture matrix rotation angle around Y axis radians.
  7849. */
  7850. rotationY: number;
  7851. /**
  7852. * Are mip maps generated for this texture or not.
  7853. */
  7854. readonly noMipmap: boolean;
  7855. private _noMipmap;
  7856. private _files;
  7857. private _extensions;
  7858. private _textureMatrix;
  7859. private _format;
  7860. private _createPolynomials;
  7861. /** @hidden */
  7862. _prefiltered: boolean;
  7863. /**
  7864. * Creates a cube texture from an array of image urls
  7865. * @param files defines an array of image urls
  7866. * @param scene defines the hosting scene
  7867. * @param noMipmap specifies if mip maps are not used
  7868. * @returns a cube texture
  7869. */
  7870. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7871. /**
  7872. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7873. * @param url defines the url of the prefiltered texture
  7874. * @param scene defines the scene the texture is attached to
  7875. * @param forcedExtension defines the extension of the file if different from the url
  7876. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7877. * @return the prefiltered texture
  7878. */
  7879. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7880. /**
  7881. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7882. * as prefiltered data.
  7883. * @param rootUrl defines the url of the texture or the root name of the six images
  7884. * @param scene defines the scene the texture is attached to
  7885. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7886. * @param noMipmap defines if mipmaps should be created or not
  7887. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7888. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7889. * @param onError defines a callback triggered in case of error during load
  7890. * @param format defines the internal format to use for the texture once loaded
  7891. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7892. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7893. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7894. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7895. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7896. * @return the cube texture
  7897. */
  7898. 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);
  7899. /**
  7900. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7901. */
  7902. readonly isPrefiltered: boolean;
  7903. /**
  7904. * Get the current class name of the texture useful for serialization or dynamic coding.
  7905. * @returns "CubeTexture"
  7906. */
  7907. getClassName(): string;
  7908. /**
  7909. * Update the url (and optional buffer) of this texture if url was null during construction.
  7910. * @param url the url of the texture
  7911. * @param forcedExtension defines the extension to use
  7912. * @param onLoad callback called when the texture is loaded (defaults to null)
  7913. */
  7914. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7915. /**
  7916. * Delays loading of the cube texture
  7917. * @param forcedExtension defines the extension to use
  7918. */
  7919. delayLoad(forcedExtension?: string): void;
  7920. /**
  7921. * Returns the reflection texture matrix
  7922. * @returns the reflection texture matrix
  7923. */
  7924. getReflectionTextureMatrix(): Matrix;
  7925. /**
  7926. * Sets the reflection texture matrix
  7927. * @param value Reflection texture matrix
  7928. */
  7929. setReflectionTextureMatrix(value: Matrix): void;
  7930. /**
  7931. * Parses text to create a cube texture
  7932. * @param parsedTexture define the serialized text to read from
  7933. * @param scene defines the hosting scene
  7934. * @param rootUrl defines the root url of the cube texture
  7935. * @returns a cube texture
  7936. */
  7937. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7938. /**
  7939. * Makes a clone, or deep copy, of the cube texture
  7940. * @returns a new cube texture
  7941. */
  7942. clone(): CubeTexture;
  7943. }
  7944. }
  7945. declare module "babylonjs/Shaders/postprocess.vertex" {
  7946. /** @hidden */
  7947. export var postprocessVertexShader: {
  7948. name: string;
  7949. shader: string;
  7950. };
  7951. }
  7952. declare module "babylonjs/Cameras/targetCamera" {
  7953. import { Nullable } from "babylonjs/types";
  7954. import { Camera } from "babylonjs/Cameras/camera";
  7955. import { Scene } from "babylonjs/scene";
  7956. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  7957. /**
  7958. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  7959. * This is the base of the follow, arc rotate cameras and Free camera
  7960. * @see http://doc.babylonjs.com/features/cameras
  7961. */
  7962. export class TargetCamera extends Camera {
  7963. private static _RigCamTransformMatrix;
  7964. private static _TargetTransformMatrix;
  7965. private static _TargetFocalPoint;
  7966. /**
  7967. * Define the current direction the camera is moving to
  7968. */
  7969. cameraDirection: Vector3;
  7970. /**
  7971. * Define the current rotation the camera is rotating to
  7972. */
  7973. cameraRotation: Vector2;
  7974. /**
  7975. * When set, the up vector of the camera will be updated by the rotation of the camera
  7976. */
  7977. updateUpVectorFromRotation: boolean;
  7978. private _tmpQuaternion;
  7979. /**
  7980. * Define the current rotation of the camera
  7981. */
  7982. rotation: Vector3;
  7983. /**
  7984. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  7985. */
  7986. rotationQuaternion: Quaternion;
  7987. /**
  7988. * Define the current speed of the camera
  7989. */
  7990. speed: number;
  7991. /**
  7992. * Add cconstraint to the camera to prevent it to move freely in all directions and
  7993. * around all axis.
  7994. */
  7995. noRotationConstraint: boolean;
  7996. /**
  7997. * Define the current target of the camera as an object or a position.
  7998. */
  7999. lockedTarget: any;
  8000. /** @hidden */
  8001. _currentTarget: Vector3;
  8002. /** @hidden */
  8003. _initialFocalDistance: number;
  8004. /** @hidden */
  8005. _viewMatrix: Matrix;
  8006. /** @hidden */
  8007. _camMatrix: Matrix;
  8008. /** @hidden */
  8009. _cameraTransformMatrix: Matrix;
  8010. /** @hidden */
  8011. _cameraRotationMatrix: Matrix;
  8012. /** @hidden */
  8013. _referencePoint: Vector3;
  8014. /** @hidden */
  8015. _transformedReferencePoint: Vector3;
  8016. protected _globalCurrentTarget: Vector3;
  8017. protected _globalCurrentUpVector: Vector3;
  8018. /** @hidden */
  8019. _reset: () => void;
  8020. private _defaultUp;
  8021. /**
  8022. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8023. * This is the base of the follow, arc rotate cameras and Free camera
  8024. * @see http://doc.babylonjs.com/features/cameras
  8025. * @param name Defines the name of the camera in the scene
  8026. * @param position Defines the start position of the camera in the scene
  8027. * @param scene Defines the scene the camera belongs to
  8028. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8029. */
  8030. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8031. /**
  8032. * Gets the position in front of the camera at a given distance.
  8033. * @param distance The distance from the camera we want the position to be
  8034. * @returns the position
  8035. */
  8036. getFrontPosition(distance: number): Vector3;
  8037. /** @hidden */
  8038. _getLockedTargetPosition(): Nullable<Vector3>;
  8039. private _storedPosition;
  8040. private _storedRotation;
  8041. private _storedRotationQuaternion;
  8042. /**
  8043. * Store current camera state of the camera (fov, position, rotation, etc..)
  8044. * @returns the camera
  8045. */
  8046. storeState(): Camera;
  8047. /**
  8048. * Restored camera state. You must call storeState() first
  8049. * @returns whether it was successful or not
  8050. * @hidden
  8051. */
  8052. _restoreStateValues(): boolean;
  8053. /** @hidden */
  8054. _initCache(): void;
  8055. /** @hidden */
  8056. _updateCache(ignoreParentClass?: boolean): void;
  8057. /** @hidden */
  8058. _isSynchronizedViewMatrix(): boolean;
  8059. /** @hidden */
  8060. _computeLocalCameraSpeed(): number;
  8061. /**
  8062. * Defines the target the camera should look at.
  8063. * @param target Defines the new target as a Vector or a mesh
  8064. */
  8065. setTarget(target: Vector3): void;
  8066. /**
  8067. * Return the current target position of the camera. This value is expressed in local space.
  8068. * @returns the target position
  8069. */
  8070. getTarget(): Vector3;
  8071. /** @hidden */
  8072. _decideIfNeedsToMove(): boolean;
  8073. /** @hidden */
  8074. _updatePosition(): void;
  8075. /** @hidden */
  8076. _checkInputs(): void;
  8077. protected _updateCameraRotationMatrix(): void;
  8078. /**
  8079. * 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)
  8080. * @returns the current camera
  8081. */
  8082. private _rotateUpVectorWithCameraRotationMatrix;
  8083. private _cachedRotationZ;
  8084. private _cachedQuaternionRotationZ;
  8085. /** @hidden */
  8086. _getViewMatrix(): Matrix;
  8087. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8088. /**
  8089. * @hidden
  8090. */
  8091. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8092. /**
  8093. * @hidden
  8094. */
  8095. _updateRigCameras(): void;
  8096. private _getRigCamPositionAndTarget;
  8097. /**
  8098. * Gets the current object class name.
  8099. * @return the class name
  8100. */
  8101. getClassName(): string;
  8102. }
  8103. }
  8104. declare module "babylonjs/Cameras/cameraInputsManager" {
  8105. import { Nullable } from "babylonjs/types";
  8106. import { Camera } from "babylonjs/Cameras/camera";
  8107. /**
  8108. * @ignore
  8109. * This is a list of all the different input types that are available in the application.
  8110. * Fo instance: ArcRotateCameraGamepadInput...
  8111. */
  8112. export var CameraInputTypes: {};
  8113. /**
  8114. * This is the contract to implement in order to create a new input class.
  8115. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8116. */
  8117. export interface ICameraInput<TCamera extends Camera> {
  8118. /**
  8119. * Defines the camera the input is attached to.
  8120. */
  8121. camera: Nullable<TCamera>;
  8122. /**
  8123. * Gets the class name of the current intput.
  8124. * @returns the class name
  8125. */
  8126. getClassName(): string;
  8127. /**
  8128. * Get the friendly name associated with the input class.
  8129. * @returns the input friendly name
  8130. */
  8131. getSimpleName(): string;
  8132. /**
  8133. * Attach the input controls to a specific dom element to get the input from.
  8134. * @param element Defines the element the controls should be listened from
  8135. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8136. */
  8137. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8138. /**
  8139. * Detach the current controls from the specified dom element.
  8140. * @param element Defines the element to stop listening the inputs from
  8141. */
  8142. detachControl(element: Nullable<HTMLElement>): void;
  8143. /**
  8144. * Update the current camera state depending on the inputs that have been used this frame.
  8145. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8146. */
  8147. checkInputs?: () => void;
  8148. }
  8149. /**
  8150. * Represents a map of input types to input instance or input index to input instance.
  8151. */
  8152. export interface CameraInputsMap<TCamera extends Camera> {
  8153. /**
  8154. * Accessor to the input by input type.
  8155. */
  8156. [name: string]: ICameraInput<TCamera>;
  8157. /**
  8158. * Accessor to the input by input index.
  8159. */
  8160. [idx: number]: ICameraInput<TCamera>;
  8161. }
  8162. /**
  8163. * This represents the input manager used within a camera.
  8164. * It helps dealing with all the different kind of input attached to a camera.
  8165. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8166. */
  8167. export class CameraInputsManager<TCamera extends Camera> {
  8168. /**
  8169. * Defines the list of inputs attahed to the camera.
  8170. */
  8171. attached: CameraInputsMap<TCamera>;
  8172. /**
  8173. * Defines the dom element the camera is collecting inputs from.
  8174. * This is null if the controls have not been attached.
  8175. */
  8176. attachedElement: Nullable<HTMLElement>;
  8177. /**
  8178. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8179. */
  8180. noPreventDefault: boolean;
  8181. /**
  8182. * Defined the camera the input manager belongs to.
  8183. */
  8184. camera: TCamera;
  8185. /**
  8186. * Update the current camera state depending on the inputs that have been used this frame.
  8187. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8188. */
  8189. checkInputs: () => void;
  8190. /**
  8191. * Instantiate a new Camera Input Manager.
  8192. * @param camera Defines the camera the input manager blongs to
  8193. */
  8194. constructor(camera: TCamera);
  8195. /**
  8196. * Add an input method to a camera
  8197. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8198. * @param input camera input method
  8199. */
  8200. add(input: ICameraInput<TCamera>): void;
  8201. /**
  8202. * Remove a specific input method from a camera
  8203. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8204. * @param inputToRemove camera input method
  8205. */
  8206. remove(inputToRemove: ICameraInput<TCamera>): void;
  8207. /**
  8208. * Remove a specific input type from a camera
  8209. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8210. * @param inputType the type of the input to remove
  8211. */
  8212. removeByType(inputType: string): void;
  8213. private _addCheckInputs;
  8214. /**
  8215. * Attach the input controls to the currently attached dom element to listen the events from.
  8216. * @param input Defines the input to attach
  8217. */
  8218. attachInput(input: ICameraInput<TCamera>): void;
  8219. /**
  8220. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8221. * @param element Defines the dom element to collect the events from
  8222. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8223. */
  8224. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8225. /**
  8226. * Detach the current manager inputs controls from a specific dom element.
  8227. * @param element Defines the dom element to collect the events from
  8228. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8229. */
  8230. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8231. /**
  8232. * Rebuild the dynamic inputCheck function from the current list of
  8233. * defined inputs in the manager.
  8234. */
  8235. rebuildInputCheck(): void;
  8236. /**
  8237. * Remove all attached input methods from a camera
  8238. */
  8239. clear(): void;
  8240. /**
  8241. * Serialize the current input manager attached to a camera.
  8242. * This ensures than once parsed,
  8243. * the input associated to the camera will be identical to the current ones
  8244. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8245. */
  8246. serialize(serializedCamera: any): void;
  8247. /**
  8248. * Parses an input manager serialized JSON to restore the previous list of inputs
  8249. * and states associated to a camera.
  8250. * @param parsedCamera Defines the JSON to parse
  8251. */
  8252. parse(parsedCamera: any): void;
  8253. }
  8254. }
  8255. declare module "babylonjs/Events/keyboardEvents" {
  8256. /**
  8257. * Gather the list of keyboard event types as constants.
  8258. */
  8259. export class KeyboardEventTypes {
  8260. /**
  8261. * The keydown event is fired when a key becomes active (pressed).
  8262. */
  8263. static readonly KEYDOWN: number;
  8264. /**
  8265. * The keyup event is fired when a key has been released.
  8266. */
  8267. static readonly KEYUP: number;
  8268. }
  8269. /**
  8270. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8271. */
  8272. export class KeyboardInfo {
  8273. /**
  8274. * Defines the type of event (KeyboardEventTypes)
  8275. */
  8276. type: number;
  8277. /**
  8278. * Defines the related dom event
  8279. */
  8280. event: KeyboardEvent;
  8281. /**
  8282. * Instantiates a new keyboard info.
  8283. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8284. * @param type Defines the type of event (KeyboardEventTypes)
  8285. * @param event Defines the related dom event
  8286. */
  8287. constructor(
  8288. /**
  8289. * Defines the type of event (KeyboardEventTypes)
  8290. */
  8291. type: number,
  8292. /**
  8293. * Defines the related dom event
  8294. */
  8295. event: KeyboardEvent);
  8296. }
  8297. /**
  8298. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8299. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8300. */
  8301. export class KeyboardInfoPre extends KeyboardInfo {
  8302. /**
  8303. * Defines the type of event (KeyboardEventTypes)
  8304. */
  8305. type: number;
  8306. /**
  8307. * Defines the related dom event
  8308. */
  8309. event: KeyboardEvent;
  8310. /**
  8311. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8312. */
  8313. skipOnPointerObservable: boolean;
  8314. /**
  8315. * Instantiates a new keyboard pre info.
  8316. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8317. * @param type Defines the type of event (KeyboardEventTypes)
  8318. * @param event Defines the related dom event
  8319. */
  8320. constructor(
  8321. /**
  8322. * Defines the type of event (KeyboardEventTypes)
  8323. */
  8324. type: number,
  8325. /**
  8326. * Defines the related dom event
  8327. */
  8328. event: KeyboardEvent);
  8329. }
  8330. }
  8331. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8332. import { Nullable } from "babylonjs/types";
  8333. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8334. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8335. /**
  8336. * Manage the keyboard inputs to control the movement of a free camera.
  8337. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8338. */
  8339. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8340. /**
  8341. * Defines the camera the input is attached to.
  8342. */
  8343. camera: FreeCamera;
  8344. /**
  8345. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8346. */
  8347. keysUp: number[];
  8348. /**
  8349. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8350. */
  8351. keysDown: number[];
  8352. /**
  8353. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8354. */
  8355. keysLeft: number[];
  8356. /**
  8357. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8358. */
  8359. keysRight: number[];
  8360. private _keys;
  8361. private _onCanvasBlurObserver;
  8362. private _onKeyboardObserver;
  8363. private _engine;
  8364. private _scene;
  8365. /**
  8366. * Attach the input controls to a specific dom element to get the input from.
  8367. * @param element Defines the element the controls should be listened from
  8368. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8369. */
  8370. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8371. /**
  8372. * Detach the current controls from the specified dom element.
  8373. * @param element Defines the element to stop listening the inputs from
  8374. */
  8375. detachControl(element: Nullable<HTMLElement>): void;
  8376. /**
  8377. * Update the current camera state depending on the inputs that have been used this frame.
  8378. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8379. */
  8380. checkInputs(): void;
  8381. /**
  8382. * Gets the class name of the current intput.
  8383. * @returns the class name
  8384. */
  8385. getClassName(): string;
  8386. /** @hidden */
  8387. _onLostFocus(): void;
  8388. /**
  8389. * Get the friendly name associated with the input class.
  8390. * @returns the input friendly name
  8391. */
  8392. getSimpleName(): string;
  8393. }
  8394. }
  8395. declare module "babylonjs/Materials/multiMaterial" {
  8396. import { Nullable } from "babylonjs/types";
  8397. import { Scene } from "babylonjs/scene";
  8398. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8399. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  8400. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8401. import { Material } from "babylonjs/Materials/material";
  8402. /**
  8403. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8404. * separate meshes. This can be use to improve performances.
  8405. * @see http://doc.babylonjs.com/how_to/multi_materials
  8406. */
  8407. export class MultiMaterial extends Material {
  8408. private _subMaterials;
  8409. /**
  8410. * Gets or Sets the list of Materials used within the multi material.
  8411. * They need to be ordered according to the submeshes order in the associated mesh
  8412. */
  8413. subMaterials: Nullable<Material>[];
  8414. /**
  8415. * Function used to align with Node.getChildren()
  8416. * @returns the list of Materials used within the multi material
  8417. */
  8418. getChildren(): Nullable<Material>[];
  8419. /**
  8420. * Instantiates a new Multi Material
  8421. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8422. * separate meshes. This can be use to improve performances.
  8423. * @see http://doc.babylonjs.com/how_to/multi_materials
  8424. * @param name Define the name in the scene
  8425. * @param scene Define the scene the material belongs to
  8426. */
  8427. constructor(name: string, scene: Scene);
  8428. private _hookArray;
  8429. /**
  8430. * Get one of the submaterial by its index in the submaterials array
  8431. * @param index The index to look the sub material at
  8432. * @returns The Material if the index has been defined
  8433. */
  8434. getSubMaterial(index: number): Nullable<Material>;
  8435. /**
  8436. * Get the list of active textures for the whole sub materials list.
  8437. * @returns All the textures that will be used during the rendering
  8438. */
  8439. getActiveTextures(): BaseTexture[];
  8440. /**
  8441. * Gets the current class name of the material e.g. "MultiMaterial"
  8442. * Mainly use in serialization.
  8443. * @returns the class name
  8444. */
  8445. getClassName(): string;
  8446. /**
  8447. * Checks if the material is ready to render the requested sub mesh
  8448. * @param mesh Define the mesh the submesh belongs to
  8449. * @param subMesh Define the sub mesh to look readyness for
  8450. * @param useInstances Define whether or not the material is used with instances
  8451. * @returns true if ready, otherwise false
  8452. */
  8453. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  8454. /**
  8455. * Clones the current material and its related sub materials
  8456. * @param name Define the name of the newly cloned material
  8457. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  8458. * @returns the cloned material
  8459. */
  8460. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  8461. /**
  8462. * Serializes the materials into a JSON representation.
  8463. * @returns the JSON representation
  8464. */
  8465. serialize(): any;
  8466. /**
  8467. * Dispose the material and release its associated resources
  8468. * @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)
  8469. * @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)
  8470. * @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)
  8471. */
  8472. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  8473. /**
  8474. * Creates a MultiMaterial from parsed MultiMaterial data.
  8475. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  8476. * @param scene defines the hosting scene
  8477. * @returns a new MultiMaterial
  8478. */
  8479. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  8480. }
  8481. }
  8482. declare module "babylonjs/Loading/sceneLoaderFlags" {
  8483. /**
  8484. * Class used to represent data loading progression
  8485. */
  8486. export class SceneLoaderFlags {
  8487. private static _ForceFullSceneLoadingForIncremental;
  8488. private static _ShowLoadingScreen;
  8489. private static _CleanBoneMatrixWeights;
  8490. private static _loggingLevel;
  8491. /**
  8492. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  8493. */
  8494. static ForceFullSceneLoadingForIncremental: boolean;
  8495. /**
  8496. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  8497. */
  8498. static ShowLoadingScreen: boolean;
  8499. /**
  8500. * Defines the current logging level (while loading the scene)
  8501. * @ignorenaming
  8502. */
  8503. static loggingLevel: number;
  8504. /**
  8505. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  8506. */
  8507. static CleanBoneMatrixWeights: boolean;
  8508. }
  8509. }
  8510. declare module "babylonjs/Meshes/transformNode" {
  8511. import { DeepImmutable } from "babylonjs/types";
  8512. import { Observable } from "babylonjs/Misc/observable";
  8513. import { Nullable } from "babylonjs/types";
  8514. import { Camera } from "babylonjs/Cameras/camera";
  8515. import { Scene } from "babylonjs/scene";
  8516. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  8517. import { Node } from "babylonjs/node";
  8518. import { Bone } from "babylonjs/Bones/bone";
  8519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8520. /**
  8521. * 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.
  8522. * @see https://doc.babylonjs.com/how_to/transformnode
  8523. */
  8524. export class TransformNode extends Node {
  8525. /**
  8526. * Object will not rotate to face the camera
  8527. */
  8528. static BILLBOARDMODE_NONE: number;
  8529. /**
  8530. * Object will rotate to face the camera but only on the x axis
  8531. */
  8532. static BILLBOARDMODE_X: number;
  8533. /**
  8534. * Object will rotate to face the camera but only on the y axis
  8535. */
  8536. static BILLBOARDMODE_Y: number;
  8537. /**
  8538. * Object will rotate to face the camera but only on the z axis
  8539. */
  8540. static BILLBOARDMODE_Z: number;
  8541. /**
  8542. * Object will rotate to face the camera
  8543. */
  8544. static BILLBOARDMODE_ALL: number;
  8545. private _forward;
  8546. private _forwardInverted;
  8547. private _up;
  8548. private _right;
  8549. private _rightInverted;
  8550. private _position;
  8551. private _rotation;
  8552. private _rotationQuaternion;
  8553. protected _scaling: Vector3;
  8554. protected _isDirty: boolean;
  8555. private _transformToBoneReferal;
  8556. private _billboardMode;
  8557. /**
  8558. * Gets or sets the billboard mode. Default is 0.
  8559. *
  8560. * | Value | Type | Description |
  8561. * | --- | --- | --- |
  8562. * | 0 | BILLBOARDMODE_NONE | |
  8563. * | 1 | BILLBOARDMODE_X | |
  8564. * | 2 | BILLBOARDMODE_Y | |
  8565. * | 4 | BILLBOARDMODE_Z | |
  8566. * | 7 | BILLBOARDMODE_ALL | |
  8567. *
  8568. */
  8569. billboardMode: number;
  8570. private _preserveParentRotationForBillboard;
  8571. /**
  8572. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  8573. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  8574. */
  8575. preserveParentRotationForBillboard: boolean;
  8576. /**
  8577. * 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
  8578. */
  8579. scalingDeterminant: number;
  8580. private _infiniteDistance;
  8581. /**
  8582. * Gets or sets the distance of the object to max, often used by skybox
  8583. */
  8584. infiniteDistance: boolean;
  8585. /**
  8586. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  8587. * By default the system will update normals to compensate
  8588. */
  8589. ignoreNonUniformScaling: boolean;
  8590. /**
  8591. * 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
  8592. */
  8593. reIntegrateRotationIntoRotationQuaternion: boolean;
  8594. /** @hidden */
  8595. _poseMatrix: Nullable<Matrix>;
  8596. /** @hidden */
  8597. _localMatrix: Matrix;
  8598. private _usePivotMatrix;
  8599. private _absolutePosition;
  8600. private _pivotMatrix;
  8601. private _pivotMatrixInverse;
  8602. protected _postMultiplyPivotMatrix: boolean;
  8603. protected _isWorldMatrixFrozen: boolean;
  8604. /** @hidden */
  8605. _indexInSceneTransformNodesArray: number;
  8606. /**
  8607. * An event triggered after the world matrix is updated
  8608. */
  8609. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  8610. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  8611. /**
  8612. * Gets a string identifying the name of the class
  8613. * @returns "TransformNode" string
  8614. */
  8615. getClassName(): string;
  8616. /**
  8617. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  8618. */
  8619. position: Vector3;
  8620. /**
  8621. * 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)).
  8622. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  8623. */
  8624. rotation: Vector3;
  8625. /**
  8626. * 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)).
  8627. */
  8628. scaling: Vector3;
  8629. /**
  8630. * 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).
  8631. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  8632. */
  8633. rotationQuaternion: Nullable<Quaternion>;
  8634. /**
  8635. * The forward direction of that transform in world space.
  8636. */
  8637. readonly forward: Vector3;
  8638. /**
  8639. * The up direction of that transform in world space.
  8640. */
  8641. readonly up: Vector3;
  8642. /**
  8643. * The right direction of that transform in world space.
  8644. */
  8645. readonly right: Vector3;
  8646. /**
  8647. * Copies the parameter passed Matrix into the mesh Pose matrix.
  8648. * @param matrix the matrix to copy the pose from
  8649. * @returns this TransformNode.
  8650. */
  8651. updatePoseMatrix(matrix: Matrix): TransformNode;
  8652. /**
  8653. * Returns the mesh Pose matrix.
  8654. * @returns the pose matrix
  8655. */
  8656. getPoseMatrix(): Matrix;
  8657. /** @hidden */
  8658. _isSynchronized(): boolean;
  8659. /** @hidden */
  8660. _initCache(): void;
  8661. /**
  8662. * Flag the transform node as dirty (Forcing it to update everything)
  8663. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  8664. * @returns this transform node
  8665. */
  8666. markAsDirty(property: string): TransformNode;
  8667. /**
  8668. * Returns the current mesh absolute position.
  8669. * Returns a Vector3.
  8670. */
  8671. readonly absolutePosition: Vector3;
  8672. /**
  8673. * Sets a new matrix to apply before all other transformation
  8674. * @param matrix defines the transform matrix
  8675. * @returns the current TransformNode
  8676. */
  8677. setPreTransformMatrix(matrix: Matrix): TransformNode;
  8678. /**
  8679. * Sets a new pivot matrix to the current node
  8680. * @param matrix defines the new pivot matrix to use
  8681. * @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
  8682. * @returns the current TransformNode
  8683. */
  8684. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  8685. /**
  8686. * Returns the mesh pivot matrix.
  8687. * Default : Identity.
  8688. * @returns the matrix
  8689. */
  8690. getPivotMatrix(): Matrix;
  8691. /**
  8692. * Prevents the World matrix to be computed any longer.
  8693. * @returns the TransformNode.
  8694. */
  8695. freezeWorldMatrix(): TransformNode;
  8696. /**
  8697. * Allows back the World matrix computation.
  8698. * @returns the TransformNode.
  8699. */
  8700. unfreezeWorldMatrix(): this;
  8701. /**
  8702. * True if the World matrix has been frozen.
  8703. */
  8704. readonly isWorldMatrixFrozen: boolean;
  8705. /**
  8706. * Retuns the mesh absolute position in the World.
  8707. * @returns a Vector3.
  8708. */
  8709. getAbsolutePosition(): Vector3;
  8710. /**
  8711. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  8712. * @param absolutePosition the absolute position to set
  8713. * @returns the TransformNode.
  8714. */
  8715. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  8716. /**
  8717. * Sets the mesh position in its local space.
  8718. * @param vector3 the position to set in localspace
  8719. * @returns the TransformNode.
  8720. */
  8721. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  8722. /**
  8723. * Returns the mesh position in the local space from the current World matrix values.
  8724. * @returns a new Vector3.
  8725. */
  8726. getPositionExpressedInLocalSpace(): Vector3;
  8727. /**
  8728. * Translates the mesh along the passed Vector3 in its local space.
  8729. * @param vector3 the distance to translate in localspace
  8730. * @returns the TransformNode.
  8731. */
  8732. locallyTranslate(vector3: Vector3): TransformNode;
  8733. private static _lookAtVectorCache;
  8734. /**
  8735. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  8736. * @param targetPoint the position (must be in same space as current mesh) to look at
  8737. * @param yawCor optional yaw (y-axis) correction in radians
  8738. * @param pitchCor optional pitch (x-axis) correction in radians
  8739. * @param rollCor optional roll (z-axis) correction in radians
  8740. * @param space the choosen space of the target
  8741. * @returns the TransformNode.
  8742. */
  8743. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  8744. /**
  8745. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8746. * This Vector3 is expressed in the World space.
  8747. * @param localAxis axis to rotate
  8748. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8749. */
  8750. getDirection(localAxis: Vector3): Vector3;
  8751. /**
  8752. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  8753. * localAxis is expressed in the mesh local space.
  8754. * result is computed in the Wordl space from the mesh World matrix.
  8755. * @param localAxis axis to rotate
  8756. * @param result the resulting transformnode
  8757. * @returns this TransformNode.
  8758. */
  8759. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  8760. /**
  8761. * Sets this transform node rotation to the given local axis.
  8762. * @param localAxis the axis in local space
  8763. * @param yawCor optional yaw (y-axis) correction in radians
  8764. * @param pitchCor optional pitch (x-axis) correction in radians
  8765. * @param rollCor optional roll (z-axis) correction in radians
  8766. * @returns this TransformNode
  8767. */
  8768. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  8769. /**
  8770. * Sets a new pivot point to the current node
  8771. * @param point defines the new pivot point to use
  8772. * @param space defines if the point is in world or local space (local by default)
  8773. * @returns the current TransformNode
  8774. */
  8775. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  8776. /**
  8777. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  8778. * @returns the pivot point
  8779. */
  8780. getPivotPoint(): Vector3;
  8781. /**
  8782. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  8783. * @param result the vector3 to store the result
  8784. * @returns this TransformNode.
  8785. */
  8786. getPivotPointToRef(result: Vector3): TransformNode;
  8787. /**
  8788. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  8789. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  8790. */
  8791. getAbsolutePivotPoint(): Vector3;
  8792. /**
  8793. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  8794. * @param result vector3 to store the result
  8795. * @returns this TransformNode.
  8796. */
  8797. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  8798. /**
  8799. * Defines the passed node as the parent of the current node.
  8800. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  8801. * @see https://doc.babylonjs.com/how_to/parenting
  8802. * @param node the node ot set as the parent
  8803. * @returns this TransformNode.
  8804. */
  8805. setParent(node: Nullable<Node>): TransformNode;
  8806. private _nonUniformScaling;
  8807. /**
  8808. * True if the scaling property of this object is non uniform eg. (1,2,1)
  8809. */
  8810. readonly nonUniformScaling: boolean;
  8811. /** @hidden */
  8812. _updateNonUniformScalingState(value: boolean): boolean;
  8813. /**
  8814. * Attach the current TransformNode to another TransformNode associated with a bone
  8815. * @param bone Bone affecting the TransformNode
  8816. * @param affectedTransformNode TransformNode associated with the bone
  8817. * @returns this object
  8818. */
  8819. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  8820. /**
  8821. * Detach the transform node if its associated with a bone
  8822. * @returns this object
  8823. */
  8824. detachFromBone(): TransformNode;
  8825. private static _rotationAxisCache;
  8826. /**
  8827. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  8828. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8829. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8830. * The passed axis is also normalized.
  8831. * @param axis the axis to rotate around
  8832. * @param amount the amount to rotate in radians
  8833. * @param space Space to rotate in (Default: local)
  8834. * @returns the TransformNode.
  8835. */
  8836. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  8837. /**
  8838. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  8839. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8840. * The passed axis is also normalized. .
  8841. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  8842. * @param point the point to rotate around
  8843. * @param axis the axis to rotate around
  8844. * @param amount the amount to rotate in radians
  8845. * @returns the TransformNode
  8846. */
  8847. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  8848. /**
  8849. * Translates the mesh along the axis vector for the passed distance in the given space.
  8850. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8851. * @param axis the axis to translate in
  8852. * @param distance the distance to translate
  8853. * @param space Space to rotate in (Default: local)
  8854. * @returns the TransformNode.
  8855. */
  8856. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  8857. /**
  8858. * Adds a rotation step to the mesh current rotation.
  8859. * x, y, z are Euler angles expressed in radians.
  8860. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  8861. * This means this rotation is made in the mesh local space only.
  8862. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  8863. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  8864. * ```javascript
  8865. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  8866. * ```
  8867. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  8868. * 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.
  8869. * @param x Rotation to add
  8870. * @param y Rotation to add
  8871. * @param z Rotation to add
  8872. * @returns the TransformNode.
  8873. */
  8874. addRotation(x: number, y: number, z: number): TransformNode;
  8875. /**
  8876. * @hidden
  8877. */
  8878. protected _getEffectiveParent(): Nullable<Node>;
  8879. /**
  8880. * Computes the world matrix of the node
  8881. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8882. * @returns the world matrix
  8883. */
  8884. computeWorldMatrix(force?: boolean): Matrix;
  8885. protected _afterComputeWorldMatrix(): void;
  8886. /**
  8887. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  8888. * @param func callback function to add
  8889. *
  8890. * @returns the TransformNode.
  8891. */
  8892. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8893. /**
  8894. * Removes a registered callback function.
  8895. * @param func callback function to remove
  8896. * @returns the TransformNode.
  8897. */
  8898. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8899. /**
  8900. * Gets the position of the current mesh in camera space
  8901. * @param camera defines the camera to use
  8902. * @returns a position
  8903. */
  8904. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  8905. /**
  8906. * Returns the distance from the mesh to the active camera
  8907. * @param camera defines the camera to use
  8908. * @returns the distance
  8909. */
  8910. getDistanceToCamera(camera?: Nullable<Camera>): number;
  8911. /**
  8912. * Clone the current transform node
  8913. * @param name Name of the new clone
  8914. * @param newParent New parent for the clone
  8915. * @param doNotCloneChildren Do not clone children hierarchy
  8916. * @returns the new transform node
  8917. */
  8918. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  8919. /**
  8920. * Serializes the objects information.
  8921. * @param currentSerializationObject defines the object to serialize in
  8922. * @returns the serialized object
  8923. */
  8924. serialize(currentSerializationObject?: any): any;
  8925. /**
  8926. * Returns a new TransformNode object parsed from the source provided.
  8927. * @param parsedTransformNode is the source.
  8928. * @param scene the scne the object belongs to
  8929. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  8930. * @returns a new TransformNode object parsed from the source provided.
  8931. */
  8932. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  8933. /**
  8934. * Get all child-transformNodes of this node
  8935. * @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
  8936. * @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
  8937. * @returns an array of TransformNode
  8938. */
  8939. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  8940. /**
  8941. * Releases resources associated with this transform node.
  8942. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8943. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8944. */
  8945. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8946. /**
  8947. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  8948. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  8949. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  8950. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  8951. * @returns the current mesh
  8952. */
  8953. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  8954. }
  8955. }
  8956. declare module "babylonjs/Animations/animationPropertiesOverride" {
  8957. /**
  8958. * Class used to override all child animations of a given target
  8959. */
  8960. export class AnimationPropertiesOverride {
  8961. /**
  8962. * Gets or sets a value indicating if animation blending must be used
  8963. */
  8964. enableBlending: boolean;
  8965. /**
  8966. * Gets or sets the blending speed to use when enableBlending is true
  8967. */
  8968. blendingSpeed: number;
  8969. /**
  8970. * Gets or sets the default loop mode to use
  8971. */
  8972. loopMode: number;
  8973. }
  8974. }
  8975. declare module "babylonjs/Bones/bone" {
  8976. import { Skeleton } from "babylonjs/Bones/skeleton";
  8977. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  8978. import { Nullable } from "babylonjs/types";
  8979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8980. import { TransformNode } from "babylonjs/Meshes/transformNode";
  8981. import { Node } from "babylonjs/node";
  8982. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  8983. /**
  8984. * Class used to store bone information
  8985. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8986. */
  8987. export class Bone extends Node {
  8988. /**
  8989. * defines the bone name
  8990. */
  8991. name: string;
  8992. private static _tmpVecs;
  8993. private static _tmpQuat;
  8994. private static _tmpMats;
  8995. /**
  8996. * Gets the list of child bones
  8997. */
  8998. children: Bone[];
  8999. /** Gets the animations associated with this bone */
  9000. animations: import("babylonjs/Animations/animation").Animation[];
  9001. /**
  9002. * Gets or sets bone length
  9003. */
  9004. length: number;
  9005. /**
  9006. * @hidden Internal only
  9007. * Set this value to map this bone to a different index in the transform matrices
  9008. * Set this value to -1 to exclude the bone from the transform matrices
  9009. */
  9010. _index: Nullable<number>;
  9011. private _skeleton;
  9012. private _localMatrix;
  9013. private _restPose;
  9014. private _baseMatrix;
  9015. private _absoluteTransform;
  9016. private _invertedAbsoluteTransform;
  9017. private _parent;
  9018. private _scalingDeterminant;
  9019. private _worldTransform;
  9020. private _localScaling;
  9021. private _localRotation;
  9022. private _localPosition;
  9023. private _needToDecompose;
  9024. private _needToCompose;
  9025. /** @hidden */
  9026. _linkedTransformNode: Nullable<TransformNode>;
  9027. /** @hidden */
  9028. _waitingTransformNodeId: Nullable<string>;
  9029. /** @hidden */
  9030. /** @hidden */
  9031. _matrix: Matrix;
  9032. /**
  9033. * Create a new bone
  9034. * @param name defines the bone name
  9035. * @param skeleton defines the parent skeleton
  9036. * @param parentBone defines the parent (can be null if the bone is the root)
  9037. * @param localMatrix defines the local matrix
  9038. * @param restPose defines the rest pose matrix
  9039. * @param baseMatrix defines the base matrix
  9040. * @param index defines index of the bone in the hiearchy
  9041. */
  9042. constructor(
  9043. /**
  9044. * defines the bone name
  9045. */
  9046. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  9047. /**
  9048. * Gets the current object class name.
  9049. * @return the class name
  9050. */
  9051. getClassName(): string;
  9052. /**
  9053. * Gets the parent skeleton
  9054. * @returns a skeleton
  9055. */
  9056. getSkeleton(): Skeleton;
  9057. /**
  9058. * Gets parent bone
  9059. * @returns a bone or null if the bone is the root of the bone hierarchy
  9060. */
  9061. getParent(): Nullable<Bone>;
  9062. /**
  9063. * Returns an array containing the root bones
  9064. * @returns an array containing the root bones
  9065. */
  9066. getChildren(): Array<Bone>;
  9067. /**
  9068. * Sets the parent bone
  9069. * @param parent defines the parent (can be null if the bone is the root)
  9070. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9071. */
  9072. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  9073. /**
  9074. * Gets the local matrix
  9075. * @returns a matrix
  9076. */
  9077. getLocalMatrix(): Matrix;
  9078. /**
  9079. * Gets the base matrix (initial matrix which remains unchanged)
  9080. * @returns a matrix
  9081. */
  9082. getBaseMatrix(): Matrix;
  9083. /**
  9084. * Gets the rest pose matrix
  9085. * @returns a matrix
  9086. */
  9087. getRestPose(): Matrix;
  9088. /**
  9089. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9090. */
  9091. getWorldMatrix(): Matrix;
  9092. /**
  9093. * Sets the local matrix to rest pose matrix
  9094. */
  9095. returnToRest(): void;
  9096. /**
  9097. * Gets the inverse of the absolute transform matrix.
  9098. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9099. * @returns a matrix
  9100. */
  9101. getInvertedAbsoluteTransform(): Matrix;
  9102. /**
  9103. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9104. * @returns a matrix
  9105. */
  9106. getAbsoluteTransform(): Matrix;
  9107. /**
  9108. * Links with the given transform node.
  9109. * The local matrix of this bone is copied from the transform node every frame.
  9110. * @param transformNode defines the transform node to link to
  9111. */
  9112. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  9113. /** Gets or sets current position (in local space) */
  9114. position: Vector3;
  9115. /** Gets or sets current rotation (in local space) */
  9116. rotation: Vector3;
  9117. /** Gets or sets current rotation quaternion (in local space) */
  9118. rotationQuaternion: Quaternion;
  9119. /** Gets or sets current scaling (in local space) */
  9120. scaling: Vector3;
  9121. /**
  9122. * Gets the animation properties override
  9123. */
  9124. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  9125. private _decompose;
  9126. private _compose;
  9127. /**
  9128. * Update the base and local matrices
  9129. * @param matrix defines the new base or local matrix
  9130. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9131. * @param updateLocalMatrix defines if the local matrix should be updated
  9132. */
  9133. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  9134. /** @hidden */
  9135. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  9136. /**
  9137. * Flag the bone as dirty (Forcing it to update everything)
  9138. */
  9139. markAsDirty(): void;
  9140. /** @hidden */
  9141. _markAsDirtyAndCompose(): void;
  9142. private _markAsDirtyAndDecompose;
  9143. /**
  9144. * Translate the bone in local or world space
  9145. * @param vec The amount to translate the bone
  9146. * @param space The space that the translation is in
  9147. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9148. */
  9149. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9150. /**
  9151. * Set the postion of the bone in local or world space
  9152. * @param position The position to set the bone
  9153. * @param space The space that the position is in
  9154. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9155. */
  9156. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9157. /**
  9158. * Set the absolute position of the bone (world space)
  9159. * @param position The position to set the bone
  9160. * @param mesh The mesh that this bone is attached to
  9161. */
  9162. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  9163. /**
  9164. * Scale the bone on the x, y and z axes (in local space)
  9165. * @param x The amount to scale the bone on the x axis
  9166. * @param y The amount to scale the bone on the y axis
  9167. * @param z The amount to scale the bone on the z axis
  9168. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  9169. */
  9170. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  9171. /**
  9172. * Set the bone scaling in local space
  9173. * @param scale defines the scaling vector
  9174. */
  9175. setScale(scale: Vector3): void;
  9176. /**
  9177. * Gets the current scaling in local space
  9178. * @returns the current scaling vector
  9179. */
  9180. getScale(): Vector3;
  9181. /**
  9182. * Gets the current scaling in local space and stores it in a target vector
  9183. * @param result defines the target vector
  9184. */
  9185. getScaleToRef(result: Vector3): void;
  9186. /**
  9187. * Set the yaw, pitch, and roll of the bone in local or world space
  9188. * @param yaw The rotation of the bone on the y axis
  9189. * @param pitch The rotation of the bone on the x axis
  9190. * @param roll The rotation of the bone on the z axis
  9191. * @param space The space that the axes of rotation are in
  9192. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9193. */
  9194. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  9195. /**
  9196. * Add a rotation to the bone on an axis in local or world space
  9197. * @param axis The axis to rotate the bone on
  9198. * @param amount The amount to rotate the bone
  9199. * @param space The space that the axis is in
  9200. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9201. */
  9202. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  9203. /**
  9204. * Set the rotation of the bone to a particular axis angle in local or world space
  9205. * @param axis The axis to rotate the bone on
  9206. * @param angle The angle that the bone should be rotated to
  9207. * @param space The space that the axis is in
  9208. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9209. */
  9210. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  9211. /**
  9212. * Set the euler rotation of the bone in local of world space
  9213. * @param rotation The euler rotation that the bone should be set to
  9214. * @param space The space that the rotation is in
  9215. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9216. */
  9217. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9218. /**
  9219. * Set the quaternion rotation of the bone in local of world space
  9220. * @param quat The quaternion rotation that the bone should be set to
  9221. * @param space The space that the rotation is in
  9222. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9223. */
  9224. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  9225. /**
  9226. * Set the rotation matrix of the bone in local of world space
  9227. * @param rotMat The rotation matrix that the bone should be set to
  9228. * @param space The space that the rotation is in
  9229. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9230. */
  9231. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  9232. private _rotateWithMatrix;
  9233. private _getNegativeRotationToRef;
  9234. /**
  9235. * Get the position of the bone in local or world space
  9236. * @param space The space that the returned position is in
  9237. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9238. * @returns The position of the bone
  9239. */
  9240. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9241. /**
  9242. * Copy the position of the bone to a vector3 in local or world space
  9243. * @param space The space that the returned position is in
  9244. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9245. * @param result The vector3 to copy the position to
  9246. */
  9247. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  9248. /**
  9249. * Get the absolute position of the bone (world space)
  9250. * @param mesh The mesh that this bone is attached to
  9251. * @returns The absolute position of the bone
  9252. */
  9253. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  9254. /**
  9255. * Copy the absolute position of the bone (world space) to the result param
  9256. * @param mesh The mesh that this bone is attached to
  9257. * @param result The vector3 to copy the absolute position to
  9258. */
  9259. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  9260. /**
  9261. * Compute the absolute transforms of this bone and its children
  9262. */
  9263. computeAbsoluteTransforms(): void;
  9264. /**
  9265. * Get the world direction from an axis that is in the local space of the bone
  9266. * @param localAxis The local direction that is used to compute the world direction
  9267. * @param mesh The mesh that this bone is attached to
  9268. * @returns The world direction
  9269. */
  9270. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9271. /**
  9272. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  9273. * @param localAxis The local direction that is used to compute the world direction
  9274. * @param mesh The mesh that this bone is attached to
  9275. * @param result The vector3 that the world direction will be copied to
  9276. */
  9277. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9278. /**
  9279. * Get the euler rotation of the bone in local or world space
  9280. * @param space The space that the rotation should be in
  9281. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9282. * @returns The euler rotation
  9283. */
  9284. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9285. /**
  9286. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  9287. * @param space The space that the rotation should be in
  9288. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9289. * @param result The vector3 that the rotation should be copied to
  9290. */
  9291. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9292. /**
  9293. * Get the quaternion rotation of the bone in either local or world space
  9294. * @param space The space that the rotation should be in
  9295. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9296. * @returns The quaternion rotation
  9297. */
  9298. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  9299. /**
  9300. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  9301. * @param space The space that the rotation should be in
  9302. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9303. * @param result The quaternion that the rotation should be copied to
  9304. */
  9305. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  9306. /**
  9307. * Get the rotation matrix of the bone in local or world space
  9308. * @param space The space that the rotation should be in
  9309. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9310. * @returns The rotation matrix
  9311. */
  9312. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  9313. /**
  9314. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  9315. * @param space The space that the rotation should be in
  9316. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9317. * @param result The quaternion that the rotation should be copied to
  9318. */
  9319. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  9320. /**
  9321. * Get the world position of a point that is in the local space of the bone
  9322. * @param position The local position
  9323. * @param mesh The mesh that this bone is attached to
  9324. * @returns The world position
  9325. */
  9326. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9327. /**
  9328. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  9329. * @param position The local position
  9330. * @param mesh The mesh that this bone is attached to
  9331. * @param result The vector3 that the world position should be copied to
  9332. */
  9333. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9334. /**
  9335. * Get the local position of a point that is in world space
  9336. * @param position The world position
  9337. * @param mesh The mesh that this bone is attached to
  9338. * @returns The local position
  9339. */
  9340. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9341. /**
  9342. * Get the local position of a point that is in world space and copy it to the result param
  9343. * @param position The world position
  9344. * @param mesh The mesh that this bone is attached to
  9345. * @param result The vector3 that the local position should be copied to
  9346. */
  9347. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9348. }
  9349. }
  9350. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  9351. import { Nullable } from "babylonjs/types";
  9352. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  9353. import { Scene } from "babylonjs/scene";
  9354. module "babylonjs/Engines/engine" {
  9355. interface Engine {
  9356. /**
  9357. * Creates a raw texture
  9358. * @param data defines the data to store in the texture
  9359. * @param width defines the width of the texture
  9360. * @param height defines the height of the texture
  9361. * @param format defines the format of the data
  9362. * @param generateMipMaps defines if the engine should generate the mip levels
  9363. * @param invertY defines if data must be stored with Y axis inverted
  9364. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  9365. * @param compression defines the compression used (null by default)
  9366. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9367. * @returns the raw texture inside an InternalTexture
  9368. */
  9369. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  9370. /**
  9371. * Update a raw texture
  9372. * @param texture defines the texture to update
  9373. * @param data defines the data to store in the texture
  9374. * @param format defines the format of the data
  9375. * @param invertY defines if data must be stored with Y axis inverted
  9376. */
  9377. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9378. /**
  9379. * Update a raw texture
  9380. * @param texture defines the texture to update
  9381. * @param data defines the data to store in the texture
  9382. * @param format defines the format of the data
  9383. * @param invertY defines if data must be stored with Y axis inverted
  9384. * @param compression defines the compression used (null by default)
  9385. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9386. */
  9387. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  9388. /**
  9389. * Creates a new raw cube texture
  9390. * @param data defines the array of data to use to create each face
  9391. * @param size defines the size of the textures
  9392. * @param format defines the format of the data
  9393. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9394. * @param generateMipMaps defines if the engine should generate the mip levels
  9395. * @param invertY defines if data must be stored with Y axis inverted
  9396. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9397. * @param compression defines the compression used (null by default)
  9398. * @returns the cube texture as an InternalTexture
  9399. */
  9400. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  9401. /**
  9402. * Update a raw cube texture
  9403. * @param texture defines the texture to udpdate
  9404. * @param data defines the data to store
  9405. * @param format defines the data format
  9406. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9407. * @param invertY defines if data must be stored with Y axis inverted
  9408. */
  9409. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  9410. /**
  9411. * Update a raw cube texture
  9412. * @param texture defines the texture to udpdate
  9413. * @param data defines the data to store
  9414. * @param format defines the data format
  9415. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9416. * @param invertY defines if data must be stored with Y axis inverted
  9417. * @param compression defines the compression used (null by default)
  9418. */
  9419. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  9420. /**
  9421. * Update a raw cube texture
  9422. * @param texture defines the texture to udpdate
  9423. * @param data defines the data to store
  9424. * @param format defines the data format
  9425. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9426. * @param invertY defines if data must be stored with Y axis inverted
  9427. * @param compression defines the compression used (null by default)
  9428. * @param level defines which level of the texture to update
  9429. */
  9430. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  9431. /**
  9432. * Creates a new raw cube texture from a specified url
  9433. * @param url defines the url where the data is located
  9434. * @param scene defines the current scene
  9435. * @param size defines the size of the textures
  9436. * @param format defines the format of the data
  9437. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9438. * @param noMipmap defines if the engine should avoid generating the mip levels
  9439. * @param callback defines a callback used to extract texture data from loaded data
  9440. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9441. * @param onLoad defines a callback called when texture is loaded
  9442. * @param onError defines a callback called if there is an error
  9443. * @returns the cube texture as an InternalTexture
  9444. */
  9445. 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;
  9446. /**
  9447. * Creates a new raw cube texture from a specified url
  9448. * @param url defines the url where the data is located
  9449. * @param scene defines the current scene
  9450. * @param size defines the size of the textures
  9451. * @param format defines the format of the data
  9452. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9453. * @param noMipmap defines if the engine should avoid generating the mip levels
  9454. * @param callback defines a callback used to extract texture data from loaded data
  9455. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9456. * @param onLoad defines a callback called when texture is loaded
  9457. * @param onError defines a callback called if there is an error
  9458. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9459. * @param invertY defines if data must be stored with Y axis inverted
  9460. * @returns the cube texture as an InternalTexture
  9461. */
  9462. 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;
  9463. /**
  9464. * Creates a new raw 3D texture
  9465. * @param data defines the data used to create the texture
  9466. * @param width defines the width of the texture
  9467. * @param height defines the height of the texture
  9468. * @param depth defines the depth of the texture
  9469. * @param format defines the format of the texture
  9470. * @param generateMipMaps defines if the engine must generate mip levels
  9471. * @param invertY defines if data must be stored with Y axis inverted
  9472. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9473. * @param compression defines the compressed used (can be null)
  9474. * @param textureType defines the compressed used (can be null)
  9475. * @returns a new raw 3D texture (stored in an InternalTexture)
  9476. */
  9477. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  9478. /**
  9479. * Update a raw 3D texture
  9480. * @param texture defines the texture to update
  9481. * @param data defines the data to store
  9482. * @param format defines the data format
  9483. * @param invertY defines if data must be stored with Y axis inverted
  9484. */
  9485. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9486. /**
  9487. * Update a raw 3D texture
  9488. * @param texture defines the texture to update
  9489. * @param data defines the data to store
  9490. * @param format defines the data format
  9491. * @param invertY defines if data must be stored with Y axis inverted
  9492. * @param compression defines the used compression (can be null)
  9493. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  9494. */
  9495. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  9496. }
  9497. }
  9498. }
  9499. declare module "babylonjs/Materials/Textures/rawTexture" {
  9500. import { Scene } from "babylonjs/scene";
  9501. import { Texture } from "babylonjs/Materials/Textures/texture";
  9502. import "babylonjs/Engines/Extensions/engine.rawTexture";
  9503. /**
  9504. * Raw texture can help creating a texture directly from an array of data.
  9505. * This can be super useful if you either get the data from an uncompressed source or
  9506. * if you wish to create your texture pixel by pixel.
  9507. */
  9508. export class RawTexture extends Texture {
  9509. /**
  9510. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9511. */
  9512. format: number;
  9513. private _engine;
  9514. /**
  9515. * Instantiates a new RawTexture.
  9516. * Raw texture can help creating a texture directly from an array of data.
  9517. * This can be super useful if you either get the data from an uncompressed source or
  9518. * if you wish to create your texture pixel by pixel.
  9519. * @param data define the array of data to use to create the texture
  9520. * @param width define the width of the texture
  9521. * @param height define the height of the texture
  9522. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9523. * @param scene define the scene the texture belongs to
  9524. * @param generateMipMaps define whether mip maps should be generated or not
  9525. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9526. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9527. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9528. */
  9529. constructor(data: ArrayBufferView, width: number, height: number,
  9530. /**
  9531. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9532. */
  9533. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  9534. /**
  9535. * Updates the texture underlying data.
  9536. * @param data Define the new data of the texture
  9537. */
  9538. update(data: ArrayBufferView): void;
  9539. /**
  9540. * Creates a luminance texture from some data.
  9541. * @param data Define the texture data
  9542. * @param width Define the width of the texture
  9543. * @param height Define the height of the texture
  9544. * @param scene Define the scene the texture belongs to
  9545. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9546. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9547. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9548. * @returns the luminance texture
  9549. */
  9550. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9551. /**
  9552. * Creates a luminance alpha texture from some data.
  9553. * @param data Define the texture data
  9554. * @param width Define the width of the texture
  9555. * @param height Define the height of the texture
  9556. * @param scene Define the scene the texture belongs to
  9557. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9558. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9559. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9560. * @returns the luminance alpha texture
  9561. */
  9562. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9563. /**
  9564. * Creates an alpha texture from some data.
  9565. * @param data Define the texture data
  9566. * @param width Define the width of the texture
  9567. * @param height Define the height of the texture
  9568. * @param scene Define the scene the texture belongs to
  9569. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9570. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9571. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9572. * @returns the alpha texture
  9573. */
  9574. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9575. /**
  9576. * Creates a RGB texture from some data.
  9577. * @param data Define the texture data
  9578. * @param width Define the width of the texture
  9579. * @param height Define the height of the texture
  9580. * @param scene Define the scene the texture belongs to
  9581. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9582. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9583. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9584. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9585. * @returns the RGB alpha texture
  9586. */
  9587. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9588. /**
  9589. * Creates a RGBA texture from some data.
  9590. * @param data Define the texture data
  9591. * @param width Define the width of the texture
  9592. * @param height Define the height of the texture
  9593. * @param scene Define the scene the texture belongs to
  9594. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9595. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9596. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9597. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9598. * @returns the RGBA texture
  9599. */
  9600. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9601. /**
  9602. * Creates a R texture from some data.
  9603. * @param data Define the texture data
  9604. * @param width Define the width of the texture
  9605. * @param height Define the height of the texture
  9606. * @param scene Define the scene the texture belongs to
  9607. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9608. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9609. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9610. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9611. * @returns the R texture
  9612. */
  9613. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9614. }
  9615. }
  9616. declare module "babylonjs/Animations/runtimeAnimation" {
  9617. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  9618. import { Animatable } from "babylonjs/Animations/animatable";
  9619. import { Scene } from "babylonjs/scene";
  9620. /**
  9621. * Defines a runtime animation
  9622. */
  9623. export class RuntimeAnimation {
  9624. private _events;
  9625. /**
  9626. * The current frame of the runtime animation
  9627. */
  9628. private _currentFrame;
  9629. /**
  9630. * The animation used by the runtime animation
  9631. */
  9632. private _animation;
  9633. /**
  9634. * The target of the runtime animation
  9635. */
  9636. private _target;
  9637. /**
  9638. * The initiating animatable
  9639. */
  9640. private _host;
  9641. /**
  9642. * The original value of the runtime animation
  9643. */
  9644. private _originalValue;
  9645. /**
  9646. * The original blend value of the runtime animation
  9647. */
  9648. private _originalBlendValue;
  9649. /**
  9650. * The offsets cache of the runtime animation
  9651. */
  9652. private _offsetsCache;
  9653. /**
  9654. * The high limits cache of the runtime animation
  9655. */
  9656. private _highLimitsCache;
  9657. /**
  9658. * Specifies if the runtime animation has been stopped
  9659. */
  9660. private _stopped;
  9661. /**
  9662. * The blending factor of the runtime animation
  9663. */
  9664. private _blendingFactor;
  9665. /**
  9666. * The BabylonJS scene
  9667. */
  9668. private _scene;
  9669. /**
  9670. * The current value of the runtime animation
  9671. */
  9672. private _currentValue;
  9673. /** @hidden */
  9674. _animationState: _IAnimationState;
  9675. /**
  9676. * The active target of the runtime animation
  9677. */
  9678. private _activeTargets;
  9679. private _currentActiveTarget;
  9680. private _directTarget;
  9681. /**
  9682. * The target path of the runtime animation
  9683. */
  9684. private _targetPath;
  9685. /**
  9686. * The weight of the runtime animation
  9687. */
  9688. private _weight;
  9689. /**
  9690. * The ratio offset of the runtime animation
  9691. */
  9692. private _ratioOffset;
  9693. /**
  9694. * The previous delay of the runtime animation
  9695. */
  9696. private _previousDelay;
  9697. /**
  9698. * The previous ratio of the runtime animation
  9699. */
  9700. private _previousRatio;
  9701. private _enableBlending;
  9702. private _keys;
  9703. private _minFrame;
  9704. private _maxFrame;
  9705. private _minValue;
  9706. private _maxValue;
  9707. private _targetIsArray;
  9708. /**
  9709. * Gets the current frame of the runtime animation
  9710. */
  9711. readonly currentFrame: number;
  9712. /**
  9713. * Gets the weight of the runtime animation
  9714. */
  9715. readonly weight: number;
  9716. /**
  9717. * Gets the current value of the runtime animation
  9718. */
  9719. readonly currentValue: any;
  9720. /**
  9721. * Gets the target path of the runtime animation
  9722. */
  9723. readonly targetPath: string;
  9724. /**
  9725. * Gets the actual target of the runtime animation
  9726. */
  9727. readonly target: any;
  9728. /** @hidden */
  9729. _onLoop: () => void;
  9730. /**
  9731. * Create a new RuntimeAnimation object
  9732. * @param target defines the target of the animation
  9733. * @param animation defines the source animation object
  9734. * @param scene defines the hosting scene
  9735. * @param host defines the initiating Animatable
  9736. */
  9737. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  9738. private _preparePath;
  9739. /**
  9740. * Gets the animation from the runtime animation
  9741. */
  9742. readonly animation: Animation;
  9743. /**
  9744. * Resets the runtime animation to the beginning
  9745. * @param restoreOriginal defines whether to restore the target property to the original value
  9746. */
  9747. reset(restoreOriginal?: boolean): void;
  9748. /**
  9749. * Specifies if the runtime animation is stopped
  9750. * @returns Boolean specifying if the runtime animation is stopped
  9751. */
  9752. isStopped(): boolean;
  9753. /**
  9754. * Disposes of the runtime animation
  9755. */
  9756. dispose(): void;
  9757. /**
  9758. * Apply the interpolated value to the target
  9759. * @param currentValue defines the value computed by the animation
  9760. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  9761. */
  9762. setValue(currentValue: any, weight: number): void;
  9763. private _getOriginalValues;
  9764. private _setValue;
  9765. /**
  9766. * Gets the loop pmode of the runtime animation
  9767. * @returns Loop Mode
  9768. */
  9769. private _getCorrectLoopMode;
  9770. /**
  9771. * Move the current animation to a given frame
  9772. * @param frame defines the frame to move to
  9773. */
  9774. goToFrame(frame: number): void;
  9775. /**
  9776. * @hidden Internal use only
  9777. */
  9778. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  9779. /**
  9780. * Execute the current animation
  9781. * @param delay defines the delay to add to the current frame
  9782. * @param from defines the lower bound of the animation range
  9783. * @param to defines the upper bound of the animation range
  9784. * @param loop defines if the current animation must loop
  9785. * @param speedRatio defines the current speed ratio
  9786. * @param weight defines the weight of the animation (default is -1 so no weight)
  9787. * @param onLoop optional callback called when animation loops
  9788. * @returns a boolean indicating if the animation is running
  9789. */
  9790. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  9791. }
  9792. }
  9793. declare module "babylonjs/Animations/animatable" {
  9794. import { Animation } from "babylonjs/Animations/animation";
  9795. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  9796. import { Nullable } from "babylonjs/types";
  9797. import { Observable } from "babylonjs/Misc/observable";
  9798. import { Scene } from "babylonjs/scene";
  9799. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  9800. import { Node } from "babylonjs/node";
  9801. /**
  9802. * Class used to store an actual running animation
  9803. */
  9804. export class Animatable {
  9805. /** defines the target object */
  9806. target: any;
  9807. /** defines the starting frame number (default is 0) */
  9808. fromFrame: number;
  9809. /** defines the ending frame number (default is 100) */
  9810. toFrame: number;
  9811. /** defines if the animation must loop (default is false) */
  9812. loopAnimation: boolean;
  9813. /** defines a callback to call when animation ends if it is not looping */
  9814. onAnimationEnd?: (() => void) | null | undefined;
  9815. /** defines a callback to call when animation loops */
  9816. onAnimationLoop?: (() => void) | null | undefined;
  9817. private _localDelayOffset;
  9818. private _pausedDelay;
  9819. private _runtimeAnimations;
  9820. private _paused;
  9821. private _scene;
  9822. private _speedRatio;
  9823. private _weight;
  9824. private _syncRoot;
  9825. /**
  9826. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  9827. * This will only apply for non looping animation (default is true)
  9828. */
  9829. disposeOnEnd: boolean;
  9830. /**
  9831. * Gets a boolean indicating if the animation has started
  9832. */
  9833. animationStarted: boolean;
  9834. /**
  9835. * Observer raised when the animation ends
  9836. */
  9837. onAnimationEndObservable: Observable<Animatable>;
  9838. /**
  9839. * Observer raised when the animation loops
  9840. */
  9841. onAnimationLoopObservable: Observable<Animatable>;
  9842. /**
  9843. * Gets the root Animatable used to synchronize and normalize animations
  9844. */
  9845. readonly syncRoot: Nullable<Animatable>;
  9846. /**
  9847. * Gets the current frame of the first RuntimeAnimation
  9848. * Used to synchronize Animatables
  9849. */
  9850. readonly masterFrame: number;
  9851. /**
  9852. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  9853. */
  9854. weight: number;
  9855. /**
  9856. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  9857. */
  9858. speedRatio: number;
  9859. /**
  9860. * Creates a new Animatable
  9861. * @param scene defines the hosting scene
  9862. * @param target defines the target object
  9863. * @param fromFrame defines the starting frame number (default is 0)
  9864. * @param toFrame defines the ending frame number (default is 100)
  9865. * @param loopAnimation defines if the animation must loop (default is false)
  9866. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  9867. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  9868. * @param animations defines a group of animation to add to the new Animatable
  9869. * @param onAnimationLoop defines a callback to call when animation loops
  9870. */
  9871. constructor(scene: Scene,
  9872. /** defines the target object */
  9873. target: any,
  9874. /** defines the starting frame number (default is 0) */
  9875. fromFrame?: number,
  9876. /** defines the ending frame number (default is 100) */
  9877. toFrame?: number,
  9878. /** defines if the animation must loop (default is false) */
  9879. loopAnimation?: boolean, speedRatio?: number,
  9880. /** defines a callback to call when animation ends if it is not looping */
  9881. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  9882. /** defines a callback to call when animation loops */
  9883. onAnimationLoop?: (() => void) | null | undefined);
  9884. /**
  9885. * Synchronize and normalize current Animatable with a source Animatable
  9886. * This is useful when using animation weights and when animations are not of the same length
  9887. * @param root defines the root Animatable to synchronize with
  9888. * @returns the current Animatable
  9889. */
  9890. syncWith(root: Animatable): Animatable;
  9891. /**
  9892. * Gets the list of runtime animations
  9893. * @returns an array of RuntimeAnimation
  9894. */
  9895. getAnimations(): RuntimeAnimation[];
  9896. /**
  9897. * Adds more animations to the current animatable
  9898. * @param target defines the target of the animations
  9899. * @param animations defines the new animations to add
  9900. */
  9901. appendAnimations(target: any, animations: Animation[]): void;
  9902. /**
  9903. * Gets the source animation for a specific property
  9904. * @param property defines the propertyu to look for
  9905. * @returns null or the source animation for the given property
  9906. */
  9907. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  9908. /**
  9909. * Gets the runtime animation for a specific property
  9910. * @param property defines the propertyu to look for
  9911. * @returns null or the runtime animation for the given property
  9912. */
  9913. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  9914. /**
  9915. * Resets the animatable to its original state
  9916. */
  9917. reset(): void;
  9918. /**
  9919. * Allows the animatable to blend with current running animations
  9920. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9921. * @param blendingSpeed defines the blending speed to use
  9922. */
  9923. enableBlending(blendingSpeed: number): void;
  9924. /**
  9925. * Disable animation blending
  9926. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9927. */
  9928. disableBlending(): void;
  9929. /**
  9930. * Jump directly to a given frame
  9931. * @param frame defines the frame to jump to
  9932. */
  9933. goToFrame(frame: number): void;
  9934. /**
  9935. * Pause the animation
  9936. */
  9937. pause(): void;
  9938. /**
  9939. * Restart the animation
  9940. */
  9941. restart(): void;
  9942. private _raiseOnAnimationEnd;
  9943. /**
  9944. * Stop and delete the current animation
  9945. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  9946. * @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)
  9947. */
  9948. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  9949. /**
  9950. * Wait asynchronously for the animation to end
  9951. * @returns a promise which will be fullfilled when the animation ends
  9952. */
  9953. waitAsync(): Promise<Animatable>;
  9954. /** @hidden */
  9955. _animate(delay: number): boolean;
  9956. }
  9957. module "babylonjs/scene" {
  9958. interface Scene {
  9959. /** @hidden */
  9960. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  9961. /** @hidden */
  9962. _processLateAnimationBindingsForMatrices(holder: {
  9963. totalWeight: number;
  9964. animations: RuntimeAnimation[];
  9965. originalValue: Matrix;
  9966. }): any;
  9967. /** @hidden */
  9968. _processLateAnimationBindingsForQuaternions(holder: {
  9969. totalWeight: number;
  9970. animations: RuntimeAnimation[];
  9971. originalValue: Quaternion;
  9972. }, refQuaternion: Quaternion): Quaternion;
  9973. /** @hidden */
  9974. _processLateAnimationBindings(): void;
  9975. /**
  9976. * Will start the animation sequence of a given target
  9977. * @param target defines the target
  9978. * @param from defines from which frame should animation start
  9979. * @param to defines until which frame should animation run.
  9980. * @param weight defines the weight to apply to the animation (1.0 by default)
  9981. * @param loop defines if the animation loops
  9982. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9983. * @param onAnimationEnd defines the function to be executed when the animation ends
  9984. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9985. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  9986. * @param onAnimationLoop defines the callback to call when an animation loops
  9987. * @returns the animatable object created for this animation
  9988. */
  9989. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  9990. /**
  9991. * Will start the animation sequence of a given target
  9992. * @param target defines the target
  9993. * @param from defines from which frame should animation start
  9994. * @param to defines until which frame should animation run.
  9995. * @param loop defines if the animation loops
  9996. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9997. * @param onAnimationEnd defines the function to be executed when the animation ends
  9998. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9999. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  10000. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  10001. * @param onAnimationLoop defines the callback to call when an animation loops
  10002. * @returns the animatable object created for this animation
  10003. */
  10004. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  10005. /**
  10006. * Will start the animation sequence of a given target and its hierarchy
  10007. * @param target defines the target
  10008. * @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.
  10009. * @param from defines from which frame should animation start
  10010. * @param to defines until which frame should animation run.
  10011. * @param loop defines if the animation loops
  10012. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  10013. * @param onAnimationEnd defines the function to be executed when the animation ends
  10014. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  10015. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  10016. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  10017. * @param onAnimationLoop defines the callback to call when an animation loops
  10018. * @returns the list of created animatables
  10019. */
  10020. 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[];
  10021. /**
  10022. * Begin a new animation on a given node
  10023. * @param target defines the target where the animation will take place
  10024. * @param animations defines the list of animations to start
  10025. * @param from defines the initial value
  10026. * @param to defines the final value
  10027. * @param loop defines if you want animation to loop (off by default)
  10028. * @param speedRatio defines the speed ratio to apply to all animations
  10029. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  10030. * @param onAnimationLoop defines the callback to call when an animation loops
  10031. * @returns the list of created animatables
  10032. */
  10033. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  10034. /**
  10035. * Begin a new animation on a given node and its hierarchy
  10036. * @param target defines the root node where the animation will take place
  10037. * @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.
  10038. * @param animations defines the list of animations to start
  10039. * @param from defines the initial value
  10040. * @param to defines the final value
  10041. * @param loop defines if you want animation to loop (off by default)
  10042. * @param speedRatio defines the speed ratio to apply to all animations
  10043. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  10044. * @param onAnimationLoop defines the callback to call when an animation loops
  10045. * @returns the list of animatables created for all nodes
  10046. */
  10047. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  10048. /**
  10049. * Gets the animatable associated with a specific target
  10050. * @param target defines the target of the animatable
  10051. * @returns the required animatable if found
  10052. */
  10053. getAnimatableByTarget(target: any): Nullable<Animatable>;
  10054. /**
  10055. * Gets all animatables associated with a given target
  10056. * @param target defines the target to look animatables for
  10057. * @returns an array of Animatables
  10058. */
  10059. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  10060. /**
  10061. * Stops and removes all animations that have been applied to the scene
  10062. */
  10063. stopAllAnimations(): void;
  10064. }
  10065. }
  10066. module "babylonjs/Bones/bone" {
  10067. interface Bone {
  10068. /**
  10069. * Copy an animation range from another bone
  10070. * @param source defines the source bone
  10071. * @param rangeName defines the range name to copy
  10072. * @param frameOffset defines the frame offset
  10073. * @param rescaleAsRequired defines if rescaling must be applied if required
  10074. * @param skelDimensionsRatio defines the scaling ratio
  10075. * @returns true if operation was successful
  10076. */
  10077. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  10078. }
  10079. }
  10080. }
  10081. declare module "babylonjs/Bones/skeleton" {
  10082. import { Bone } from "babylonjs/Bones/bone";
  10083. import { IAnimatable } from "babylonjs/Misc/tools";
  10084. import { Observable } from "babylonjs/Misc/observable";
  10085. import { Vector3, Matrix } from "babylonjs/Maths/math";
  10086. import { Scene } from "babylonjs/scene";
  10087. import { Nullable } from "babylonjs/types";
  10088. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10089. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  10090. import { Animatable } from "babylonjs/Animations/animatable";
  10091. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  10092. import { Animation } from "babylonjs/Animations/animation";
  10093. import { AnimationRange } from "babylonjs/Animations/animationRange";
  10094. import { IInspectable } from "babylonjs/Misc/iInspectable";
  10095. /**
  10096. * Class used to handle skinning animations
  10097. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  10098. */
  10099. export class Skeleton implements IAnimatable {
  10100. /** defines the skeleton name */
  10101. name: string;
  10102. /** defines the skeleton Id */
  10103. id: string;
  10104. /**
  10105. * Defines the list of child bones
  10106. */
  10107. bones: Bone[];
  10108. /**
  10109. * Defines an estimate of the dimension of the skeleton at rest
  10110. */
  10111. dimensionsAtRest: Vector3;
  10112. /**
  10113. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  10114. */
  10115. needInitialSkinMatrix: boolean;
  10116. /**
  10117. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  10118. */
  10119. overrideMesh: Nullable<AbstractMesh>;
  10120. /**
  10121. * Gets the list of animations attached to this skeleton
  10122. */
  10123. animations: Array<Animation>;
  10124. private _scene;
  10125. private _isDirty;
  10126. private _transformMatrices;
  10127. private _transformMatrixTexture;
  10128. private _meshesWithPoseMatrix;
  10129. private _animatables;
  10130. private _identity;
  10131. private _synchronizedWithMesh;
  10132. private _ranges;
  10133. private _lastAbsoluteTransformsUpdateId;
  10134. private _canUseTextureForBones;
  10135. private _uniqueId;
  10136. /** @hidden */
  10137. _numBonesWithLinkedTransformNode: number;
  10138. /** @hidden */
  10139. _hasWaitingData: Nullable<boolean>;
  10140. /**
  10141. * Specifies if the skeleton should be serialized
  10142. */
  10143. doNotSerialize: boolean;
  10144. private _useTextureToStoreBoneMatrices;
  10145. /**
  10146. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  10147. * Please note that this option is not available if the hardware does not support it
  10148. */
  10149. useTextureToStoreBoneMatrices: boolean;
  10150. private _animationPropertiesOverride;
  10151. /**
  10152. * Gets or sets the animation properties override
  10153. */
  10154. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10155. /**
  10156. * List of inspectable custom properties (used by the Inspector)
  10157. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  10158. */
  10159. inspectableCustomProperties: IInspectable[];
  10160. /**
  10161. * An observable triggered before computing the skeleton's matrices
  10162. */
  10163. onBeforeComputeObservable: Observable<Skeleton>;
  10164. /**
  10165. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  10166. */
  10167. readonly isUsingTextureForMatrices: boolean;
  10168. /**
  10169. * Gets the unique ID of this skeleton
  10170. */
  10171. readonly uniqueId: number;
  10172. /**
  10173. * Creates a new skeleton
  10174. * @param name defines the skeleton name
  10175. * @param id defines the skeleton Id
  10176. * @param scene defines the hosting scene
  10177. */
  10178. constructor(
  10179. /** defines the skeleton name */
  10180. name: string,
  10181. /** defines the skeleton Id */
  10182. id: string, scene: Scene);
  10183. /**
  10184. * Gets the current object class name.
  10185. * @return the class name
  10186. */
  10187. getClassName(): string;
  10188. /**
  10189. * Returns an array containing the root bones
  10190. * @returns an array containing the root bones
  10191. */
  10192. getChildren(): Array<Bone>;
  10193. /**
  10194. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  10195. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  10196. * @returns a Float32Array containing matrices data
  10197. */
  10198. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  10199. /**
  10200. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  10201. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  10202. * @returns a raw texture containing the data
  10203. */
  10204. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  10205. /**
  10206. * Gets the current hosting scene
  10207. * @returns a scene object
  10208. */
  10209. getScene(): Scene;
  10210. /**
  10211. * Gets a string representing the current skeleton data
  10212. * @param fullDetails defines a boolean indicating if we want a verbose version
  10213. * @returns a string representing the current skeleton data
  10214. */
  10215. toString(fullDetails?: boolean): string;
  10216. /**
  10217. * Get bone's index searching by name
  10218. * @param name defines bone's name to search for
  10219. * @return the indice of the bone. Returns -1 if not found
  10220. */
  10221. getBoneIndexByName(name: string): number;
  10222. /**
  10223. * Creater a new animation range
  10224. * @param name defines the name of the range
  10225. * @param from defines the start key
  10226. * @param to defines the end key
  10227. */
  10228. createAnimationRange(name: string, from: number, to: number): void;
  10229. /**
  10230. * Delete a specific animation range
  10231. * @param name defines the name of the range
  10232. * @param deleteFrames defines if frames must be removed as well
  10233. */
  10234. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  10235. /**
  10236. * Gets a specific animation range
  10237. * @param name defines the name of the range to look for
  10238. * @returns the requested animation range or null if not found
  10239. */
  10240. getAnimationRange(name: string): Nullable<AnimationRange>;
  10241. /**
  10242. * Gets the list of all animation ranges defined on this skeleton
  10243. * @returns an array
  10244. */
  10245. getAnimationRanges(): Nullable<AnimationRange>[];
  10246. /**
  10247. * Copy animation range from a source skeleton.
  10248. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  10249. * @param source defines the source skeleton
  10250. * @param name defines the name of the range to copy
  10251. * @param rescaleAsRequired defines if rescaling must be applied if required
  10252. * @returns true if operation was successful
  10253. */
  10254. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  10255. /**
  10256. * Forces the skeleton to go to rest pose
  10257. */
  10258. returnToRest(): void;
  10259. private _getHighestAnimationFrame;
  10260. /**
  10261. * Begin a specific animation range
  10262. * @param name defines the name of the range to start
  10263. * @param loop defines if looping must be turned on (false by default)
  10264. * @param speedRatio defines the speed ratio to apply (1 by default)
  10265. * @param onAnimationEnd defines a callback which will be called when animation will end
  10266. * @returns a new animatable
  10267. */
  10268. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  10269. /** @hidden */
  10270. _markAsDirty(): void;
  10271. /** @hidden */
  10272. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10273. /** @hidden */
  10274. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10275. private _computeTransformMatrices;
  10276. /**
  10277. * Build all resources required to render a skeleton
  10278. */
  10279. prepare(): void;
  10280. /**
  10281. * Gets the list of animatables currently running for this skeleton
  10282. * @returns an array of animatables
  10283. */
  10284. getAnimatables(): IAnimatable[];
  10285. /**
  10286. * Clone the current skeleton
  10287. * @param name defines the name of the new skeleton
  10288. * @param id defines the id of the new skeleton
  10289. * @returns the new skeleton
  10290. */
  10291. clone(name: string, id: string): Skeleton;
  10292. /**
  10293. * Enable animation blending for this skeleton
  10294. * @param blendingSpeed defines the blending speed to apply
  10295. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  10296. */
  10297. enableBlending(blendingSpeed?: number): void;
  10298. /**
  10299. * Releases all resources associated with the current skeleton
  10300. */
  10301. dispose(): void;
  10302. /**
  10303. * Serialize the skeleton in a JSON object
  10304. * @returns a JSON object
  10305. */
  10306. serialize(): any;
  10307. /**
  10308. * Creates a new skeleton from serialized data
  10309. * @param parsedSkeleton defines the serialized data
  10310. * @param scene defines the hosting scene
  10311. * @returns a new skeleton
  10312. */
  10313. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  10314. /**
  10315. * Compute all node absolute transforms
  10316. * @param forceUpdate defines if computation must be done even if cache is up to date
  10317. */
  10318. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  10319. /**
  10320. * Gets the root pose matrix
  10321. * @returns a matrix
  10322. */
  10323. getPoseMatrix(): Nullable<Matrix>;
  10324. /**
  10325. * Sorts bones per internal index
  10326. */
  10327. sortBones(): void;
  10328. private _sortBones;
  10329. }
  10330. }
  10331. declare module "babylonjs/Morph/morphTarget" {
  10332. import { IAnimatable } from "babylonjs/Misc/tools";
  10333. import { Observable } from "babylonjs/Misc/observable";
  10334. import { Nullable, FloatArray } from "babylonjs/types";
  10335. import { Scene } from "babylonjs/scene";
  10336. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10337. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  10338. /**
  10339. * Defines a target to use with MorphTargetManager
  10340. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10341. */
  10342. export class MorphTarget implements IAnimatable {
  10343. /** defines the name of the target */
  10344. name: string;
  10345. /**
  10346. * Gets or sets the list of animations
  10347. */
  10348. animations: import("babylonjs/Animations/animation").Animation[];
  10349. private _scene;
  10350. private _positions;
  10351. private _normals;
  10352. private _tangents;
  10353. private _uvs;
  10354. private _influence;
  10355. /**
  10356. * Observable raised when the influence changes
  10357. */
  10358. onInfluenceChanged: Observable<boolean>;
  10359. /** @hidden */
  10360. _onDataLayoutChanged: Observable<void>;
  10361. /**
  10362. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  10363. */
  10364. influence: number;
  10365. /**
  10366. * Gets or sets the id of the morph Target
  10367. */
  10368. id: string;
  10369. private _animationPropertiesOverride;
  10370. /**
  10371. * Gets or sets the animation properties override
  10372. */
  10373. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10374. /**
  10375. * Creates a new MorphTarget
  10376. * @param name defines the name of the target
  10377. * @param influence defines the influence to use
  10378. * @param scene defines the scene the morphtarget belongs to
  10379. */
  10380. constructor(
  10381. /** defines the name of the target */
  10382. name: string, influence?: number, scene?: Nullable<Scene>);
  10383. /**
  10384. * Gets a boolean defining if the target contains position data
  10385. */
  10386. readonly hasPositions: boolean;
  10387. /**
  10388. * Gets a boolean defining if the target contains normal data
  10389. */
  10390. readonly hasNormals: boolean;
  10391. /**
  10392. * Gets a boolean defining if the target contains tangent data
  10393. */
  10394. readonly hasTangents: boolean;
  10395. /**
  10396. * Gets a boolean defining if the target contains texture coordinates data
  10397. */
  10398. readonly hasUVs: boolean;
  10399. /**
  10400. * Affects position data to this target
  10401. * @param data defines the position data to use
  10402. */
  10403. setPositions(data: Nullable<FloatArray>): void;
  10404. /**
  10405. * Gets the position data stored in this target
  10406. * @returns a FloatArray containing the position data (or null if not present)
  10407. */
  10408. getPositions(): Nullable<FloatArray>;
  10409. /**
  10410. * Affects normal data to this target
  10411. * @param data defines the normal data to use
  10412. */
  10413. setNormals(data: Nullable<FloatArray>): void;
  10414. /**
  10415. * Gets the normal data stored in this target
  10416. * @returns a FloatArray containing the normal data (or null if not present)
  10417. */
  10418. getNormals(): Nullable<FloatArray>;
  10419. /**
  10420. * Affects tangent data to this target
  10421. * @param data defines the tangent data to use
  10422. */
  10423. setTangents(data: Nullable<FloatArray>): void;
  10424. /**
  10425. * Gets the tangent data stored in this target
  10426. * @returns a FloatArray containing the tangent data (or null if not present)
  10427. */
  10428. getTangents(): Nullable<FloatArray>;
  10429. /**
  10430. * Affects texture coordinates data to this target
  10431. * @param data defines the texture coordinates data to use
  10432. */
  10433. setUVs(data: Nullable<FloatArray>): void;
  10434. /**
  10435. * Gets the texture coordinates data stored in this target
  10436. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  10437. */
  10438. getUVs(): Nullable<FloatArray>;
  10439. /**
  10440. * Serializes the current target into a Serialization object
  10441. * @returns the serialized object
  10442. */
  10443. serialize(): any;
  10444. /**
  10445. * Returns the string "MorphTarget"
  10446. * @returns "MorphTarget"
  10447. */
  10448. getClassName(): string;
  10449. /**
  10450. * Creates a new target from serialized data
  10451. * @param serializationObject defines the serialized data to use
  10452. * @returns a new MorphTarget
  10453. */
  10454. static Parse(serializationObject: any): MorphTarget;
  10455. /**
  10456. * Creates a MorphTarget from mesh data
  10457. * @param mesh defines the source mesh
  10458. * @param name defines the name to use for the new target
  10459. * @param influence defines the influence to attach to the target
  10460. * @returns a new MorphTarget
  10461. */
  10462. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  10463. }
  10464. }
  10465. declare module "babylonjs/Morph/morphTargetManager" {
  10466. import { Nullable } from "babylonjs/types";
  10467. import { Scene } from "babylonjs/scene";
  10468. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  10469. /**
  10470. * This class is used to deform meshes using morphing between different targets
  10471. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10472. */
  10473. export class MorphTargetManager {
  10474. private _targets;
  10475. private _targetInfluenceChangedObservers;
  10476. private _targetDataLayoutChangedObservers;
  10477. private _activeTargets;
  10478. private _scene;
  10479. private _influences;
  10480. private _supportsNormals;
  10481. private _supportsTangents;
  10482. private _supportsUVs;
  10483. private _vertexCount;
  10484. private _uniqueId;
  10485. private _tempInfluences;
  10486. /**
  10487. * Gets or sets a boolean indicating if normals must be morphed
  10488. */
  10489. enableNormalMorphing: boolean;
  10490. /**
  10491. * Gets or sets a boolean indicating if tangents must be morphed
  10492. */
  10493. enableTangentMorphing: boolean;
  10494. /**
  10495. * Gets or sets a boolean indicating if UV must be morphed
  10496. */
  10497. enableUVMorphing: boolean;
  10498. /**
  10499. * Creates a new MorphTargetManager
  10500. * @param scene defines the current scene
  10501. */
  10502. constructor(scene?: Nullable<Scene>);
  10503. /**
  10504. * Gets the unique ID of this manager
  10505. */
  10506. readonly uniqueId: number;
  10507. /**
  10508. * Gets the number of vertices handled by this manager
  10509. */
  10510. readonly vertexCount: number;
  10511. /**
  10512. * Gets a boolean indicating if this manager supports morphing of normals
  10513. */
  10514. readonly supportsNormals: boolean;
  10515. /**
  10516. * Gets a boolean indicating if this manager supports morphing of tangents
  10517. */
  10518. readonly supportsTangents: boolean;
  10519. /**
  10520. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  10521. */
  10522. readonly supportsUVs: boolean;
  10523. /**
  10524. * Gets the number of targets stored in this manager
  10525. */
  10526. readonly numTargets: number;
  10527. /**
  10528. * Gets the number of influencers (ie. the number of targets with influences > 0)
  10529. */
  10530. readonly numInfluencers: number;
  10531. /**
  10532. * Gets the list of influences (one per target)
  10533. */
  10534. readonly influences: Float32Array;
  10535. /**
  10536. * Gets the active target at specified index. An active target is a target with an influence > 0
  10537. * @param index defines the index to check
  10538. * @returns the requested target
  10539. */
  10540. getActiveTarget(index: number): MorphTarget;
  10541. /**
  10542. * Gets the target at specified index
  10543. * @param index defines the index to check
  10544. * @returns the requested target
  10545. */
  10546. getTarget(index: number): MorphTarget;
  10547. /**
  10548. * Add a new target to this manager
  10549. * @param target defines the target to add
  10550. */
  10551. addTarget(target: MorphTarget): void;
  10552. /**
  10553. * Removes a target from the manager
  10554. * @param target defines the target to remove
  10555. */
  10556. removeTarget(target: MorphTarget): void;
  10557. /**
  10558. * Serializes the current manager into a Serialization object
  10559. * @returns the serialized object
  10560. */
  10561. serialize(): any;
  10562. private _syncActiveTargets;
  10563. /**
  10564. * Syncrhonize the targets with all the meshes using this morph target manager
  10565. */
  10566. synchronize(): void;
  10567. /**
  10568. * Creates a new MorphTargetManager from serialized data
  10569. * @param serializationObject defines the serialized data
  10570. * @param scene defines the hosting scene
  10571. * @returns the new MorphTargetManager
  10572. */
  10573. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  10574. }
  10575. }
  10576. declare module "babylonjs/sceneComponent" {
  10577. import { Scene } from "babylonjs/scene";
  10578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10579. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10580. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10581. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10582. import { Nullable } from "babylonjs/types";
  10583. import { Camera } from "babylonjs/Cameras/camera";
  10584. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10585. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10586. import { AbstractScene } from "babylonjs/abstractScene";
  10587. /**
  10588. * Groups all the scene component constants in one place to ease maintenance.
  10589. * @hidden
  10590. */
  10591. export class SceneComponentConstants {
  10592. static readonly NAME_EFFECTLAYER: string;
  10593. static readonly NAME_LAYER: string;
  10594. static readonly NAME_LENSFLARESYSTEM: string;
  10595. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10596. static readonly NAME_PARTICLESYSTEM: string;
  10597. static readonly NAME_GAMEPAD: string;
  10598. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10599. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10600. static readonly NAME_DEPTHRENDERER: string;
  10601. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10602. static readonly NAME_SPRITE: string;
  10603. static readonly NAME_OUTLINERENDERER: string;
  10604. static readonly NAME_PROCEDURALTEXTURE: string;
  10605. static readonly NAME_SHADOWGENERATOR: string;
  10606. static readonly NAME_OCTREE: string;
  10607. static readonly NAME_PHYSICSENGINE: string;
  10608. static readonly NAME_AUDIO: string;
  10609. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10610. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10611. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10612. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10613. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10614. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10615. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10616. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10617. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10618. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10619. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10620. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10621. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10622. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10623. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10624. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10625. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10626. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10627. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10628. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10629. static readonly STEP_AFTERRENDER_AUDIO: number;
  10630. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10631. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10632. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10633. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10634. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10635. static readonly STEP_POINTERMOVE_SPRITE: number;
  10636. static readonly STEP_POINTERDOWN_SPRITE: number;
  10637. static readonly STEP_POINTERUP_SPRITE: number;
  10638. }
  10639. /**
  10640. * This represents a scene component.
  10641. *
  10642. * This is used to decouple the dependency the scene is having on the different workloads like
  10643. * layers, post processes...
  10644. */
  10645. export interface ISceneComponent {
  10646. /**
  10647. * The name of the component. Each component must have a unique name.
  10648. */
  10649. name: string;
  10650. /**
  10651. * The scene the component belongs to.
  10652. */
  10653. scene: Scene;
  10654. /**
  10655. * Register the component to one instance of a scene.
  10656. */
  10657. register(): void;
  10658. /**
  10659. * Rebuilds the elements related to this component in case of
  10660. * context lost for instance.
  10661. */
  10662. rebuild(): void;
  10663. /**
  10664. * Disposes the component and the associated ressources.
  10665. */
  10666. dispose(): void;
  10667. }
  10668. /**
  10669. * This represents a SERIALIZABLE scene component.
  10670. *
  10671. * This extends Scene Component to add Serialization methods on top.
  10672. */
  10673. export interface ISceneSerializableComponent extends ISceneComponent {
  10674. /**
  10675. * Adds all the elements from the container to the scene
  10676. * @param container the container holding the elements
  10677. */
  10678. addFromContainer(container: AbstractScene): void;
  10679. /**
  10680. * Removes all the elements in the container from the scene
  10681. * @param container contains the elements to remove
  10682. * @param dispose if the removed element should be disposed (default: false)
  10683. */
  10684. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10685. /**
  10686. * Serializes the component data to the specified json object
  10687. * @param serializationObject The object to serialize to
  10688. */
  10689. serialize(serializationObject: any): void;
  10690. }
  10691. /**
  10692. * Strong typing of a Mesh related stage step action
  10693. */
  10694. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10695. /**
  10696. * Strong typing of a Evaluate Sub Mesh related stage step action
  10697. */
  10698. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10699. /**
  10700. * Strong typing of a Active Mesh related stage step action
  10701. */
  10702. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10703. /**
  10704. * Strong typing of a Camera related stage step action
  10705. */
  10706. export type CameraStageAction = (camera: Camera) => void;
  10707. /**
  10708. * Strong typing of a Camera Frame buffer related stage step action
  10709. */
  10710. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10711. /**
  10712. * Strong typing of a Render Target related stage step action
  10713. */
  10714. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10715. /**
  10716. * Strong typing of a RenderingGroup related stage step action
  10717. */
  10718. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10719. /**
  10720. * Strong typing of a Mesh Render related stage step action
  10721. */
  10722. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10723. /**
  10724. * Strong typing of a simple stage step action
  10725. */
  10726. export type SimpleStageAction = () => void;
  10727. /**
  10728. * Strong typing of a render target action.
  10729. */
  10730. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10731. /**
  10732. * Strong typing of a pointer move action.
  10733. */
  10734. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  10735. /**
  10736. * Strong typing of a pointer up/down action.
  10737. */
  10738. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10739. /**
  10740. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  10741. * @hidden
  10742. */
  10743. export class Stage<T extends Function> extends Array<{
  10744. index: number;
  10745. component: ISceneComponent;
  10746. action: T;
  10747. }> {
  10748. /**
  10749. * Hide ctor from the rest of the world.
  10750. * @param items The items to add.
  10751. */
  10752. private constructor();
  10753. /**
  10754. * Creates a new Stage.
  10755. * @returns A new instance of a Stage
  10756. */
  10757. static Create<T extends Function>(): Stage<T>;
  10758. /**
  10759. * Registers a step in an ordered way in the targeted stage.
  10760. * @param index Defines the position to register the step in
  10761. * @param component Defines the component attached to the step
  10762. * @param action Defines the action to launch during the step
  10763. */
  10764. registerStep(index: number, component: ISceneComponent, action: T): void;
  10765. /**
  10766. * Clears all the steps from the stage.
  10767. */
  10768. clear(): void;
  10769. }
  10770. }
  10771. declare module "babylonjs/Meshes/meshLODLevel" {
  10772. import { Mesh } from "babylonjs/Meshes/mesh";
  10773. import { Nullable } from "babylonjs/types";
  10774. /**
  10775. * Class used to represent a specific level of detail of a mesh
  10776. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  10777. */
  10778. export class MeshLODLevel {
  10779. /** Defines the distance where this level should star being displayed */
  10780. distance: number;
  10781. /** Defines the mesh to use to render this level */
  10782. mesh: Nullable<Mesh>;
  10783. /**
  10784. * Creates a new LOD level
  10785. * @param distance defines the distance where this level should star being displayed
  10786. * @param mesh defines the mesh to use to render this level
  10787. */
  10788. constructor(
  10789. /** Defines the distance where this level should star being displayed */
  10790. distance: number,
  10791. /** Defines the mesh to use to render this level */
  10792. mesh: Nullable<Mesh>);
  10793. }
  10794. }
  10795. declare module "babylonjs/Lights/shadowLight" {
  10796. import { Camera } from "babylonjs/Cameras/camera";
  10797. import { Scene } from "babylonjs/scene";
  10798. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  10799. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10800. import { Light } from "babylonjs/Lights/light";
  10801. /**
  10802. * Interface describing all the common properties and methods a shadow light needs to implement.
  10803. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  10804. * as well as binding the different shadow properties to the effects.
  10805. */
  10806. export interface IShadowLight extends Light {
  10807. /**
  10808. * The light id in the scene (used in scene.findLighById for instance)
  10809. */
  10810. id: string;
  10811. /**
  10812. * The position the shdow will be casted from.
  10813. */
  10814. position: Vector3;
  10815. /**
  10816. * In 2d mode (needCube being false), the direction used to cast the shadow.
  10817. */
  10818. direction: Vector3;
  10819. /**
  10820. * The transformed position. Position of the light in world space taking parenting in account.
  10821. */
  10822. transformedPosition: Vector3;
  10823. /**
  10824. * The transformed direction. Direction of the light in world space taking parenting in account.
  10825. */
  10826. transformedDirection: Vector3;
  10827. /**
  10828. * The friendly name of the light in the scene.
  10829. */
  10830. name: string;
  10831. /**
  10832. * Defines the shadow projection clipping minimum z value.
  10833. */
  10834. shadowMinZ: number;
  10835. /**
  10836. * Defines the shadow projection clipping maximum z value.
  10837. */
  10838. shadowMaxZ: number;
  10839. /**
  10840. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10841. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10842. */
  10843. computeTransformedInformation(): boolean;
  10844. /**
  10845. * Gets the scene the light belongs to.
  10846. * @returns The scene
  10847. */
  10848. getScene(): Scene;
  10849. /**
  10850. * Callback defining a custom Projection Matrix Builder.
  10851. * This can be used to override the default projection matrix computation.
  10852. */
  10853. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10854. /**
  10855. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10856. * @param matrix The materix to updated with the projection information
  10857. * @param viewMatrix The transform matrix of the light
  10858. * @param renderList The list of mesh to render in the map
  10859. * @returns The current light
  10860. */
  10861. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10862. /**
  10863. * Gets the current depth scale used in ESM.
  10864. * @returns The scale
  10865. */
  10866. getDepthScale(): number;
  10867. /**
  10868. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10869. * @returns true if a cube texture needs to be use
  10870. */
  10871. needCube(): boolean;
  10872. /**
  10873. * Detects if the projection matrix requires to be recomputed this frame.
  10874. * @returns true if it requires to be recomputed otherwise, false.
  10875. */
  10876. needProjectionMatrixCompute(): boolean;
  10877. /**
  10878. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10879. */
  10880. forceProjectionMatrixCompute(): void;
  10881. /**
  10882. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10883. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10884. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10885. */
  10886. getShadowDirection(faceIndex?: number): Vector3;
  10887. /**
  10888. * Gets the minZ used for shadow according to both the scene and the light.
  10889. * @param activeCamera The camera we are returning the min for
  10890. * @returns the depth min z
  10891. */
  10892. getDepthMinZ(activeCamera: Camera): number;
  10893. /**
  10894. * Gets the maxZ used for shadow according to both the scene and the light.
  10895. * @param activeCamera The camera we are returning the max for
  10896. * @returns the depth max z
  10897. */
  10898. getDepthMaxZ(activeCamera: Camera): number;
  10899. }
  10900. /**
  10901. * Base implementation IShadowLight
  10902. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  10903. */
  10904. export abstract class ShadowLight extends Light implements IShadowLight {
  10905. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10906. protected _position: Vector3;
  10907. protected _setPosition(value: Vector3): void;
  10908. /**
  10909. * Sets the position the shadow will be casted from. Also use as the light position for both
  10910. * point and spot lights.
  10911. */
  10912. /**
  10913. * Sets the position the shadow will be casted from. Also use as the light position for both
  10914. * point and spot lights.
  10915. */
  10916. position: Vector3;
  10917. protected _direction: Vector3;
  10918. protected _setDirection(value: Vector3): void;
  10919. /**
  10920. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  10921. * Also use as the light direction on spot and directional lights.
  10922. */
  10923. /**
  10924. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  10925. * Also use as the light direction on spot and directional lights.
  10926. */
  10927. direction: Vector3;
  10928. private _shadowMinZ;
  10929. /**
  10930. * Gets the shadow projection clipping minimum z value.
  10931. */
  10932. /**
  10933. * Sets the shadow projection clipping minimum z value.
  10934. */
  10935. shadowMinZ: number;
  10936. private _shadowMaxZ;
  10937. /**
  10938. * Sets the shadow projection clipping maximum z value.
  10939. */
  10940. /**
  10941. * Gets the shadow projection clipping maximum z value.
  10942. */
  10943. shadowMaxZ: number;
  10944. /**
  10945. * Callback defining a custom Projection Matrix Builder.
  10946. * This can be used to override the default projection matrix computation.
  10947. */
  10948. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10949. /**
  10950. * The transformed position. Position of the light in world space taking parenting in account.
  10951. */
  10952. transformedPosition: Vector3;
  10953. /**
  10954. * The transformed direction. Direction of the light in world space taking parenting in account.
  10955. */
  10956. transformedDirection: Vector3;
  10957. private _needProjectionMatrixCompute;
  10958. /**
  10959. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10960. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10961. */
  10962. computeTransformedInformation(): boolean;
  10963. /**
  10964. * Return the depth scale used for the shadow map.
  10965. * @returns the depth scale.
  10966. */
  10967. getDepthScale(): number;
  10968. /**
  10969. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10970. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10971. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10972. */
  10973. getShadowDirection(faceIndex?: number): Vector3;
  10974. /**
  10975. * Returns the ShadowLight absolute position in the World.
  10976. * @returns the position vector in world space
  10977. */
  10978. getAbsolutePosition(): Vector3;
  10979. /**
  10980. * Sets the ShadowLight direction toward the passed target.
  10981. * @param target The point to target in local space
  10982. * @returns the updated ShadowLight direction
  10983. */
  10984. setDirectionToTarget(target: Vector3): Vector3;
  10985. /**
  10986. * Returns the light rotation in euler definition.
  10987. * @returns the x y z rotation in local space.
  10988. */
  10989. getRotation(): Vector3;
  10990. /**
  10991. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10992. * @returns true if a cube texture needs to be use
  10993. */
  10994. needCube(): boolean;
  10995. /**
  10996. * Detects if the projection matrix requires to be recomputed this frame.
  10997. * @returns true if it requires to be recomputed otherwise, false.
  10998. */
  10999. needProjectionMatrixCompute(): boolean;
  11000. /**
  11001. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  11002. */
  11003. forceProjectionMatrixCompute(): void;
  11004. /** @hidden */
  11005. _initCache(): void;
  11006. /** @hidden */
  11007. _isSynchronized(): boolean;
  11008. /**
  11009. * Computes the world matrix of the node
  11010. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  11011. * @returns the world matrix
  11012. */
  11013. computeWorldMatrix(force?: boolean): Matrix;
  11014. /**
  11015. * Gets the minZ used for shadow according to both the scene and the light.
  11016. * @param activeCamera The camera we are returning the min for
  11017. * @returns the depth min z
  11018. */
  11019. getDepthMinZ(activeCamera: Camera): number;
  11020. /**
  11021. * Gets the maxZ used for shadow according to both the scene and the light.
  11022. * @param activeCamera The camera we are returning the max for
  11023. * @returns the depth max z
  11024. */
  11025. getDepthMaxZ(activeCamera: Camera): number;
  11026. /**
  11027. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  11028. * @param matrix The materix to updated with the projection information
  11029. * @param viewMatrix The transform matrix of the light
  11030. * @param renderList The list of mesh to render in the map
  11031. * @returns The current light
  11032. */
  11033. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  11034. }
  11035. }
  11036. declare module "babylonjs/Materials/materialHelper" {
  11037. import { Nullable } from "babylonjs/types";
  11038. import { Scene } from "babylonjs/scene";
  11039. import { Engine } from "babylonjs/Engines/engine";
  11040. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11041. import { Light } from "babylonjs/Lights/light";
  11042. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  11043. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  11044. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  11045. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  11046. /**
  11047. * "Static Class" containing the most commonly used helper while dealing with material for
  11048. * rendering purpose.
  11049. *
  11050. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  11051. *
  11052. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  11053. */
  11054. export class MaterialHelper {
  11055. /**
  11056. * Bind the current view position to an effect.
  11057. * @param effect The effect to be bound
  11058. * @param scene The scene the eyes position is used from
  11059. */
  11060. static BindEyePosition(effect: Effect, scene: Scene): void;
  11061. /**
  11062. * Helps preparing the defines values about the UVs in used in the effect.
  11063. * UVs are shared as much as we can accross channels in the shaders.
  11064. * @param texture The texture we are preparing the UVs for
  11065. * @param defines The defines to update
  11066. * @param key The channel key "diffuse", "specular"... used in the shader
  11067. */
  11068. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  11069. /**
  11070. * Binds a texture matrix value to its corrsponding uniform
  11071. * @param texture The texture to bind the matrix for
  11072. * @param uniformBuffer The uniform buffer receivin the data
  11073. * @param key The channel key "diffuse", "specular"... used in the shader
  11074. */
  11075. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  11076. /**
  11077. * Gets the current status of the fog (should it be enabled?)
  11078. * @param mesh defines the mesh to evaluate for fog support
  11079. * @param scene defines the hosting scene
  11080. * @returns true if fog must be enabled
  11081. */
  11082. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  11083. /**
  11084. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  11085. * @param mesh defines the current mesh
  11086. * @param scene defines the current scene
  11087. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  11088. * @param pointsCloud defines if point cloud rendering has to be turned on
  11089. * @param fogEnabled defines if fog has to be turned on
  11090. * @param alphaTest defines if alpha testing has to be turned on
  11091. * @param defines defines the current list of defines
  11092. */
  11093. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  11094. /**
  11095. * Helper used to prepare the list of defines associated with frame values for shader compilation
  11096. * @param scene defines the current scene
  11097. * @param engine defines the current engine
  11098. * @param defines specifies the list of active defines
  11099. * @param useInstances defines if instances have to be turned on
  11100. * @param useClipPlane defines if clip plane have to be turned on
  11101. */
  11102. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  11103. /**
  11104. * Prepares the defines for bones
  11105. * @param mesh The mesh containing the geometry data we will draw
  11106. * @param defines The defines to update
  11107. */
  11108. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  11109. /**
  11110. * Prepares the defines for morph targets
  11111. * @param mesh The mesh containing the geometry data we will draw
  11112. * @param defines The defines to update
  11113. */
  11114. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  11115. /**
  11116. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  11117. * @param mesh The mesh containing the geometry data we will draw
  11118. * @param defines The defines to update
  11119. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  11120. * @param useBones Precise whether bones should be used or not (override mesh info)
  11121. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  11122. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  11123. * @returns false if defines are considered not dirty and have not been checked
  11124. */
  11125. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  11126. /**
  11127. * Prepares the defines related to multiview
  11128. * @param scene The scene we are intending to draw
  11129. * @param defines The defines to update
  11130. */
  11131. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  11132. /**
  11133. * Prepares the defines related to the light information passed in parameter
  11134. * @param scene The scene we are intending to draw
  11135. * @param mesh The mesh the effect is compiling for
  11136. * @param light The light the effect is compiling for
  11137. * @param lightIndex The index of the light
  11138. * @param defines The defines to update
  11139. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  11140. * @param state Defines the current state regarding what is needed (normals, etc...)
  11141. */
  11142. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  11143. needNormals: boolean;
  11144. needRebuild: boolean;
  11145. shadowEnabled: boolean;
  11146. specularEnabled: boolean;
  11147. lightmapMode: boolean;
  11148. }): void;
  11149. /**
  11150. * Prepares the defines related to the light information passed in parameter
  11151. * @param scene The scene we are intending to draw
  11152. * @param mesh The mesh the effect is compiling for
  11153. * @param defines The defines to update
  11154. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  11155. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  11156. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  11157. * @returns true if normals will be required for the rest of the effect
  11158. */
  11159. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  11160. /**
  11161. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  11162. * @param lightIndex defines the light index
  11163. * @param uniformsList The uniform list
  11164. * @param samplersList The sampler list
  11165. * @param projectedLightTexture defines if projected texture must be used
  11166. * @param uniformBuffersList defines an optional list of uniform buffers
  11167. */
  11168. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  11169. /**
  11170. * Prepares the uniforms and samplers list to be used in the effect
  11171. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  11172. * @param samplersList The sampler list
  11173. * @param defines The defines helping in the list generation
  11174. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  11175. */
  11176. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  11177. /**
  11178. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  11179. * @param defines The defines to update while falling back
  11180. * @param fallbacks The authorized effect fallbacks
  11181. * @param maxSimultaneousLights The maximum number of lights allowed
  11182. * @param rank the current rank of the Effect
  11183. * @returns The newly affected rank
  11184. */
  11185. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  11186. private static _TmpMorphInfluencers;
  11187. /**
  11188. * Prepares the list of attributes required for morph targets according to the effect defines.
  11189. * @param attribs The current list of supported attribs
  11190. * @param mesh The mesh to prepare the morph targets attributes for
  11191. * @param influencers The number of influencers
  11192. */
  11193. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  11194. /**
  11195. * Prepares the list of attributes required for morph targets according to the effect defines.
  11196. * @param attribs The current list of supported attribs
  11197. * @param mesh The mesh to prepare the morph targets attributes for
  11198. * @param defines The current Defines of the effect
  11199. */
  11200. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  11201. /**
  11202. * Prepares the list of attributes required for bones according to the effect defines.
  11203. * @param attribs The current list of supported attribs
  11204. * @param mesh The mesh to prepare the bones attributes for
  11205. * @param defines The current Defines of the effect
  11206. * @param fallbacks The current efffect fallback strategy
  11207. */
  11208. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  11209. /**
  11210. * Check and prepare the list of attributes required for instances according to the effect defines.
  11211. * @param attribs The current list of supported attribs
  11212. * @param defines The current MaterialDefines of the effect
  11213. */
  11214. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  11215. /**
  11216. * Add the list of attributes required for instances to the attribs array.
  11217. * @param attribs The current list of supported attribs
  11218. */
  11219. static PushAttributesForInstances(attribs: string[]): void;
  11220. /**
  11221. * Binds the light shadow information to the effect for the given mesh.
  11222. * @param light The light containing the generator
  11223. * @param scene The scene the lights belongs to
  11224. * @param mesh The mesh we are binding the information to render
  11225. * @param lightIndex The light index in the effect used to render the mesh
  11226. * @param effect The effect we are binding the data to
  11227. */
  11228. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  11229. /**
  11230. * Binds the light information to the effect.
  11231. * @param light The light containing the generator
  11232. * @param effect The effect we are binding the data to
  11233. * @param lightIndex The light index in the effect used to render
  11234. */
  11235. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  11236. /**
  11237. * Binds the lights information from the scene to the effect for the given mesh.
  11238. * @param light Light to bind
  11239. * @param lightIndex Light index
  11240. * @param scene The scene where the light belongs to
  11241. * @param mesh The mesh we are binding the information to render
  11242. * @param effect The effect we are binding the data to
  11243. * @param useSpecular Defines if specular is supported
  11244. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  11245. */
  11246. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  11247. /**
  11248. * Binds the lights information from the scene to the effect for the given mesh.
  11249. * @param scene The scene the lights belongs to
  11250. * @param mesh The mesh we are binding the information to render
  11251. * @param effect The effect we are binding the data to
  11252. * @param defines The generated defines for the effect
  11253. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  11254. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  11255. */
  11256. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  11257. private static _tempFogColor;
  11258. /**
  11259. * Binds the fog information from the scene to the effect for the given mesh.
  11260. * @param scene The scene the lights belongs to
  11261. * @param mesh The mesh we are binding the information to render
  11262. * @param effect The effect we are binding the data to
  11263. * @param linearSpace Defines if the fog effect is applied in linear space
  11264. */
  11265. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  11266. /**
  11267. * Binds the bones information from the mesh to the effect.
  11268. * @param mesh The mesh we are binding the information to render
  11269. * @param effect The effect we are binding the data to
  11270. */
  11271. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  11272. /**
  11273. * Binds the morph targets information from the mesh to the effect.
  11274. * @param abstractMesh The mesh we are binding the information to render
  11275. * @param effect The effect we are binding the data to
  11276. */
  11277. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  11278. /**
  11279. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  11280. * @param defines The generated defines used in the effect
  11281. * @param effect The effect we are binding the data to
  11282. * @param scene The scene we are willing to render with logarithmic scale for
  11283. */
  11284. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  11285. /**
  11286. * Binds the clip plane information from the scene to the effect.
  11287. * @param scene The scene the clip plane information are extracted from
  11288. * @param effect The effect we are binding the data to
  11289. */
  11290. static BindClipPlane(effect: Effect, scene: Scene): void;
  11291. }
  11292. }
  11293. declare module "babylonjs/Shaders/shadowMap.fragment" {
  11294. /** @hidden */
  11295. export var shadowMapPixelShader: {
  11296. name: string;
  11297. shader: string;
  11298. };
  11299. }
  11300. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  11301. /** @hidden */
  11302. export var bonesDeclaration: {
  11303. name: string;
  11304. shader: string;
  11305. };
  11306. }
  11307. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  11308. /** @hidden */
  11309. export var morphTargetsVertexGlobalDeclaration: {
  11310. name: string;
  11311. shader: string;
  11312. };
  11313. }
  11314. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  11315. /** @hidden */
  11316. export var morphTargetsVertexDeclaration: {
  11317. name: string;
  11318. shader: string;
  11319. };
  11320. }
  11321. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  11322. /** @hidden */
  11323. export var instancesDeclaration: {
  11324. name: string;
  11325. shader: string;
  11326. };
  11327. }
  11328. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  11329. /** @hidden */
  11330. export var helperFunctions: {
  11331. name: string;
  11332. shader: string;
  11333. };
  11334. }
  11335. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  11336. /** @hidden */
  11337. export var morphTargetsVertex: {
  11338. name: string;
  11339. shader: string;
  11340. };
  11341. }
  11342. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  11343. /** @hidden */
  11344. export var instancesVertex: {
  11345. name: string;
  11346. shader: string;
  11347. };
  11348. }
  11349. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  11350. /** @hidden */
  11351. export var bonesVertex: {
  11352. name: string;
  11353. shader: string;
  11354. };
  11355. }
  11356. declare module "babylonjs/Shaders/shadowMap.vertex" {
  11357. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  11358. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  11359. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  11360. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  11361. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11362. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  11363. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  11364. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  11365. /** @hidden */
  11366. export var shadowMapVertexShader: {
  11367. name: string;
  11368. shader: string;
  11369. };
  11370. }
  11371. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  11372. /** @hidden */
  11373. export var depthBoxBlurPixelShader: {
  11374. name: string;
  11375. shader: string;
  11376. };
  11377. }
  11378. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  11379. import { Nullable } from "babylonjs/types";
  11380. import { Scene } from "babylonjs/scene";
  11381. import { Matrix } from "babylonjs/Maths/math";
  11382. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11384. import { Mesh } from "babylonjs/Meshes/mesh";
  11385. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  11386. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  11387. import { Effect } from "babylonjs/Materials/effect";
  11388. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11389. import "babylonjs/Shaders/shadowMap.fragment";
  11390. import "babylonjs/Shaders/shadowMap.vertex";
  11391. import "babylonjs/Shaders/depthBoxBlur.fragment";
  11392. import { Observable } from "babylonjs/Misc/observable";
  11393. /**
  11394. * Defines the options associated with the creation of a custom shader for a shadow generator.
  11395. */
  11396. export interface ICustomShaderOptions {
  11397. /**
  11398. * Gets or sets the custom shader name to use
  11399. */
  11400. shaderName: string;
  11401. /**
  11402. * The list of attribute names used in the shader
  11403. */
  11404. attributes?: string[];
  11405. /**
  11406. * The list of unifrom names used in the shader
  11407. */
  11408. uniforms?: string[];
  11409. /**
  11410. * The list of sampler names used in the shader
  11411. */
  11412. samplers?: string[];
  11413. /**
  11414. * The list of defines used in the shader
  11415. */
  11416. defines?: string[];
  11417. }
  11418. /**
  11419. * Interface to implement to create a shadow generator compatible with BJS.
  11420. */
  11421. export interface IShadowGenerator {
  11422. /**
  11423. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11424. * @returns The render target texture if present otherwise, null
  11425. */
  11426. getShadowMap(): Nullable<RenderTargetTexture>;
  11427. /**
  11428. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11429. * @returns The render target texture if the shadow map is present otherwise, null
  11430. */
  11431. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11432. /**
  11433. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11434. * @param subMesh The submesh we want to render in the shadow map
  11435. * @param useInstances Defines wether will draw in the map using instances
  11436. * @returns true if ready otherwise, false
  11437. */
  11438. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11439. /**
  11440. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11441. * @param defines Defines of the material we want to update
  11442. * @param lightIndex Index of the light in the enabled light list of the material
  11443. */
  11444. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  11445. /**
  11446. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11447. * defined in the generator but impacting the effect).
  11448. * It implies the unifroms available on the materials are the standard BJS ones.
  11449. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11450. * @param effect The effect we are binfing the information for
  11451. */
  11452. bindShadowLight(lightIndex: string, effect: Effect): void;
  11453. /**
  11454. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11455. * (eq to shadow prjection matrix * light transform matrix)
  11456. * @returns The transform matrix used to create the shadow map
  11457. */
  11458. getTransformMatrix(): Matrix;
  11459. /**
  11460. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11461. * Cube and 2D textures for instance.
  11462. */
  11463. recreateShadowMap(): void;
  11464. /**
  11465. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11466. * @param onCompiled Callback triggered at the and of the effects compilation
  11467. * @param options Sets of optional options forcing the compilation with different modes
  11468. */
  11469. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11470. useInstances: boolean;
  11471. }>): void;
  11472. /**
  11473. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11474. * @param options Sets of optional options forcing the compilation with different modes
  11475. * @returns A promise that resolves when the compilation completes
  11476. */
  11477. forceCompilationAsync(options?: Partial<{
  11478. useInstances: boolean;
  11479. }>): Promise<void>;
  11480. /**
  11481. * Serializes the shadow generator setup to a json object.
  11482. * @returns The serialized JSON object
  11483. */
  11484. serialize(): any;
  11485. /**
  11486. * Disposes the Shadow map and related Textures and effects.
  11487. */
  11488. dispose(): void;
  11489. }
  11490. /**
  11491. * Default implementation IShadowGenerator.
  11492. * This is the main object responsible of generating shadows in the framework.
  11493. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  11494. */
  11495. export class ShadowGenerator implements IShadowGenerator {
  11496. /**
  11497. * Shadow generator mode None: no filtering applied.
  11498. */
  11499. static readonly FILTER_NONE: number;
  11500. /**
  11501. * Shadow generator mode ESM: Exponential Shadow Mapping.
  11502. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11503. */
  11504. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  11505. /**
  11506. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  11507. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  11508. */
  11509. static readonly FILTER_POISSONSAMPLING: number;
  11510. /**
  11511. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  11512. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11513. */
  11514. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  11515. /**
  11516. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  11517. * edge artifacts on steep falloff.
  11518. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11519. */
  11520. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  11521. /**
  11522. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  11523. * edge artifacts on steep falloff.
  11524. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11525. */
  11526. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  11527. /**
  11528. * Shadow generator mode PCF: Percentage Closer Filtering
  11529. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11530. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  11531. */
  11532. static readonly FILTER_PCF: number;
  11533. /**
  11534. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  11535. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11536. * Contact Hardening
  11537. */
  11538. static readonly FILTER_PCSS: number;
  11539. /**
  11540. * Reserved for PCF and PCSS
  11541. * Highest Quality.
  11542. *
  11543. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  11544. *
  11545. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  11546. */
  11547. static readonly QUALITY_HIGH: number;
  11548. /**
  11549. * Reserved for PCF and PCSS
  11550. * Good tradeoff for quality/perf cross devices
  11551. *
  11552. * Execute PCF on a 3*3 kernel.
  11553. *
  11554. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  11555. */
  11556. static readonly QUALITY_MEDIUM: number;
  11557. /**
  11558. * Reserved for PCF and PCSS
  11559. * The lowest quality but the fastest.
  11560. *
  11561. * Execute PCF on a 1*1 kernel.
  11562. *
  11563. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  11564. */
  11565. static readonly QUALITY_LOW: number;
  11566. /** Gets or sets the custom shader name to use */
  11567. customShaderOptions: ICustomShaderOptions;
  11568. /**
  11569. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  11570. */
  11571. onBeforeShadowMapRenderObservable: Observable<Effect>;
  11572. /**
  11573. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  11574. */
  11575. onAfterShadowMapRenderObservable: Observable<Effect>;
  11576. /**
  11577. * Observable triggered before a mesh is rendered in the shadow map.
  11578. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  11579. */
  11580. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  11581. /**
  11582. * Observable triggered after a mesh is rendered in the shadow map.
  11583. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  11584. */
  11585. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  11586. private _bias;
  11587. /**
  11588. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  11589. */
  11590. /**
  11591. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  11592. */
  11593. bias: number;
  11594. private _normalBias;
  11595. /**
  11596. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11597. */
  11598. /**
  11599. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11600. */
  11601. normalBias: number;
  11602. private _blurBoxOffset;
  11603. /**
  11604. * Gets the blur box offset: offset applied during the blur pass.
  11605. * Only useful if useKernelBlur = false
  11606. */
  11607. /**
  11608. * Sets the blur box offset: offset applied during the blur pass.
  11609. * Only useful if useKernelBlur = false
  11610. */
  11611. blurBoxOffset: number;
  11612. private _blurScale;
  11613. /**
  11614. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  11615. * 2 means half of the size.
  11616. */
  11617. /**
  11618. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  11619. * 2 means half of the size.
  11620. */
  11621. blurScale: number;
  11622. private _blurKernel;
  11623. /**
  11624. * Gets the blur kernel: kernel size of the blur pass.
  11625. * Only useful if useKernelBlur = true
  11626. */
  11627. /**
  11628. * Sets the blur kernel: kernel size of the blur pass.
  11629. * Only useful if useKernelBlur = true
  11630. */
  11631. blurKernel: number;
  11632. private _useKernelBlur;
  11633. /**
  11634. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  11635. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11636. */
  11637. /**
  11638. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  11639. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11640. */
  11641. useKernelBlur: boolean;
  11642. private _depthScale;
  11643. /**
  11644. * Gets the depth scale used in ESM mode.
  11645. */
  11646. /**
  11647. * Sets the depth scale used in ESM mode.
  11648. * This can override the scale stored on the light.
  11649. */
  11650. depthScale: number;
  11651. private _filter;
  11652. /**
  11653. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  11654. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11655. */
  11656. /**
  11657. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  11658. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11659. */
  11660. filter: number;
  11661. /**
  11662. * Gets if the current filter is set to Poisson Sampling.
  11663. */
  11664. /**
  11665. * Sets the current filter to Poisson Sampling.
  11666. */
  11667. usePoissonSampling: boolean;
  11668. /**
  11669. * Gets if the current filter is set to ESM.
  11670. */
  11671. /**
  11672. * Sets the current filter is to ESM.
  11673. */
  11674. useExponentialShadowMap: boolean;
  11675. /**
  11676. * Gets if the current filter is set to filtered ESM.
  11677. */
  11678. /**
  11679. * Gets if the current filter is set to filtered ESM.
  11680. */
  11681. useBlurExponentialShadowMap: boolean;
  11682. /**
  11683. * Gets if the current filter is set to "close ESM" (using the inverse of the
  11684. * exponential to prevent steep falloff artifacts).
  11685. */
  11686. /**
  11687. * Sets the current filter to "close ESM" (using the inverse of the
  11688. * exponential to prevent steep falloff artifacts).
  11689. */
  11690. useCloseExponentialShadowMap: boolean;
  11691. /**
  11692. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  11693. * exponential to prevent steep falloff artifacts).
  11694. */
  11695. /**
  11696. * Sets the current filter to filtered "close ESM" (using the inverse of the
  11697. * exponential to prevent steep falloff artifacts).
  11698. */
  11699. useBlurCloseExponentialShadowMap: boolean;
  11700. /**
  11701. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  11702. */
  11703. /**
  11704. * Sets the current filter to "PCF" (percentage closer filtering).
  11705. */
  11706. usePercentageCloserFiltering: boolean;
  11707. private _filteringQuality;
  11708. /**
  11709. * Gets the PCF or PCSS Quality.
  11710. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11711. */
  11712. /**
  11713. * Sets the PCF or PCSS Quality.
  11714. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11715. */
  11716. filteringQuality: number;
  11717. /**
  11718. * Gets if the current filter is set to "PCSS" (contact hardening).
  11719. */
  11720. /**
  11721. * Sets the current filter to "PCSS" (contact hardening).
  11722. */
  11723. useContactHardeningShadow: boolean;
  11724. private _contactHardeningLightSizeUVRatio;
  11725. /**
  11726. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11727. * Using a ratio helps keeping shape stability independently of the map size.
  11728. *
  11729. * It does not account for the light projection as it was having too much
  11730. * instability during the light setup or during light position changes.
  11731. *
  11732. * Only valid if useContactHardeningShadow is true.
  11733. */
  11734. /**
  11735. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11736. * Using a ratio helps keeping shape stability independently of the map size.
  11737. *
  11738. * It does not account for the light projection as it was having too much
  11739. * instability during the light setup or during light position changes.
  11740. *
  11741. * Only valid if useContactHardeningShadow is true.
  11742. */
  11743. contactHardeningLightSizeUVRatio: number;
  11744. private _darkness;
  11745. /** Gets or sets the actual darkness of a shadow */
  11746. darkness: number;
  11747. /**
  11748. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  11749. * 0 means strongest and 1 would means no shadow.
  11750. * @returns the darkness.
  11751. */
  11752. getDarkness(): number;
  11753. /**
  11754. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  11755. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  11756. * @returns the shadow generator allowing fluent coding.
  11757. */
  11758. setDarkness(darkness: number): ShadowGenerator;
  11759. private _transparencyShadow;
  11760. /** Gets or sets the ability to have transparent shadow */
  11761. transparencyShadow: boolean;
  11762. /**
  11763. * Sets the ability to have transparent shadow (boolean).
  11764. * @param transparent True if transparent else False
  11765. * @returns the shadow generator allowing fluent coding
  11766. */
  11767. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  11768. private _shadowMap;
  11769. private _shadowMap2;
  11770. /**
  11771. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11772. * @returns The render target texture if present otherwise, null
  11773. */
  11774. getShadowMap(): Nullable<RenderTargetTexture>;
  11775. /**
  11776. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11777. * @returns The render target texture if the shadow map is present otherwise, null
  11778. */
  11779. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11780. /**
  11781. * Gets the class name of that object
  11782. * @returns "ShadowGenerator"
  11783. */
  11784. getClassName(): string;
  11785. /**
  11786. * Helper function to add a mesh and its descendants to the list of shadow casters.
  11787. * @param mesh Mesh to add
  11788. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  11789. * @returns the Shadow Generator itself
  11790. */
  11791. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11792. /**
  11793. * Helper function to remove a mesh and its descendants from the list of shadow casters
  11794. * @param mesh Mesh to remove
  11795. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  11796. * @returns the Shadow Generator itself
  11797. */
  11798. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11799. /**
  11800. * Controls the extent to which the shadows fade out at the edge of the frustum
  11801. * Used only by directionals and spots
  11802. */
  11803. frustumEdgeFalloff: number;
  11804. private _light;
  11805. /**
  11806. * Returns the associated light object.
  11807. * @returns the light generating the shadow
  11808. */
  11809. getLight(): IShadowLight;
  11810. /**
  11811. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  11812. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  11813. * It might on the other hand introduce peter panning.
  11814. */
  11815. forceBackFacesOnly: boolean;
  11816. private _scene;
  11817. private _lightDirection;
  11818. private _effect;
  11819. private _viewMatrix;
  11820. private _projectionMatrix;
  11821. private _transformMatrix;
  11822. private _cachedPosition;
  11823. private _cachedDirection;
  11824. private _cachedDefines;
  11825. private _currentRenderID;
  11826. private _boxBlurPostprocess;
  11827. private _kernelBlurXPostprocess;
  11828. private _kernelBlurYPostprocess;
  11829. private _blurPostProcesses;
  11830. private _mapSize;
  11831. private _currentFaceIndex;
  11832. private _currentFaceIndexCache;
  11833. private _textureType;
  11834. private _defaultTextureMatrix;
  11835. /** @hidden */
  11836. static _SceneComponentInitialization: (scene: Scene) => void;
  11837. /**
  11838. * Creates a ShadowGenerator object.
  11839. * A ShadowGenerator is the required tool to use the shadows.
  11840. * Each light casting shadows needs to use its own ShadowGenerator.
  11841. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  11842. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  11843. * @param light The light object generating the shadows.
  11844. * @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.
  11845. */
  11846. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  11847. private _initializeGenerator;
  11848. private _initializeShadowMap;
  11849. private _initializeBlurRTTAndPostProcesses;
  11850. private _renderForShadowMap;
  11851. private _renderSubMeshForShadowMap;
  11852. private _applyFilterValues;
  11853. /**
  11854. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11855. * @param onCompiled Callback triggered at the and of the effects compilation
  11856. * @param options Sets of optional options forcing the compilation with different modes
  11857. */
  11858. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11859. useInstances: boolean;
  11860. }>): void;
  11861. /**
  11862. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11863. * @param options Sets of optional options forcing the compilation with different modes
  11864. * @returns A promise that resolves when the compilation completes
  11865. */
  11866. forceCompilationAsync(options?: Partial<{
  11867. useInstances: boolean;
  11868. }>): Promise<void>;
  11869. /**
  11870. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11871. * @param subMesh The submesh we want to render in the shadow map
  11872. * @param useInstances Defines wether will draw in the map using instances
  11873. * @returns true if ready otherwise, false
  11874. */
  11875. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11876. /**
  11877. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11878. * @param defines Defines of the material we want to update
  11879. * @param lightIndex Index of the light in the enabled light list of the material
  11880. */
  11881. prepareDefines(defines: any, lightIndex: number): void;
  11882. /**
  11883. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11884. * defined in the generator but impacting the effect).
  11885. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11886. * @param effect The effect we are binfing the information for
  11887. */
  11888. bindShadowLight(lightIndex: string, effect: Effect): void;
  11889. /**
  11890. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11891. * (eq to shadow prjection matrix * light transform matrix)
  11892. * @returns The transform matrix used to create the shadow map
  11893. */
  11894. getTransformMatrix(): Matrix;
  11895. /**
  11896. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11897. * Cube and 2D textures for instance.
  11898. */
  11899. recreateShadowMap(): void;
  11900. private _disposeBlurPostProcesses;
  11901. private _disposeRTTandPostProcesses;
  11902. /**
  11903. * Disposes the ShadowGenerator.
  11904. * Returns nothing.
  11905. */
  11906. dispose(): void;
  11907. /**
  11908. * Serializes the shadow generator setup to a json object.
  11909. * @returns The serialized JSON object
  11910. */
  11911. serialize(): any;
  11912. /**
  11913. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  11914. * @param parsedShadowGenerator The JSON object to parse
  11915. * @param scene The scene to create the shadow map for
  11916. * @returns The parsed shadow generator
  11917. */
  11918. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  11919. }
  11920. }
  11921. declare module "babylonjs/Lights/light" {
  11922. import { Nullable } from "babylonjs/types";
  11923. import { Scene } from "babylonjs/scene";
  11924. import { Vector3, Color3 } from "babylonjs/Maths/math";
  11925. import { Node } from "babylonjs/node";
  11926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11927. import { Effect } from "babylonjs/Materials/effect";
  11928. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  11929. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  11930. /**
  11931. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11932. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11933. * 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.
  11934. */
  11935. export abstract class Light extends Node {
  11936. /**
  11937. * Falloff Default: light is falling off following the material specification:
  11938. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  11939. */
  11940. static readonly FALLOFF_DEFAULT: number;
  11941. /**
  11942. * Falloff Physical: light is falling off following the inverse squared distance law.
  11943. */
  11944. static readonly FALLOFF_PHYSICAL: number;
  11945. /**
  11946. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  11947. * to enhance interoperability with other engines.
  11948. */
  11949. static readonly FALLOFF_GLTF: number;
  11950. /**
  11951. * Falloff Standard: light is falling off like in the standard material
  11952. * to enhance interoperability with other materials.
  11953. */
  11954. static readonly FALLOFF_STANDARD: number;
  11955. /**
  11956. * If every light affecting the material is in this lightmapMode,
  11957. * material.lightmapTexture adds or multiplies
  11958. * (depends on material.useLightmapAsShadowmap)
  11959. * after every other light calculations.
  11960. */
  11961. static readonly LIGHTMAP_DEFAULT: number;
  11962. /**
  11963. * material.lightmapTexture as only diffuse lighting from this light
  11964. * adds only specular lighting from this light
  11965. * adds dynamic shadows
  11966. */
  11967. static readonly LIGHTMAP_SPECULAR: number;
  11968. /**
  11969. * material.lightmapTexture as only lighting
  11970. * no light calculation from this light
  11971. * only adds dynamic shadows from this light
  11972. */
  11973. static readonly LIGHTMAP_SHADOWSONLY: number;
  11974. /**
  11975. * Each light type uses the default quantity according to its type:
  11976. * point/spot lights use luminous intensity
  11977. * directional lights use illuminance
  11978. */
  11979. static readonly INTENSITYMODE_AUTOMATIC: number;
  11980. /**
  11981. * lumen (lm)
  11982. */
  11983. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11984. /**
  11985. * candela (lm/sr)
  11986. */
  11987. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11988. /**
  11989. * lux (lm/m^2)
  11990. */
  11991. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11992. /**
  11993. * nit (cd/m^2)
  11994. */
  11995. static readonly INTENSITYMODE_LUMINANCE: number;
  11996. /**
  11997. * Light type const id of the point light.
  11998. */
  11999. static readonly LIGHTTYPEID_POINTLIGHT: number;
  12000. /**
  12001. * Light type const id of the directional light.
  12002. */
  12003. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  12004. /**
  12005. * Light type const id of the spot light.
  12006. */
  12007. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  12008. /**
  12009. * Light type const id of the hemispheric light.
  12010. */
  12011. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  12012. /**
  12013. * Diffuse gives the basic color to an object.
  12014. */
  12015. diffuse: Color3;
  12016. /**
  12017. * Specular produces a highlight color on an object.
  12018. * Note: This is note affecting PBR materials.
  12019. */
  12020. specular: Color3;
  12021. /**
  12022. * Defines the falloff type for this light. This lets overrriding how punctual light are
  12023. * falling off base on range or angle.
  12024. * This can be set to any values in Light.FALLOFF_x.
  12025. *
  12026. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  12027. * other types of materials.
  12028. */
  12029. falloffType: number;
  12030. /**
  12031. * Strength of the light.
  12032. * Note: By default it is define in the framework own unit.
  12033. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  12034. */
  12035. intensity: number;
  12036. private _range;
  12037. protected _inverseSquaredRange: number;
  12038. /**
  12039. * Defines how far from the source the light is impacting in scene units.
  12040. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12041. */
  12042. /**
  12043. * Defines how far from the source the light is impacting in scene units.
  12044. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12045. */
  12046. range: number;
  12047. /**
  12048. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  12049. * of light.
  12050. */
  12051. private _photometricScale;
  12052. private _intensityMode;
  12053. /**
  12054. * Gets the photometric scale used to interpret the intensity.
  12055. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12056. */
  12057. /**
  12058. * Sets the photometric scale used to interpret the intensity.
  12059. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12060. */
  12061. intensityMode: number;
  12062. private _radius;
  12063. /**
  12064. * Gets the light radius used by PBR Materials to simulate soft area lights.
  12065. */
  12066. /**
  12067. * sets the light radius used by PBR Materials to simulate soft area lights.
  12068. */
  12069. radius: number;
  12070. private _renderPriority;
  12071. /**
  12072. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  12073. * exceeding the number allowed of the materials.
  12074. */
  12075. renderPriority: number;
  12076. private _shadowEnabled;
  12077. /**
  12078. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12079. * the current shadow generator.
  12080. */
  12081. /**
  12082. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12083. * the current shadow generator.
  12084. */
  12085. shadowEnabled: boolean;
  12086. private _includedOnlyMeshes;
  12087. /**
  12088. * Gets the only meshes impacted by this light.
  12089. */
  12090. /**
  12091. * Sets the only meshes impacted by this light.
  12092. */
  12093. includedOnlyMeshes: AbstractMesh[];
  12094. private _excludedMeshes;
  12095. /**
  12096. * Gets the meshes not impacted by this light.
  12097. */
  12098. /**
  12099. * Sets the meshes not impacted by this light.
  12100. */
  12101. excludedMeshes: AbstractMesh[];
  12102. private _excludeWithLayerMask;
  12103. /**
  12104. * Gets the layer id use to find what meshes are not impacted by the light.
  12105. * Inactive if 0
  12106. */
  12107. /**
  12108. * Sets the layer id use to find what meshes are not impacted by the light.
  12109. * Inactive if 0
  12110. */
  12111. excludeWithLayerMask: number;
  12112. private _includeOnlyWithLayerMask;
  12113. /**
  12114. * Gets the layer id use to find what meshes are impacted by the light.
  12115. * Inactive if 0
  12116. */
  12117. /**
  12118. * Sets the layer id use to find what meshes are impacted by the light.
  12119. * Inactive if 0
  12120. */
  12121. includeOnlyWithLayerMask: number;
  12122. private _lightmapMode;
  12123. /**
  12124. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12125. */
  12126. /**
  12127. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12128. */
  12129. lightmapMode: number;
  12130. /**
  12131. * Shadow generator associted to the light.
  12132. * @hidden Internal use only.
  12133. */
  12134. _shadowGenerator: Nullable<IShadowGenerator>;
  12135. /**
  12136. * @hidden Internal use only.
  12137. */
  12138. _excludedMeshesIds: string[];
  12139. /**
  12140. * @hidden Internal use only.
  12141. */
  12142. _includedOnlyMeshesIds: string[];
  12143. /**
  12144. * The current light unifom buffer.
  12145. * @hidden Internal use only.
  12146. */
  12147. _uniformBuffer: UniformBuffer;
  12148. /**
  12149. * Creates a Light object in the scene.
  12150. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12151. * @param name The firendly name of the light
  12152. * @param scene The scene the light belongs too
  12153. */
  12154. constructor(name: string, scene: Scene);
  12155. protected abstract _buildUniformLayout(): void;
  12156. /**
  12157. * Sets the passed Effect "effect" with the Light information.
  12158. * @param effect The effect to update
  12159. * @param lightIndex The index of the light in the effect to update
  12160. * @returns The light
  12161. */
  12162. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  12163. /**
  12164. * Returns the string "Light".
  12165. * @returns the class name
  12166. */
  12167. getClassName(): string;
  12168. /** @hidden */
  12169. readonly _isLight: boolean;
  12170. /**
  12171. * Converts the light information to a readable string for debug purpose.
  12172. * @param fullDetails Supports for multiple levels of logging within scene loading
  12173. * @returns the human readable light info
  12174. */
  12175. toString(fullDetails?: boolean): string;
  12176. /** @hidden */
  12177. protected _syncParentEnabledState(): void;
  12178. /**
  12179. * Set the enabled state of this node.
  12180. * @param value - the new enabled state
  12181. */
  12182. setEnabled(value: boolean): void;
  12183. /**
  12184. * Returns the Light associated shadow generator if any.
  12185. * @return the associated shadow generator.
  12186. */
  12187. getShadowGenerator(): Nullable<IShadowGenerator>;
  12188. /**
  12189. * Returns a Vector3, the absolute light position in the World.
  12190. * @returns the world space position of the light
  12191. */
  12192. getAbsolutePosition(): Vector3;
  12193. /**
  12194. * Specifies if the light will affect the passed mesh.
  12195. * @param mesh The mesh to test against the light
  12196. * @return true the mesh is affected otherwise, false.
  12197. */
  12198. canAffectMesh(mesh: AbstractMesh): boolean;
  12199. /**
  12200. * Sort function to order lights for rendering.
  12201. * @param a First Light object to compare to second.
  12202. * @param b Second Light object to compare first.
  12203. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  12204. */
  12205. static CompareLightsPriority(a: Light, b: Light): number;
  12206. /**
  12207. * Releases resources associated with this node.
  12208. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12209. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12210. */
  12211. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12212. /**
  12213. * Returns the light type ID (integer).
  12214. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12215. */
  12216. getTypeID(): number;
  12217. /**
  12218. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  12219. * @returns the scaled intensity in intensity mode unit
  12220. */
  12221. getScaledIntensity(): number;
  12222. /**
  12223. * Returns a new Light object, named "name", from the current one.
  12224. * @param name The name of the cloned light
  12225. * @returns the new created light
  12226. */
  12227. clone(name: string): Nullable<Light>;
  12228. /**
  12229. * Serializes the current light into a Serialization object.
  12230. * @returns the serialized object.
  12231. */
  12232. serialize(): any;
  12233. /**
  12234. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  12235. * This new light is named "name" and added to the passed scene.
  12236. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  12237. * @param name The friendly name of the light
  12238. * @param scene The scene the new light will belong to
  12239. * @returns the constructor function
  12240. */
  12241. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  12242. /**
  12243. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  12244. * @param parsedLight The JSON representation of the light
  12245. * @param scene The scene to create the parsed light in
  12246. * @returns the created light after parsing
  12247. */
  12248. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  12249. private _hookArrayForExcluded;
  12250. private _hookArrayForIncludedOnly;
  12251. private _resyncMeshes;
  12252. /**
  12253. * Forces the meshes to update their light related information in their rendering used effects
  12254. * @hidden Internal Use Only
  12255. */
  12256. _markMeshesAsLightDirty(): void;
  12257. /**
  12258. * Recomputes the cached photometric scale if needed.
  12259. */
  12260. private _computePhotometricScale;
  12261. /**
  12262. * Returns the Photometric Scale according to the light type and intensity mode.
  12263. */
  12264. private _getPhotometricScale;
  12265. /**
  12266. * Reorder the light in the scene according to their defined priority.
  12267. * @hidden Internal Use Only
  12268. */
  12269. _reorderLightsInScene(): void;
  12270. /**
  12271. * Prepares the list of defines specific to the light type.
  12272. * @param defines the list of defines
  12273. * @param lightIndex defines the index of the light for the effect
  12274. */
  12275. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12276. }
  12277. }
  12278. declare module "babylonjs/Meshes/instancedMesh" {
  12279. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  12280. import { Vector3, Matrix } from "babylonjs/Maths/math";
  12281. import { Camera } from "babylonjs/Cameras/camera";
  12282. import { Node } from "babylonjs/node";
  12283. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12284. import { Mesh } from "babylonjs/Meshes/mesh";
  12285. import { Material } from "babylonjs/Materials/material";
  12286. import { Skeleton } from "babylonjs/Bones/skeleton";
  12287. import { Light } from "babylonjs/Lights/light";
  12288. /**
  12289. * Creates an instance based on a source mesh.
  12290. */
  12291. export class InstancedMesh extends AbstractMesh {
  12292. private _sourceMesh;
  12293. private _currentLOD;
  12294. /** @hidden */
  12295. _indexInSourceMeshInstanceArray: number;
  12296. constructor(name: string, source: Mesh);
  12297. /**
  12298. * Returns the string "InstancedMesh".
  12299. */
  12300. getClassName(): string;
  12301. /** Gets the list of lights affecting that mesh */
  12302. readonly lightSources: Light[];
  12303. _resyncLightSources(): void;
  12304. _resyncLighSource(light: Light): void;
  12305. _removeLightSource(light: Light): void;
  12306. /**
  12307. * If the source mesh receives shadows
  12308. */
  12309. readonly receiveShadows: boolean;
  12310. /**
  12311. * The material of the source mesh
  12312. */
  12313. readonly material: Nullable<Material>;
  12314. /**
  12315. * Visibility of the source mesh
  12316. */
  12317. readonly visibility: number;
  12318. /**
  12319. * Skeleton of the source mesh
  12320. */
  12321. readonly skeleton: Nullable<Skeleton>;
  12322. /**
  12323. * Rendering ground id of the source mesh
  12324. */
  12325. renderingGroupId: number;
  12326. /**
  12327. * Returns the total number of vertices (integer).
  12328. */
  12329. getTotalVertices(): number;
  12330. /**
  12331. * Returns a positive integer : the total number of indices in this mesh geometry.
  12332. * @returns the numner of indices or zero if the mesh has no geometry.
  12333. */
  12334. getTotalIndices(): number;
  12335. /**
  12336. * The source mesh of the instance
  12337. */
  12338. readonly sourceMesh: Mesh;
  12339. /**
  12340. * Is this node ready to be used/rendered
  12341. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  12342. * @return {boolean} is it ready
  12343. */
  12344. isReady(completeCheck?: boolean): boolean;
  12345. /**
  12346. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  12347. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  12348. * @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.
  12349. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  12350. */
  12351. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  12352. /**
  12353. * Sets the vertex data of the mesh geometry for the requested `kind`.
  12354. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  12355. * The `data` are either a numeric array either a Float32Array.
  12356. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  12357. * 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).
  12358. * Note that a new underlying VertexBuffer object is created each call.
  12359. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  12360. *
  12361. * Possible `kind` values :
  12362. * - VertexBuffer.PositionKind
  12363. * - VertexBuffer.UVKind
  12364. * - VertexBuffer.UV2Kind
  12365. * - VertexBuffer.UV3Kind
  12366. * - VertexBuffer.UV4Kind
  12367. * - VertexBuffer.UV5Kind
  12368. * - VertexBuffer.UV6Kind
  12369. * - VertexBuffer.ColorKind
  12370. * - VertexBuffer.MatricesIndicesKind
  12371. * - VertexBuffer.MatricesIndicesExtraKind
  12372. * - VertexBuffer.MatricesWeightsKind
  12373. * - VertexBuffer.MatricesWeightsExtraKind
  12374. *
  12375. * Returns the Mesh.
  12376. */
  12377. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  12378. /**
  12379. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  12380. * If the mesh has no geometry, it is simply returned as it is.
  12381. * The `data` are either a numeric array either a Float32Array.
  12382. * No new underlying VertexBuffer object is created.
  12383. * 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.
  12384. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  12385. *
  12386. * Possible `kind` values :
  12387. * - VertexBuffer.PositionKind
  12388. * - VertexBuffer.UVKind
  12389. * - VertexBuffer.UV2Kind
  12390. * - VertexBuffer.UV3Kind
  12391. * - VertexBuffer.UV4Kind
  12392. * - VertexBuffer.UV5Kind
  12393. * - VertexBuffer.UV6Kind
  12394. * - VertexBuffer.ColorKind
  12395. * - VertexBuffer.MatricesIndicesKind
  12396. * - VertexBuffer.MatricesIndicesExtraKind
  12397. * - VertexBuffer.MatricesWeightsKind
  12398. * - VertexBuffer.MatricesWeightsExtraKind
  12399. *
  12400. * Returns the Mesh.
  12401. */
  12402. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  12403. /**
  12404. * Sets the mesh indices.
  12405. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  12406. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  12407. * This method creates a new index buffer each call.
  12408. * Returns the Mesh.
  12409. */
  12410. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  12411. /**
  12412. * Boolean : True if the mesh owns the requested kind of data.
  12413. */
  12414. isVerticesDataPresent(kind: string): boolean;
  12415. /**
  12416. * Returns an array of indices (IndicesArray).
  12417. */
  12418. getIndices(): Nullable<IndicesArray>;
  12419. readonly _positions: Nullable<Vector3[]>;
  12420. /**
  12421. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  12422. * This means the mesh underlying bounding box and sphere are recomputed.
  12423. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  12424. * @returns the current mesh
  12425. */
  12426. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  12427. /** @hidden */
  12428. _preActivate(): InstancedMesh;
  12429. /** @hidden */
  12430. _activate(renderId: number, intermediateRendering: boolean): boolean;
  12431. /** @hidden */
  12432. _postActivate(): void;
  12433. getWorldMatrix(): Matrix;
  12434. readonly isAnInstance: boolean;
  12435. /**
  12436. * Returns the current associated LOD AbstractMesh.
  12437. */
  12438. getLOD(camera: Camera): AbstractMesh;
  12439. /** @hidden */
  12440. _syncSubMeshes(): InstancedMesh;
  12441. /** @hidden */
  12442. _generatePointsArray(): boolean;
  12443. /**
  12444. * Creates a new InstancedMesh from the current mesh.
  12445. * - name (string) : the cloned mesh name
  12446. * - newParent (optional Node) : the optional Node to parent the clone to.
  12447. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  12448. *
  12449. * Returns the clone.
  12450. */
  12451. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  12452. /**
  12453. * Disposes the InstancedMesh.
  12454. * Returns nothing.
  12455. */
  12456. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12457. }
  12458. }
  12459. declare module "babylonjs/Materials/shaderMaterial" {
  12460. import { Scene } from "babylonjs/scene";
  12461. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  12462. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12463. import { Mesh } from "babylonjs/Meshes/mesh";
  12464. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  12465. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12466. import { Texture } from "babylonjs/Materials/Textures/texture";
  12467. import { Material } from "babylonjs/Materials/material";
  12468. /**
  12469. * Defines the options associated with the creation of a shader material.
  12470. */
  12471. export interface IShaderMaterialOptions {
  12472. /**
  12473. * Does the material work in alpha blend mode
  12474. */
  12475. needAlphaBlending: boolean;
  12476. /**
  12477. * Does the material work in alpha test mode
  12478. */
  12479. needAlphaTesting: boolean;
  12480. /**
  12481. * The list of attribute names used in the shader
  12482. */
  12483. attributes: string[];
  12484. /**
  12485. * The list of unifrom names used in the shader
  12486. */
  12487. uniforms: string[];
  12488. /**
  12489. * The list of UBO names used in the shader
  12490. */
  12491. uniformBuffers: string[];
  12492. /**
  12493. * The list of sampler names used in the shader
  12494. */
  12495. samplers: string[];
  12496. /**
  12497. * The list of defines used in the shader
  12498. */
  12499. defines: string[];
  12500. }
  12501. /**
  12502. * 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.
  12503. *
  12504. * This returned material effects how the mesh will look based on the code in the shaders.
  12505. *
  12506. * @see http://doc.babylonjs.com/how_to/shader_material
  12507. */
  12508. export class ShaderMaterial extends Material {
  12509. private _shaderPath;
  12510. private _options;
  12511. private _textures;
  12512. private _textureArrays;
  12513. private _floats;
  12514. private _ints;
  12515. private _floatsArrays;
  12516. private _colors3;
  12517. private _colors3Arrays;
  12518. private _colors4;
  12519. private _colors4Arrays;
  12520. private _vectors2;
  12521. private _vectors3;
  12522. private _vectors4;
  12523. private _matrices;
  12524. private _matrices3x3;
  12525. private _matrices2x2;
  12526. private _vectors2Arrays;
  12527. private _vectors3Arrays;
  12528. private _vectors4Arrays;
  12529. private _cachedWorldViewMatrix;
  12530. private _cachedWorldViewProjectionMatrix;
  12531. private _renderId;
  12532. /**
  12533. * Instantiate a new shader material.
  12534. * 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.
  12535. * This returned material effects how the mesh will look based on the code in the shaders.
  12536. * @see http://doc.babylonjs.com/how_to/shader_material
  12537. * @param name Define the name of the material in the scene
  12538. * @param scene Define the scene the material belongs to
  12539. * @param shaderPath Defines the route to the shader code in one of three ways:
  12540. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  12541. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  12542. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  12543. * @param options Define the options used to create the shader
  12544. */
  12545. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  12546. /**
  12547. * Gets the options used to compile the shader.
  12548. * They can be modified to trigger a new compilation
  12549. */
  12550. readonly options: IShaderMaterialOptions;
  12551. /**
  12552. * Gets the current class name of the material e.g. "ShaderMaterial"
  12553. * Mainly use in serialization.
  12554. * @returns the class name
  12555. */
  12556. getClassName(): string;
  12557. /**
  12558. * Specifies if the material will require alpha blending
  12559. * @returns a boolean specifying if alpha blending is needed
  12560. */
  12561. needAlphaBlending(): boolean;
  12562. /**
  12563. * Specifies if this material should be rendered in alpha test mode
  12564. * @returns a boolean specifying if an alpha test is needed.
  12565. */
  12566. needAlphaTesting(): boolean;
  12567. private _checkUniform;
  12568. /**
  12569. * Set a texture in the shader.
  12570. * @param name Define the name of the uniform samplers as defined in the shader
  12571. * @param texture Define the texture to bind to this sampler
  12572. * @return the material itself allowing "fluent" like uniform updates
  12573. */
  12574. setTexture(name: string, texture: Texture): ShaderMaterial;
  12575. /**
  12576. * Set a texture array in the shader.
  12577. * @param name Define the name of the uniform sampler array as defined in the shader
  12578. * @param textures Define the list of textures to bind to this sampler
  12579. * @return the material itself allowing "fluent" like uniform updates
  12580. */
  12581. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  12582. /**
  12583. * Set a float in the shader.
  12584. * @param name Define the name of the uniform as defined in the shader
  12585. * @param value Define the value to give to the uniform
  12586. * @return the material itself allowing "fluent" like uniform updates
  12587. */
  12588. setFloat(name: string, value: number): ShaderMaterial;
  12589. /**
  12590. * Set a int in the shader.
  12591. * @param name Define the name of the uniform as defined in the shader
  12592. * @param value Define the value to give to the uniform
  12593. * @return the material itself allowing "fluent" like uniform updates
  12594. */
  12595. setInt(name: string, value: number): ShaderMaterial;
  12596. /**
  12597. * Set an array of floats in the shader.
  12598. * @param name Define the name of the uniform as defined in the shader
  12599. * @param value Define the value to give to the uniform
  12600. * @return the material itself allowing "fluent" like uniform updates
  12601. */
  12602. setFloats(name: string, value: number[]): ShaderMaterial;
  12603. /**
  12604. * Set a vec3 in the shader from a Color3.
  12605. * @param name Define the name of the uniform as defined in the shader
  12606. * @param value Define the value to give to the uniform
  12607. * @return the material itself allowing "fluent" like uniform updates
  12608. */
  12609. setColor3(name: string, value: Color3): ShaderMaterial;
  12610. /**
  12611. * Set a vec3 array in the shader from a Color3 array.
  12612. * @param name Define the name of the uniform as defined in the shader
  12613. * @param value Define the value to give to the uniform
  12614. * @return the material itself allowing "fluent" like uniform updates
  12615. */
  12616. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  12617. /**
  12618. * Set a vec4 in the shader from a Color4.
  12619. * @param name Define the name of the uniform as defined in the shader
  12620. * @param value Define the value to give to the uniform
  12621. * @return the material itself allowing "fluent" like uniform updates
  12622. */
  12623. setColor4(name: string, value: Color4): ShaderMaterial;
  12624. /**
  12625. * Set a vec4 array in the shader from a Color4 array.
  12626. * @param name Define the name of the uniform as defined in the shader
  12627. * @param value Define the value to give to the uniform
  12628. * @return the material itself allowing "fluent" like uniform updates
  12629. */
  12630. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  12631. /**
  12632. * Set a vec2 in the shader from a Vector2.
  12633. * @param name Define the name of the uniform as defined in the shader
  12634. * @param value Define the value to give to the uniform
  12635. * @return the material itself allowing "fluent" like uniform updates
  12636. */
  12637. setVector2(name: string, value: Vector2): ShaderMaterial;
  12638. /**
  12639. * Set a vec3 in the shader from a Vector3.
  12640. * @param name Define the name of the uniform as defined in the shader
  12641. * @param value Define the value to give to the uniform
  12642. * @return the material itself allowing "fluent" like uniform updates
  12643. */
  12644. setVector3(name: string, value: Vector3): ShaderMaterial;
  12645. /**
  12646. * Set a vec4 in the shader from a Vector4.
  12647. * @param name Define the name of the uniform as defined in the shader
  12648. * @param value Define the value to give to the uniform
  12649. * @return the material itself allowing "fluent" like uniform updates
  12650. */
  12651. setVector4(name: string, value: Vector4): ShaderMaterial;
  12652. /**
  12653. * Set a mat4 in the shader from a Matrix.
  12654. * @param name Define the name of the uniform as defined in the shader
  12655. * @param value Define the value to give to the uniform
  12656. * @return the material itself allowing "fluent" like uniform updates
  12657. */
  12658. setMatrix(name: string, value: Matrix): ShaderMaterial;
  12659. /**
  12660. * Set a mat3 in the shader from a Float32Array.
  12661. * @param name Define the name of the uniform as defined in the shader
  12662. * @param value Define the value to give to the uniform
  12663. * @return the material itself allowing "fluent" like uniform updates
  12664. */
  12665. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  12666. /**
  12667. * Set a mat2 in the shader from a Float32Array.
  12668. * @param name Define the name of the uniform as defined in the shader
  12669. * @param value Define the value to give to the uniform
  12670. * @return the material itself allowing "fluent" like uniform updates
  12671. */
  12672. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  12673. /**
  12674. * Set a vec2 array in the shader from a number array.
  12675. * @param name Define the name of the uniform as defined in the shader
  12676. * @param value Define the value to give to the uniform
  12677. * @return the material itself allowing "fluent" like uniform updates
  12678. */
  12679. setArray2(name: string, value: number[]): ShaderMaterial;
  12680. /**
  12681. * Set a vec3 array in the shader from a number array.
  12682. * @param name Define the name of the uniform as defined in the shader
  12683. * @param value Define the value to give to the uniform
  12684. * @return the material itself allowing "fluent" like uniform updates
  12685. */
  12686. setArray3(name: string, value: number[]): ShaderMaterial;
  12687. /**
  12688. * Set a vec4 array in the shader from a number array.
  12689. * @param name Define the name of the uniform as defined in the shader
  12690. * @param value Define the value to give to the uniform
  12691. * @return the material itself allowing "fluent" like uniform updates
  12692. */
  12693. setArray4(name: string, value: number[]): ShaderMaterial;
  12694. private _checkCache;
  12695. /**
  12696. * Specifies that the submesh is ready to be used
  12697. * @param mesh defines the mesh to check
  12698. * @param subMesh defines which submesh to check
  12699. * @param useInstances specifies that instances should be used
  12700. * @returns a boolean indicating that the submesh is ready or not
  12701. */
  12702. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  12703. /**
  12704. * Checks if the material is ready to render the requested mesh
  12705. * @param mesh Define the mesh to render
  12706. * @param useInstances Define whether or not the material is used with instances
  12707. * @returns true if ready, otherwise false
  12708. */
  12709. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  12710. /**
  12711. * Binds the world matrix to the material
  12712. * @param world defines the world transformation matrix
  12713. */
  12714. bindOnlyWorldMatrix(world: Matrix): void;
  12715. /**
  12716. * Binds the material to the mesh
  12717. * @param world defines the world transformation matrix
  12718. * @param mesh defines the mesh to bind the material to
  12719. */
  12720. bind(world: Matrix, mesh?: Mesh): void;
  12721. /**
  12722. * Gets the active textures from the material
  12723. * @returns an array of textures
  12724. */
  12725. getActiveTextures(): BaseTexture[];
  12726. /**
  12727. * Specifies if the material uses a texture
  12728. * @param texture defines the texture to check against the material
  12729. * @returns a boolean specifying if the material uses the texture
  12730. */
  12731. hasTexture(texture: BaseTexture): boolean;
  12732. /**
  12733. * Makes a duplicate of the material, and gives it a new name
  12734. * @param name defines the new name for the duplicated material
  12735. * @returns the cloned material
  12736. */
  12737. clone(name: string): ShaderMaterial;
  12738. /**
  12739. * Disposes the material
  12740. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  12741. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  12742. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  12743. */
  12744. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  12745. /**
  12746. * Serializes this material in a JSON representation
  12747. * @returns the serialized material object
  12748. */
  12749. serialize(): any;
  12750. /**
  12751. * Creates a shader material from parsed shader material data
  12752. * @param source defines the JSON represnetation of the material
  12753. * @param scene defines the hosting scene
  12754. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  12755. * @returns a new material
  12756. */
  12757. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  12758. }
  12759. }
  12760. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  12761. /** @hidden */
  12762. export var clipPlaneFragmentDeclaration: {
  12763. name: string;
  12764. shader: string;
  12765. };
  12766. }
  12767. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  12768. /** @hidden */
  12769. export var clipPlaneFragment: {
  12770. name: string;
  12771. shader: string;
  12772. };
  12773. }
  12774. declare module "babylonjs/Shaders/color.fragment" {
  12775. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12776. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12777. /** @hidden */
  12778. export var colorPixelShader: {
  12779. name: string;
  12780. shader: string;
  12781. };
  12782. }
  12783. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  12784. /** @hidden */
  12785. export var clipPlaneVertexDeclaration: {
  12786. name: string;
  12787. shader: string;
  12788. };
  12789. }
  12790. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  12791. /** @hidden */
  12792. export var clipPlaneVertex: {
  12793. name: string;
  12794. shader: string;
  12795. };
  12796. }
  12797. declare module "babylonjs/Shaders/color.vertex" {
  12798. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  12799. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12800. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  12801. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  12802. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  12803. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12804. /** @hidden */
  12805. export var colorVertexShader: {
  12806. name: string;
  12807. shader: string;
  12808. };
  12809. }
  12810. declare module "babylonjs/Meshes/linesMesh" {
  12811. import { Nullable } from "babylonjs/types";
  12812. import { Scene } from "babylonjs/scene";
  12813. import { Color3 } from "babylonjs/Maths/math";
  12814. import { Node } from "babylonjs/node";
  12815. import { SubMesh } from "babylonjs/Meshes/subMesh";
  12816. import { Mesh } from "babylonjs/Meshes/mesh";
  12817. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  12818. import { Effect } from "babylonjs/Materials/effect";
  12819. import { Material } from "babylonjs/Materials/material";
  12820. import "babylonjs/Shaders/color.fragment";
  12821. import "babylonjs/Shaders/color.vertex";
  12822. /**
  12823. * Line mesh
  12824. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  12825. */
  12826. export class LinesMesh extends Mesh {
  12827. /**
  12828. * If vertex color should be applied to the mesh
  12829. */
  12830. readonly useVertexColor?: boolean | undefined;
  12831. /**
  12832. * If vertex alpha should be applied to the mesh
  12833. */
  12834. readonly useVertexAlpha?: boolean | undefined;
  12835. /**
  12836. * Color of the line (Default: White)
  12837. */
  12838. color: Color3;
  12839. /**
  12840. * Alpha of the line (Default: 1)
  12841. */
  12842. alpha: number;
  12843. /**
  12844. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12845. * This margin is expressed in world space coordinates, so its value may vary.
  12846. * Default value is 0.1
  12847. */
  12848. intersectionThreshold: number;
  12849. private _colorShader;
  12850. private color4;
  12851. /**
  12852. * Creates a new LinesMesh
  12853. * @param name defines the name
  12854. * @param scene defines the hosting scene
  12855. * @param parent defines the parent mesh if any
  12856. * @param source defines the optional source LinesMesh used to clone data from
  12857. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  12858. * When false, achieved by calling a clone(), also passing False.
  12859. * This will make creation of children, recursive.
  12860. * @param useVertexColor defines if this LinesMesh supports vertex color
  12861. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  12862. */
  12863. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  12864. /**
  12865. * If vertex color should be applied to the mesh
  12866. */
  12867. useVertexColor?: boolean | undefined,
  12868. /**
  12869. * If vertex alpha should be applied to the mesh
  12870. */
  12871. useVertexAlpha?: boolean | undefined);
  12872. private _addClipPlaneDefine;
  12873. private _removeClipPlaneDefine;
  12874. isReady(): boolean;
  12875. /**
  12876. * Returns the string "LineMesh"
  12877. */
  12878. getClassName(): string;
  12879. /**
  12880. * @hidden
  12881. */
  12882. /**
  12883. * @hidden
  12884. */
  12885. material: Material;
  12886. /**
  12887. * @hidden
  12888. */
  12889. readonly checkCollisions: boolean;
  12890. /** @hidden */
  12891. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  12892. /** @hidden */
  12893. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  12894. /**
  12895. * Disposes of the line mesh
  12896. * @param doNotRecurse If children should be disposed
  12897. */
  12898. dispose(doNotRecurse?: boolean): void;
  12899. /**
  12900. * Returns a new LineMesh object cloned from the current one.
  12901. */
  12902. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  12903. /**
  12904. * Creates a new InstancedLinesMesh object from the mesh model.
  12905. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  12906. * @param name defines the name of the new instance
  12907. * @returns a new InstancedLinesMesh
  12908. */
  12909. createInstance(name: string): InstancedLinesMesh;
  12910. }
  12911. /**
  12912. * Creates an instance based on a source LinesMesh
  12913. */
  12914. export class InstancedLinesMesh extends InstancedMesh {
  12915. /**
  12916. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12917. * This margin is expressed in world space coordinates, so its value may vary.
  12918. * Initilized with the intersectionThreshold value of the source LinesMesh
  12919. */
  12920. intersectionThreshold: number;
  12921. constructor(name: string, source: LinesMesh);
  12922. /**
  12923. * Returns the string "InstancedLinesMesh".
  12924. */
  12925. getClassName(): string;
  12926. }
  12927. }
  12928. declare module "babylonjs/Meshes/groundMesh" {
  12929. import { Scene } from "babylonjs/scene";
  12930. import { Vector3 } from "babylonjs/Maths/math";
  12931. import { Mesh } from "babylonjs/Meshes/mesh";
  12932. /**
  12933. * Mesh representing the gorund
  12934. */
  12935. export class GroundMesh extends Mesh {
  12936. /** If octree should be generated */
  12937. generateOctree: boolean;
  12938. private _heightQuads;
  12939. /** @hidden */
  12940. _subdivisionsX: number;
  12941. /** @hidden */
  12942. _subdivisionsY: number;
  12943. /** @hidden */
  12944. _width: number;
  12945. /** @hidden */
  12946. _height: number;
  12947. /** @hidden */
  12948. _minX: number;
  12949. /** @hidden */
  12950. _maxX: number;
  12951. /** @hidden */
  12952. _minZ: number;
  12953. /** @hidden */
  12954. _maxZ: number;
  12955. constructor(name: string, scene: Scene);
  12956. /**
  12957. * "GroundMesh"
  12958. * @returns "GroundMesh"
  12959. */
  12960. getClassName(): string;
  12961. /**
  12962. * The minimum of x and y subdivisions
  12963. */
  12964. readonly subdivisions: number;
  12965. /**
  12966. * X subdivisions
  12967. */
  12968. readonly subdivisionsX: number;
  12969. /**
  12970. * Y subdivisions
  12971. */
  12972. readonly subdivisionsY: number;
  12973. /**
  12974. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  12975. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  12976. * @param chunksCount the number of subdivisions for x and y
  12977. * @param octreeBlocksSize (Default: 32)
  12978. */
  12979. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  12980. /**
  12981. * Returns a height (y) value in the Worl system :
  12982. * the ground altitude at the coordinates (x, z) expressed in the World system.
  12983. * @param x x coordinate
  12984. * @param z z coordinate
  12985. * @returns the ground y position if (x, z) are outside the ground surface.
  12986. */
  12987. getHeightAtCoordinates(x: number, z: number): number;
  12988. /**
  12989. * Returns a normalized vector (Vector3) orthogonal to the ground
  12990. * at the ground coordinates (x, z) expressed in the World system.
  12991. * @param x x coordinate
  12992. * @param z z coordinate
  12993. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  12994. */
  12995. getNormalAtCoordinates(x: number, z: number): Vector3;
  12996. /**
  12997. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  12998. * at the ground coordinates (x, z) expressed in the World system.
  12999. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  13000. * @param x x coordinate
  13001. * @param z z coordinate
  13002. * @param ref vector to store the result
  13003. * @returns the GroundMesh.
  13004. */
  13005. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  13006. /**
  13007. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  13008. * if the ground has been updated.
  13009. * This can be used in the render loop.
  13010. * @returns the GroundMesh.
  13011. */
  13012. updateCoordinateHeights(): GroundMesh;
  13013. private _getFacetAt;
  13014. private _initHeightQuads;
  13015. private _computeHeightQuads;
  13016. /**
  13017. * Serializes this ground mesh
  13018. * @param serializationObject object to write serialization to
  13019. */
  13020. serialize(serializationObject: any): void;
  13021. /**
  13022. * Parses a serialized ground mesh
  13023. * @param parsedMesh the serialized mesh
  13024. * @param scene the scene to create the ground mesh in
  13025. * @returns the created ground mesh
  13026. */
  13027. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  13028. }
  13029. }
  13030. declare module "babylonjs/Physics/physicsJoint" {
  13031. import { Vector3 } from "babylonjs/Maths/math";
  13032. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  13033. /**
  13034. * Interface for Physics-Joint data
  13035. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13036. */
  13037. export interface PhysicsJointData {
  13038. /**
  13039. * The main pivot of the joint
  13040. */
  13041. mainPivot?: Vector3;
  13042. /**
  13043. * The connected pivot of the joint
  13044. */
  13045. connectedPivot?: Vector3;
  13046. /**
  13047. * The main axis of the joint
  13048. */
  13049. mainAxis?: Vector3;
  13050. /**
  13051. * The connected axis of the joint
  13052. */
  13053. connectedAxis?: Vector3;
  13054. /**
  13055. * The collision of the joint
  13056. */
  13057. collision?: boolean;
  13058. /**
  13059. * Native Oimo/Cannon/Energy data
  13060. */
  13061. nativeParams?: any;
  13062. }
  13063. /**
  13064. * This is a holder class for the physics joint created by the physics plugin
  13065. * It holds a set of functions to control the underlying joint
  13066. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13067. */
  13068. export class PhysicsJoint {
  13069. /**
  13070. * The type of the physics joint
  13071. */
  13072. type: number;
  13073. /**
  13074. * The data for the physics joint
  13075. */
  13076. jointData: PhysicsJointData;
  13077. private _physicsJoint;
  13078. protected _physicsPlugin: IPhysicsEnginePlugin;
  13079. /**
  13080. * Initializes the physics joint
  13081. * @param type The type of the physics joint
  13082. * @param jointData The data for the physics joint
  13083. */
  13084. constructor(
  13085. /**
  13086. * The type of the physics joint
  13087. */
  13088. type: number,
  13089. /**
  13090. * The data for the physics joint
  13091. */
  13092. jointData: PhysicsJointData);
  13093. /**
  13094. * Gets the physics joint
  13095. */
  13096. /**
  13097. * Sets the physics joint
  13098. */
  13099. physicsJoint: any;
  13100. /**
  13101. * Sets the physics plugin
  13102. */
  13103. physicsPlugin: IPhysicsEnginePlugin;
  13104. /**
  13105. * Execute a function that is physics-plugin specific.
  13106. * @param {Function} func the function that will be executed.
  13107. * It accepts two parameters: the physics world and the physics joint
  13108. */
  13109. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  13110. /**
  13111. * Distance-Joint type
  13112. */
  13113. static DistanceJoint: number;
  13114. /**
  13115. * Hinge-Joint type
  13116. */
  13117. static HingeJoint: number;
  13118. /**
  13119. * Ball-and-Socket joint type
  13120. */
  13121. static BallAndSocketJoint: number;
  13122. /**
  13123. * Wheel-Joint type
  13124. */
  13125. static WheelJoint: number;
  13126. /**
  13127. * Slider-Joint type
  13128. */
  13129. static SliderJoint: number;
  13130. /**
  13131. * Prismatic-Joint type
  13132. */
  13133. static PrismaticJoint: number;
  13134. /**
  13135. * Universal-Joint type
  13136. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  13137. */
  13138. static UniversalJoint: number;
  13139. /**
  13140. * Hinge-Joint 2 type
  13141. */
  13142. static Hinge2Joint: number;
  13143. /**
  13144. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  13145. */
  13146. static PointToPointJoint: number;
  13147. /**
  13148. * Spring-Joint type
  13149. */
  13150. static SpringJoint: number;
  13151. /**
  13152. * Lock-Joint type
  13153. */
  13154. static LockJoint: number;
  13155. }
  13156. /**
  13157. * A class representing a physics distance joint
  13158. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13159. */
  13160. export class DistanceJoint extends PhysicsJoint {
  13161. /**
  13162. *
  13163. * @param jointData The data for the Distance-Joint
  13164. */
  13165. constructor(jointData: DistanceJointData);
  13166. /**
  13167. * Update the predefined distance.
  13168. * @param maxDistance The maximum preferred distance
  13169. * @param minDistance The minimum preferred distance
  13170. */
  13171. updateDistance(maxDistance: number, minDistance?: number): void;
  13172. }
  13173. /**
  13174. * Represents a Motor-Enabled Joint
  13175. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13176. */
  13177. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  13178. /**
  13179. * Initializes the Motor-Enabled Joint
  13180. * @param type The type of the joint
  13181. * @param jointData The physica joint data for the joint
  13182. */
  13183. constructor(type: number, jointData: PhysicsJointData);
  13184. /**
  13185. * Set the motor values.
  13186. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13187. * @param force the force to apply
  13188. * @param maxForce max force for this motor.
  13189. */
  13190. setMotor(force?: number, maxForce?: number): void;
  13191. /**
  13192. * Set the motor's limits.
  13193. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13194. * @param upperLimit The upper limit of the motor
  13195. * @param lowerLimit The lower limit of the motor
  13196. */
  13197. setLimit(upperLimit: number, lowerLimit?: number): void;
  13198. }
  13199. /**
  13200. * This class represents a single physics Hinge-Joint
  13201. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13202. */
  13203. export class HingeJoint extends MotorEnabledJoint {
  13204. /**
  13205. * Initializes the Hinge-Joint
  13206. * @param jointData The joint data for the Hinge-Joint
  13207. */
  13208. constructor(jointData: PhysicsJointData);
  13209. /**
  13210. * Set the motor values.
  13211. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13212. * @param {number} force the force to apply
  13213. * @param {number} maxForce max force for this motor.
  13214. */
  13215. setMotor(force?: number, maxForce?: number): void;
  13216. /**
  13217. * Set the motor's limits.
  13218. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13219. * @param upperLimit The upper limit of the motor
  13220. * @param lowerLimit The lower limit of the motor
  13221. */
  13222. setLimit(upperLimit: number, lowerLimit?: number): void;
  13223. }
  13224. /**
  13225. * This class represents a dual hinge physics joint (same as wheel joint)
  13226. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13227. */
  13228. export class Hinge2Joint extends MotorEnabledJoint {
  13229. /**
  13230. * Initializes the Hinge2-Joint
  13231. * @param jointData The joint data for the Hinge2-Joint
  13232. */
  13233. constructor(jointData: PhysicsJointData);
  13234. /**
  13235. * Set the motor values.
  13236. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13237. * @param {number} targetSpeed the speed the motor is to reach
  13238. * @param {number} maxForce max force for this motor.
  13239. * @param {motorIndex} the motor's index, 0 or 1.
  13240. */
  13241. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  13242. /**
  13243. * Set the motor limits.
  13244. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13245. * @param {number} upperLimit the upper limit
  13246. * @param {number} lowerLimit lower limit
  13247. * @param {motorIndex} the motor's index, 0 or 1.
  13248. */
  13249. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13250. }
  13251. /**
  13252. * Interface for a motor enabled joint
  13253. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13254. */
  13255. export interface IMotorEnabledJoint {
  13256. /**
  13257. * Physics joint
  13258. */
  13259. physicsJoint: any;
  13260. /**
  13261. * Sets the motor of the motor-enabled joint
  13262. * @param force The force of the motor
  13263. * @param maxForce The maximum force of the motor
  13264. * @param motorIndex The index of the motor
  13265. */
  13266. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  13267. /**
  13268. * Sets the limit of the motor
  13269. * @param upperLimit The upper limit of the motor
  13270. * @param lowerLimit The lower limit of the motor
  13271. * @param motorIndex The index of the motor
  13272. */
  13273. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13274. }
  13275. /**
  13276. * Joint data for a Distance-Joint
  13277. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13278. */
  13279. export interface DistanceJointData extends PhysicsJointData {
  13280. /**
  13281. * Max distance the 2 joint objects can be apart
  13282. */
  13283. maxDistance: number;
  13284. }
  13285. /**
  13286. * Joint data from a spring joint
  13287. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13288. */
  13289. export interface SpringJointData extends PhysicsJointData {
  13290. /**
  13291. * Length of the spring
  13292. */
  13293. length: number;
  13294. /**
  13295. * Stiffness of the spring
  13296. */
  13297. stiffness: number;
  13298. /**
  13299. * Damping of the spring
  13300. */
  13301. damping: number;
  13302. /** this callback will be called when applying the force to the impostors. */
  13303. forceApplicationCallback: () => void;
  13304. }
  13305. }
  13306. declare module "babylonjs/Physics/physicsRaycastResult" {
  13307. import { Vector3 } from "babylonjs/Maths/math";
  13308. /**
  13309. * Holds the data for the raycast result
  13310. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13311. */
  13312. export class PhysicsRaycastResult {
  13313. private _hasHit;
  13314. private _hitDistance;
  13315. private _hitNormalWorld;
  13316. private _hitPointWorld;
  13317. private _rayFromWorld;
  13318. private _rayToWorld;
  13319. /**
  13320. * Gets if there was a hit
  13321. */
  13322. readonly hasHit: boolean;
  13323. /**
  13324. * Gets the distance from the hit
  13325. */
  13326. readonly hitDistance: number;
  13327. /**
  13328. * Gets the hit normal/direction in the world
  13329. */
  13330. readonly hitNormalWorld: Vector3;
  13331. /**
  13332. * Gets the hit point in the world
  13333. */
  13334. readonly hitPointWorld: Vector3;
  13335. /**
  13336. * Gets the ray "start point" of the ray in the world
  13337. */
  13338. readonly rayFromWorld: Vector3;
  13339. /**
  13340. * Gets the ray "end point" of the ray in the world
  13341. */
  13342. readonly rayToWorld: Vector3;
  13343. /**
  13344. * Sets the hit data (normal & point in world space)
  13345. * @param hitNormalWorld defines the normal in world space
  13346. * @param hitPointWorld defines the point in world space
  13347. */
  13348. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  13349. /**
  13350. * Sets the distance from the start point to the hit point
  13351. * @param distance
  13352. */
  13353. setHitDistance(distance: number): void;
  13354. /**
  13355. * Calculates the distance manually
  13356. */
  13357. calculateHitDistance(): void;
  13358. /**
  13359. * Resets all the values to default
  13360. * @param from The from point on world space
  13361. * @param to The to point on world space
  13362. */
  13363. reset(from?: Vector3, to?: Vector3): void;
  13364. }
  13365. /**
  13366. * Interface for the size containing width and height
  13367. */
  13368. interface IXYZ {
  13369. /**
  13370. * X
  13371. */
  13372. x: number;
  13373. /**
  13374. * Y
  13375. */
  13376. y: number;
  13377. /**
  13378. * Z
  13379. */
  13380. z: number;
  13381. }
  13382. }
  13383. declare module "babylonjs/Physics/IPhysicsEngine" {
  13384. import { Nullable } from "babylonjs/types";
  13385. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  13386. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13387. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  13388. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  13389. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  13390. /**
  13391. * Interface used to describe a physics joint
  13392. */
  13393. export interface PhysicsImpostorJoint {
  13394. /** Defines the main impostor to which the joint is linked */
  13395. mainImpostor: PhysicsImpostor;
  13396. /** Defines the impostor that is connected to the main impostor using this joint */
  13397. connectedImpostor: PhysicsImpostor;
  13398. /** Defines the joint itself */
  13399. joint: PhysicsJoint;
  13400. }
  13401. /** @hidden */
  13402. export interface IPhysicsEnginePlugin {
  13403. world: any;
  13404. name: string;
  13405. setGravity(gravity: Vector3): void;
  13406. setTimeStep(timeStep: number): void;
  13407. getTimeStep(): number;
  13408. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  13409. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13410. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13411. generatePhysicsBody(impostor: PhysicsImpostor): void;
  13412. removePhysicsBody(impostor: PhysicsImpostor): void;
  13413. generateJoint(joint: PhysicsImpostorJoint): void;
  13414. removeJoint(joint: PhysicsImpostorJoint): void;
  13415. isSupported(): boolean;
  13416. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  13417. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  13418. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13419. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13420. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13421. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13422. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  13423. getBodyMass(impostor: PhysicsImpostor): number;
  13424. getBodyFriction(impostor: PhysicsImpostor): number;
  13425. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  13426. getBodyRestitution(impostor: PhysicsImpostor): number;
  13427. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  13428. getBodyPressure?(impostor: PhysicsImpostor): number;
  13429. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  13430. getBodyStiffness?(impostor: PhysicsImpostor): number;
  13431. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  13432. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  13433. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  13434. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  13435. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  13436. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13437. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13438. sleepBody(impostor: PhysicsImpostor): void;
  13439. wakeUpBody(impostor: PhysicsImpostor): void;
  13440. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13441. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  13442. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  13443. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13444. getRadius(impostor: PhysicsImpostor): number;
  13445. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  13446. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  13447. dispose(): void;
  13448. }
  13449. /**
  13450. * Interface used to define a physics engine
  13451. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  13452. */
  13453. export interface IPhysicsEngine {
  13454. /**
  13455. * Gets the gravity vector used by the simulation
  13456. */
  13457. gravity: Vector3;
  13458. /**
  13459. * Sets the gravity vector used by the simulation
  13460. * @param gravity defines the gravity vector to use
  13461. */
  13462. setGravity(gravity: Vector3): void;
  13463. /**
  13464. * Set the time step of the physics engine.
  13465. * Default is 1/60.
  13466. * To slow it down, enter 1/600 for example.
  13467. * To speed it up, 1/30
  13468. * @param newTimeStep the new timestep to apply to this world.
  13469. */
  13470. setTimeStep(newTimeStep: number): void;
  13471. /**
  13472. * Get the time step of the physics engine.
  13473. * @returns the current time step
  13474. */
  13475. getTimeStep(): number;
  13476. /**
  13477. * Release all resources
  13478. */
  13479. dispose(): void;
  13480. /**
  13481. * Gets the name of the current physics plugin
  13482. * @returns the name of the plugin
  13483. */
  13484. getPhysicsPluginName(): string;
  13485. /**
  13486. * Adding a new impostor for the impostor tracking.
  13487. * This will be done by the impostor itself.
  13488. * @param impostor the impostor to add
  13489. */
  13490. addImpostor(impostor: PhysicsImpostor): void;
  13491. /**
  13492. * Remove an impostor from the engine.
  13493. * This impostor and its mesh will not longer be updated by the physics engine.
  13494. * @param impostor the impostor to remove
  13495. */
  13496. removeImpostor(impostor: PhysicsImpostor): void;
  13497. /**
  13498. * Add a joint to the physics engine
  13499. * @param mainImpostor defines the main impostor to which the joint is added.
  13500. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  13501. * @param joint defines the joint that will connect both impostors.
  13502. */
  13503. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13504. /**
  13505. * Removes a joint from the simulation
  13506. * @param mainImpostor defines the impostor used with the joint
  13507. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  13508. * @param joint defines the joint to remove
  13509. */
  13510. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13511. /**
  13512. * Gets the current plugin used to run the simulation
  13513. * @returns current plugin
  13514. */
  13515. getPhysicsPlugin(): IPhysicsEnginePlugin;
  13516. /**
  13517. * Gets the list of physic impostors
  13518. * @returns an array of PhysicsImpostor
  13519. */
  13520. getImpostors(): Array<PhysicsImpostor>;
  13521. /**
  13522. * Gets the impostor for a physics enabled object
  13523. * @param object defines the object impersonated by the impostor
  13524. * @returns the PhysicsImpostor or null if not found
  13525. */
  13526. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13527. /**
  13528. * Gets the impostor for a physics body object
  13529. * @param body defines physics body used by the impostor
  13530. * @returns the PhysicsImpostor or null if not found
  13531. */
  13532. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  13533. /**
  13534. * Does a raycast in the physics world
  13535. * @param from when should the ray start?
  13536. * @param to when should the ray end?
  13537. * @returns PhysicsRaycastResult
  13538. */
  13539. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13540. /**
  13541. * Called by the scene. No need to call it.
  13542. * @param delta defines the timespam between frames
  13543. */
  13544. _step(delta: number): void;
  13545. }
  13546. }
  13547. declare module "babylonjs/Physics/physicsImpostor" {
  13548. import { Nullable, IndicesArray } from "babylonjs/types";
  13549. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  13550. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13552. import { Scene } from "babylonjs/scene";
  13553. import { Bone } from "babylonjs/Bones/bone";
  13554. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  13555. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  13556. /**
  13557. * The interface for the physics imposter parameters
  13558. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13559. */
  13560. export interface PhysicsImpostorParameters {
  13561. /**
  13562. * The mass of the physics imposter
  13563. */
  13564. mass: number;
  13565. /**
  13566. * The friction of the physics imposter
  13567. */
  13568. friction?: number;
  13569. /**
  13570. * The coefficient of restitution of the physics imposter
  13571. */
  13572. restitution?: number;
  13573. /**
  13574. * The native options of the physics imposter
  13575. */
  13576. nativeOptions?: any;
  13577. /**
  13578. * Specifies if the parent should be ignored
  13579. */
  13580. ignoreParent?: boolean;
  13581. /**
  13582. * Specifies if bi-directional transformations should be disabled
  13583. */
  13584. disableBidirectionalTransformation?: boolean;
  13585. /**
  13586. * The pressure inside the physics imposter, soft object only
  13587. */
  13588. pressure?: number;
  13589. /**
  13590. * The stiffness the physics imposter, soft object only
  13591. */
  13592. stiffness?: number;
  13593. /**
  13594. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  13595. */
  13596. velocityIterations?: number;
  13597. /**
  13598. * The number of iterations used in maintaining consistent vertex positions, soft object only
  13599. */
  13600. positionIterations?: number;
  13601. /**
  13602. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  13603. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  13604. * Add to fix multiple points
  13605. */
  13606. fixedPoints?: number;
  13607. /**
  13608. * The collision margin around a soft object
  13609. */
  13610. margin?: number;
  13611. /**
  13612. * The collision margin around a soft object
  13613. */
  13614. damping?: number;
  13615. /**
  13616. * The path for a rope based on an extrusion
  13617. */
  13618. path?: any;
  13619. /**
  13620. * The shape of an extrusion used for a rope based on an extrusion
  13621. */
  13622. shape?: any;
  13623. }
  13624. /**
  13625. * Interface for a physics-enabled object
  13626. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13627. */
  13628. export interface IPhysicsEnabledObject {
  13629. /**
  13630. * The position of the physics-enabled object
  13631. */
  13632. position: Vector3;
  13633. /**
  13634. * The rotation of the physics-enabled object
  13635. */
  13636. rotationQuaternion: Nullable<Quaternion>;
  13637. /**
  13638. * The scale of the physics-enabled object
  13639. */
  13640. scaling: Vector3;
  13641. /**
  13642. * The rotation of the physics-enabled object
  13643. */
  13644. rotation?: Vector3;
  13645. /**
  13646. * The parent of the physics-enabled object
  13647. */
  13648. parent?: any;
  13649. /**
  13650. * The bounding info of the physics-enabled object
  13651. * @returns The bounding info of the physics-enabled object
  13652. */
  13653. getBoundingInfo(): BoundingInfo;
  13654. /**
  13655. * Computes the world matrix
  13656. * @param force Specifies if the world matrix should be computed by force
  13657. * @returns A world matrix
  13658. */
  13659. computeWorldMatrix(force: boolean): Matrix;
  13660. /**
  13661. * Gets the world matrix
  13662. * @returns A world matrix
  13663. */
  13664. getWorldMatrix?(): Matrix;
  13665. /**
  13666. * Gets the child meshes
  13667. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  13668. * @returns An array of abstract meshes
  13669. */
  13670. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  13671. /**
  13672. * Gets the vertex data
  13673. * @param kind The type of vertex data
  13674. * @returns A nullable array of numbers, or a float32 array
  13675. */
  13676. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  13677. /**
  13678. * Gets the indices from the mesh
  13679. * @returns A nullable array of index arrays
  13680. */
  13681. getIndices?(): Nullable<IndicesArray>;
  13682. /**
  13683. * Gets the scene from the mesh
  13684. * @returns the indices array or null
  13685. */
  13686. getScene?(): Scene;
  13687. /**
  13688. * Gets the absolute position from the mesh
  13689. * @returns the absolute position
  13690. */
  13691. getAbsolutePosition(): Vector3;
  13692. /**
  13693. * Gets the absolute pivot point from the mesh
  13694. * @returns the absolute pivot point
  13695. */
  13696. getAbsolutePivotPoint(): Vector3;
  13697. /**
  13698. * Rotates the mesh
  13699. * @param axis The axis of rotation
  13700. * @param amount The amount of rotation
  13701. * @param space The space of the rotation
  13702. * @returns The rotation transform node
  13703. */
  13704. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13705. /**
  13706. * Translates the mesh
  13707. * @param axis The axis of translation
  13708. * @param distance The distance of translation
  13709. * @param space The space of the translation
  13710. * @returns The transform node
  13711. */
  13712. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13713. /**
  13714. * Sets the absolute position of the mesh
  13715. * @param absolutePosition The absolute position of the mesh
  13716. * @returns The transform node
  13717. */
  13718. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13719. /**
  13720. * Gets the class name of the mesh
  13721. * @returns The class name
  13722. */
  13723. getClassName(): string;
  13724. }
  13725. /**
  13726. * Represents a physics imposter
  13727. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13728. */
  13729. export class PhysicsImpostor {
  13730. /**
  13731. * The physics-enabled object used as the physics imposter
  13732. */
  13733. object: IPhysicsEnabledObject;
  13734. /**
  13735. * The type of the physics imposter
  13736. */
  13737. type: number;
  13738. private _options;
  13739. private _scene?;
  13740. /**
  13741. * The default object size of the imposter
  13742. */
  13743. static DEFAULT_OBJECT_SIZE: Vector3;
  13744. /**
  13745. * The identity quaternion of the imposter
  13746. */
  13747. static IDENTITY_QUATERNION: Quaternion;
  13748. /** @hidden */
  13749. _pluginData: any;
  13750. private _physicsEngine;
  13751. private _physicsBody;
  13752. private _bodyUpdateRequired;
  13753. private _onBeforePhysicsStepCallbacks;
  13754. private _onAfterPhysicsStepCallbacks;
  13755. /** @hidden */
  13756. _onPhysicsCollideCallbacks: Array<{
  13757. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  13758. otherImpostors: Array<PhysicsImpostor>;
  13759. }>;
  13760. private _deltaPosition;
  13761. private _deltaRotation;
  13762. private _deltaRotationConjugated;
  13763. /** @hidden */
  13764. _isFromLine: boolean;
  13765. private _parent;
  13766. private _isDisposed;
  13767. private static _tmpVecs;
  13768. private static _tmpQuat;
  13769. /**
  13770. * Specifies if the physics imposter is disposed
  13771. */
  13772. readonly isDisposed: boolean;
  13773. /**
  13774. * Gets the mass of the physics imposter
  13775. */
  13776. mass: number;
  13777. /**
  13778. * Gets the coefficient of friction
  13779. */
  13780. /**
  13781. * Sets the coefficient of friction
  13782. */
  13783. friction: number;
  13784. /**
  13785. * Gets the coefficient of restitution
  13786. */
  13787. /**
  13788. * Sets the coefficient of restitution
  13789. */
  13790. restitution: number;
  13791. /**
  13792. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  13793. */
  13794. /**
  13795. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  13796. */
  13797. pressure: number;
  13798. /**
  13799. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13800. */
  13801. /**
  13802. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13803. */
  13804. stiffness: number;
  13805. /**
  13806. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13807. */
  13808. /**
  13809. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13810. */
  13811. velocityIterations: number;
  13812. /**
  13813. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13814. */
  13815. /**
  13816. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13817. */
  13818. positionIterations: number;
  13819. /**
  13820. * The unique id of the physics imposter
  13821. * set by the physics engine when adding this impostor to the array
  13822. */
  13823. uniqueId: number;
  13824. /**
  13825. * @hidden
  13826. */
  13827. soft: boolean;
  13828. /**
  13829. * @hidden
  13830. */
  13831. segments: number;
  13832. private _joints;
  13833. /**
  13834. * Initializes the physics imposter
  13835. * @param object The physics-enabled object used as the physics imposter
  13836. * @param type The type of the physics imposter
  13837. * @param _options The options for the physics imposter
  13838. * @param _scene The Babylon scene
  13839. */
  13840. constructor(
  13841. /**
  13842. * The physics-enabled object used as the physics imposter
  13843. */
  13844. object: IPhysicsEnabledObject,
  13845. /**
  13846. * The type of the physics imposter
  13847. */
  13848. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  13849. /**
  13850. * This function will completly initialize this impostor.
  13851. * It will create a new body - but only if this mesh has no parent.
  13852. * If it has, this impostor will not be used other than to define the impostor
  13853. * of the child mesh.
  13854. * @hidden
  13855. */
  13856. _init(): void;
  13857. private _getPhysicsParent;
  13858. /**
  13859. * Should a new body be generated.
  13860. * @returns boolean specifying if body initialization is required
  13861. */
  13862. isBodyInitRequired(): boolean;
  13863. /**
  13864. * Sets the updated scaling
  13865. * @param updated Specifies if the scaling is updated
  13866. */
  13867. setScalingUpdated(): void;
  13868. /**
  13869. * Force a regeneration of this or the parent's impostor's body.
  13870. * Use under cautious - This will remove all joints already implemented.
  13871. */
  13872. forceUpdate(): void;
  13873. /**
  13874. * Gets the body that holds this impostor. Either its own, or its parent.
  13875. */
  13876. /**
  13877. * Set the physics body. Used mainly by the physics engine/plugin
  13878. */
  13879. physicsBody: any;
  13880. /**
  13881. * Get the parent of the physics imposter
  13882. * @returns Physics imposter or null
  13883. */
  13884. /**
  13885. * Sets the parent of the physics imposter
  13886. */
  13887. parent: Nullable<PhysicsImpostor>;
  13888. /**
  13889. * Resets the update flags
  13890. */
  13891. resetUpdateFlags(): void;
  13892. /**
  13893. * Gets the object extend size
  13894. * @returns the object extend size
  13895. */
  13896. getObjectExtendSize(): Vector3;
  13897. /**
  13898. * Gets the object center
  13899. * @returns The object center
  13900. */
  13901. getObjectCenter(): Vector3;
  13902. /**
  13903. * Get a specific parametes from the options parameter
  13904. * @param paramName The object parameter name
  13905. * @returns The object parameter
  13906. */
  13907. getParam(paramName: string): any;
  13908. /**
  13909. * Sets a specific parameter in the options given to the physics plugin
  13910. * @param paramName The parameter name
  13911. * @param value The value of the parameter
  13912. */
  13913. setParam(paramName: string, value: number): void;
  13914. /**
  13915. * Specifically change the body's mass option. Won't recreate the physics body object
  13916. * @param mass The mass of the physics imposter
  13917. */
  13918. setMass(mass: number): void;
  13919. /**
  13920. * Gets the linear velocity
  13921. * @returns linear velocity or null
  13922. */
  13923. getLinearVelocity(): Nullable<Vector3>;
  13924. /**
  13925. * Sets the linear velocity
  13926. * @param velocity linear velocity or null
  13927. */
  13928. setLinearVelocity(velocity: Nullable<Vector3>): void;
  13929. /**
  13930. * Gets the angular velocity
  13931. * @returns angular velocity or null
  13932. */
  13933. getAngularVelocity(): Nullable<Vector3>;
  13934. /**
  13935. * Sets the angular velocity
  13936. * @param velocity The velocity or null
  13937. */
  13938. setAngularVelocity(velocity: Nullable<Vector3>): void;
  13939. /**
  13940. * Execute a function with the physics plugin native code
  13941. * Provide a function the will have two variables - the world object and the physics body object
  13942. * @param func The function to execute with the physics plugin native code
  13943. */
  13944. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  13945. /**
  13946. * Register a function that will be executed before the physics world is stepping forward
  13947. * @param func The function to execute before the physics world is stepped forward
  13948. */
  13949. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13950. /**
  13951. * Unregister a function that will be executed before the physics world is stepping forward
  13952. * @param func The function to execute before the physics world is stepped forward
  13953. */
  13954. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13955. /**
  13956. * Register a function that will be executed after the physics step
  13957. * @param func The function to execute after physics step
  13958. */
  13959. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13960. /**
  13961. * Unregisters a function that will be executed after the physics step
  13962. * @param func The function to execute after physics step
  13963. */
  13964. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13965. /**
  13966. * register a function that will be executed when this impostor collides against a different body
  13967. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  13968. * @param func Callback that is executed on collision
  13969. */
  13970. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  13971. /**
  13972. * Unregisters the physics imposter on contact
  13973. * @param collideAgainst The physics object to collide against
  13974. * @param func Callback to execute on collision
  13975. */
  13976. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  13977. private _tmpQuat;
  13978. private _tmpQuat2;
  13979. /**
  13980. * Get the parent rotation
  13981. * @returns The parent rotation
  13982. */
  13983. getParentsRotation(): Quaternion;
  13984. /**
  13985. * this function is executed by the physics engine.
  13986. */
  13987. beforeStep: () => void;
  13988. /**
  13989. * this function is executed by the physics engine
  13990. */
  13991. afterStep: () => void;
  13992. /**
  13993. * Legacy collision detection event support
  13994. */
  13995. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  13996. /**
  13997. * event and body object due to cannon's event-based architecture.
  13998. */
  13999. onCollide: (e: {
  14000. body: any;
  14001. }) => void;
  14002. /**
  14003. * Apply a force
  14004. * @param force The force to apply
  14005. * @param contactPoint The contact point for the force
  14006. * @returns The physics imposter
  14007. */
  14008. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  14009. /**
  14010. * Apply an impulse
  14011. * @param force The impulse force
  14012. * @param contactPoint The contact point for the impulse force
  14013. * @returns The physics imposter
  14014. */
  14015. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  14016. /**
  14017. * A help function to create a joint
  14018. * @param otherImpostor A physics imposter used to create a joint
  14019. * @param jointType The type of joint
  14020. * @param jointData The data for the joint
  14021. * @returns The physics imposter
  14022. */
  14023. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  14024. /**
  14025. * Add a joint to this impostor with a different impostor
  14026. * @param otherImpostor A physics imposter used to add a joint
  14027. * @param joint The joint to add
  14028. * @returns The physics imposter
  14029. */
  14030. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  14031. /**
  14032. * Add an anchor to a cloth impostor
  14033. * @param otherImpostor rigid impostor to anchor to
  14034. * @param width ratio across width from 0 to 1
  14035. * @param height ratio up height from 0 to 1
  14036. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  14037. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  14038. * @returns impostor the soft imposter
  14039. */
  14040. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  14041. /**
  14042. * Add a hook to a rope impostor
  14043. * @param otherImpostor rigid impostor to anchor to
  14044. * @param length ratio across rope from 0 to 1
  14045. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  14046. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  14047. * @returns impostor the rope imposter
  14048. */
  14049. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  14050. /**
  14051. * Will keep this body still, in a sleep mode.
  14052. * @returns the physics imposter
  14053. */
  14054. sleep(): PhysicsImpostor;
  14055. /**
  14056. * Wake the body up.
  14057. * @returns The physics imposter
  14058. */
  14059. wakeUp(): PhysicsImpostor;
  14060. /**
  14061. * Clones the physics imposter
  14062. * @param newObject The physics imposter clones to this physics-enabled object
  14063. * @returns A nullable physics imposter
  14064. */
  14065. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  14066. /**
  14067. * Disposes the physics imposter
  14068. */
  14069. dispose(): void;
  14070. /**
  14071. * Sets the delta position
  14072. * @param position The delta position amount
  14073. */
  14074. setDeltaPosition(position: Vector3): void;
  14075. /**
  14076. * Sets the delta rotation
  14077. * @param rotation The delta rotation amount
  14078. */
  14079. setDeltaRotation(rotation: Quaternion): void;
  14080. /**
  14081. * Gets the box size of the physics imposter and stores the result in the input parameter
  14082. * @param result Stores the box size
  14083. * @returns The physics imposter
  14084. */
  14085. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  14086. /**
  14087. * Gets the radius of the physics imposter
  14088. * @returns Radius of the physics imposter
  14089. */
  14090. getRadius(): number;
  14091. /**
  14092. * Sync a bone with this impostor
  14093. * @param bone The bone to sync to the impostor.
  14094. * @param boneMesh The mesh that the bone is influencing.
  14095. * @param jointPivot The pivot of the joint / bone in local space.
  14096. * @param distToJoint Optional distance from the impostor to the joint.
  14097. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  14098. */
  14099. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  14100. /**
  14101. * Sync impostor to a bone
  14102. * @param bone The bone that the impostor will be synced to.
  14103. * @param boneMesh The mesh that the bone is influencing.
  14104. * @param jointPivot The pivot of the joint / bone in local space.
  14105. * @param distToJoint Optional distance from the impostor to the joint.
  14106. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  14107. * @param boneAxis Optional vector3 axis the bone is aligned with
  14108. */
  14109. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  14110. /**
  14111. * No-Imposter type
  14112. */
  14113. static NoImpostor: number;
  14114. /**
  14115. * Sphere-Imposter type
  14116. */
  14117. static SphereImpostor: number;
  14118. /**
  14119. * Box-Imposter type
  14120. */
  14121. static BoxImpostor: number;
  14122. /**
  14123. * Plane-Imposter type
  14124. */
  14125. static PlaneImpostor: number;
  14126. /**
  14127. * Mesh-imposter type
  14128. */
  14129. static MeshImpostor: number;
  14130. /**
  14131. * Capsule-Impostor type (Ammo.js plugin only)
  14132. */
  14133. static CapsuleImpostor: number;
  14134. /**
  14135. * Cylinder-Imposter type
  14136. */
  14137. static CylinderImpostor: number;
  14138. /**
  14139. * Particle-Imposter type
  14140. */
  14141. static ParticleImpostor: number;
  14142. /**
  14143. * Heightmap-Imposter type
  14144. */
  14145. static HeightmapImpostor: number;
  14146. /**
  14147. * ConvexHull-Impostor type (Ammo.js plugin only)
  14148. */
  14149. static ConvexHullImpostor: number;
  14150. /**
  14151. * Rope-Imposter type
  14152. */
  14153. static RopeImpostor: number;
  14154. /**
  14155. * Cloth-Imposter type
  14156. */
  14157. static ClothImpostor: number;
  14158. /**
  14159. * Softbody-Imposter type
  14160. */
  14161. static SoftbodyImpostor: number;
  14162. }
  14163. }
  14164. declare module "babylonjs/Meshes/mesh" {
  14165. import { Observable } from "babylonjs/Misc/observable";
  14166. import { IAnimatable } from "babylonjs/Misc/tools";
  14167. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  14168. import { Camera } from "babylonjs/Cameras/camera";
  14169. import { Scene } from "babylonjs/scene";
  14170. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  14171. import { Engine } from "babylonjs/Engines/engine";
  14172. import { Node } from "babylonjs/node";
  14173. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  14174. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  14175. import { Buffer } from "babylonjs/Meshes/buffer";
  14176. import { Geometry } from "babylonjs/Meshes/geometry";
  14177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14178. import { SubMesh } from "babylonjs/Meshes/subMesh";
  14179. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  14180. import { Effect } from "babylonjs/Materials/effect";
  14181. import { Material } from "babylonjs/Materials/material";
  14182. import { Skeleton } from "babylonjs/Bones/skeleton";
  14183. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  14184. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  14185. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  14186. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  14187. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  14188. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  14189. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  14190. /**
  14191. * @hidden
  14192. **/
  14193. export class _CreationDataStorage {
  14194. closePath?: boolean;
  14195. closeArray?: boolean;
  14196. idx: number[];
  14197. dashSize: number;
  14198. gapSize: number;
  14199. path3D: Path3D;
  14200. pathArray: Vector3[][];
  14201. arc: number;
  14202. radius: number;
  14203. cap: number;
  14204. tessellation: number;
  14205. }
  14206. /**
  14207. * @hidden
  14208. **/
  14209. class _InstanceDataStorage {
  14210. visibleInstances: any;
  14211. batchCache: _InstancesBatch;
  14212. instancesBufferSize: number;
  14213. instancesBuffer: Nullable<Buffer>;
  14214. instancesData: Float32Array;
  14215. overridenInstanceCount: number;
  14216. isFrozen: boolean;
  14217. previousBatch: Nullable<_InstancesBatch>;
  14218. hardwareInstancedRendering: boolean;
  14219. sideOrientation: number;
  14220. }
  14221. /**
  14222. * @hidden
  14223. **/
  14224. export class _InstancesBatch {
  14225. mustReturn: boolean;
  14226. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  14227. renderSelf: boolean[];
  14228. hardwareInstancedRendering: boolean[];
  14229. }
  14230. /**
  14231. * Class used to represent renderable models
  14232. */
  14233. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  14234. /**
  14235. * Mesh side orientation : usually the external or front surface
  14236. */
  14237. static readonly FRONTSIDE: number;
  14238. /**
  14239. * Mesh side orientation : usually the internal or back surface
  14240. */
  14241. static readonly BACKSIDE: number;
  14242. /**
  14243. * Mesh side orientation : both internal and external or front and back surfaces
  14244. */
  14245. static readonly DOUBLESIDE: number;
  14246. /**
  14247. * Mesh side orientation : by default, `FRONTSIDE`
  14248. */
  14249. static readonly DEFAULTSIDE: number;
  14250. /**
  14251. * Mesh cap setting : no cap
  14252. */
  14253. static readonly NO_CAP: number;
  14254. /**
  14255. * Mesh cap setting : one cap at the beginning of the mesh
  14256. */
  14257. static readonly CAP_START: number;
  14258. /**
  14259. * Mesh cap setting : one cap at the end of the mesh
  14260. */
  14261. static readonly CAP_END: number;
  14262. /**
  14263. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  14264. */
  14265. static readonly CAP_ALL: number;
  14266. /**
  14267. * Mesh pattern setting : no flip or rotate
  14268. */
  14269. static readonly NO_FLIP: number;
  14270. /**
  14271. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  14272. */
  14273. static readonly FLIP_TILE: number;
  14274. /**
  14275. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  14276. */
  14277. static readonly ROTATE_TILE: number;
  14278. /**
  14279. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  14280. */
  14281. static readonly FLIP_ROW: number;
  14282. /**
  14283. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  14284. */
  14285. static readonly ROTATE_ROW: number;
  14286. /**
  14287. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  14288. */
  14289. static readonly FLIP_N_ROTATE_TILE: number;
  14290. /**
  14291. * Mesh pattern setting : rotate pattern and rotate
  14292. */
  14293. static readonly FLIP_N_ROTATE_ROW: number;
  14294. /**
  14295. * Mesh tile positioning : part tiles same on left/right or top/bottom
  14296. */
  14297. static readonly CENTER: number;
  14298. /**
  14299. * Mesh tile positioning : part tiles on left
  14300. */
  14301. static readonly LEFT: number;
  14302. /**
  14303. * Mesh tile positioning : part tiles on right
  14304. */
  14305. static readonly RIGHT: number;
  14306. /**
  14307. * Mesh tile positioning : part tiles on top
  14308. */
  14309. static readonly TOP: number;
  14310. /**
  14311. * Mesh tile positioning : part tiles on bottom
  14312. */
  14313. static readonly BOTTOM: number;
  14314. /**
  14315. * Gets the default side orientation.
  14316. * @param orientation the orientation to value to attempt to get
  14317. * @returns the default orientation
  14318. * @hidden
  14319. */
  14320. static _GetDefaultSideOrientation(orientation?: number): number;
  14321. private _internalMeshDataInfo;
  14322. /**
  14323. * An event triggered before rendering the mesh
  14324. */
  14325. readonly onBeforeRenderObservable: Observable<Mesh>;
  14326. /**
  14327. * An event triggered before binding the mesh
  14328. */
  14329. readonly onBeforeBindObservable: Observable<Mesh>;
  14330. /**
  14331. * An event triggered after rendering the mesh
  14332. */
  14333. readonly onAfterRenderObservable: Observable<Mesh>;
  14334. /**
  14335. * An event triggered before drawing the mesh
  14336. */
  14337. readonly onBeforeDrawObservable: Observable<Mesh>;
  14338. private _onBeforeDrawObserver;
  14339. /**
  14340. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  14341. */
  14342. onBeforeDraw: () => void;
  14343. /**
  14344. * Gets the delay loading state of the mesh (when delay loading is turned on)
  14345. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  14346. */
  14347. delayLoadState: number;
  14348. /**
  14349. * Gets the list of instances created from this mesh
  14350. * it is not supposed to be modified manually.
  14351. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  14352. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14353. */
  14354. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  14355. /**
  14356. * Gets the file containing delay loading data for this mesh
  14357. */
  14358. delayLoadingFile: string;
  14359. /** @hidden */
  14360. _binaryInfo: any;
  14361. /**
  14362. * User defined function used to change how LOD level selection is done
  14363. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  14364. */
  14365. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  14366. /**
  14367. * Gets or sets the morph target manager
  14368. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  14369. */
  14370. morphTargetManager: Nullable<MorphTargetManager>;
  14371. /** @hidden */
  14372. _creationDataStorage: Nullable<_CreationDataStorage>;
  14373. /** @hidden */
  14374. _geometry: Nullable<Geometry>;
  14375. /** @hidden */
  14376. _delayInfo: Array<string>;
  14377. /** @hidden */
  14378. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  14379. /** @hidden */
  14380. _instanceDataStorage: _InstanceDataStorage;
  14381. private _effectiveMaterial;
  14382. /** @hidden */
  14383. _shouldGenerateFlatShading: boolean;
  14384. /** @hidden */
  14385. _originalBuilderSideOrientation: number;
  14386. /**
  14387. * Use this property to change the original side orientation defined at construction time
  14388. */
  14389. overrideMaterialSideOrientation: Nullable<number>;
  14390. /**
  14391. * Gets the source mesh (the one used to clone this one from)
  14392. */
  14393. readonly source: Nullable<Mesh>;
  14394. /**
  14395. * Gets or sets a boolean indicating that this mesh does not use index buffer
  14396. */
  14397. isUnIndexed: boolean;
  14398. /**
  14399. * @constructor
  14400. * @param name The value used by scene.getMeshByName() to do a lookup.
  14401. * @param scene The scene to add this mesh to.
  14402. * @param parent The parent of this mesh, if it has one
  14403. * @param source An optional Mesh from which geometry is shared, cloned.
  14404. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  14405. * When false, achieved by calling a clone(), also passing False.
  14406. * This will make creation of children, recursive.
  14407. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  14408. */
  14409. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  14410. /**
  14411. * Gets the class name
  14412. * @returns the string "Mesh".
  14413. */
  14414. getClassName(): string;
  14415. /** @hidden */
  14416. readonly _isMesh: boolean;
  14417. /**
  14418. * Returns a description of this mesh
  14419. * @param fullDetails define if full details about this mesh must be used
  14420. * @returns a descriptive string representing this mesh
  14421. */
  14422. toString(fullDetails?: boolean): string;
  14423. /** @hidden */
  14424. _unBindEffect(): void;
  14425. /**
  14426. * Gets a boolean indicating if this mesh has LOD
  14427. */
  14428. readonly hasLODLevels: boolean;
  14429. /**
  14430. * Gets the list of MeshLODLevel associated with the current mesh
  14431. * @returns an array of MeshLODLevel
  14432. */
  14433. getLODLevels(): MeshLODLevel[];
  14434. private _sortLODLevels;
  14435. /**
  14436. * Add a mesh as LOD level triggered at the given distance.
  14437. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14438. * @param distance The distance from the center of the object to show this level
  14439. * @param mesh The mesh to be added as LOD level (can be null)
  14440. * @return This mesh (for chaining)
  14441. */
  14442. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  14443. /**
  14444. * Returns the LOD level mesh at the passed distance or null if not found.
  14445. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14446. * @param distance The distance from the center of the object to show this level
  14447. * @returns a Mesh or `null`
  14448. */
  14449. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  14450. /**
  14451. * Remove a mesh from the LOD array
  14452. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14453. * @param mesh defines the mesh to be removed
  14454. * @return This mesh (for chaining)
  14455. */
  14456. removeLODLevel(mesh: Mesh): Mesh;
  14457. /**
  14458. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  14459. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14460. * @param camera defines the camera to use to compute distance
  14461. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  14462. * @return This mesh (for chaining)
  14463. */
  14464. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  14465. /**
  14466. * Gets the mesh internal Geometry object
  14467. */
  14468. readonly geometry: Nullable<Geometry>;
  14469. /**
  14470. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  14471. * @returns the total number of vertices
  14472. */
  14473. getTotalVertices(): number;
  14474. /**
  14475. * Returns the content of an associated vertex buffer
  14476. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14477. * - VertexBuffer.PositionKind
  14478. * - VertexBuffer.UVKind
  14479. * - VertexBuffer.UV2Kind
  14480. * - VertexBuffer.UV3Kind
  14481. * - VertexBuffer.UV4Kind
  14482. * - VertexBuffer.UV5Kind
  14483. * - VertexBuffer.UV6Kind
  14484. * - VertexBuffer.ColorKind
  14485. * - VertexBuffer.MatricesIndicesKind
  14486. * - VertexBuffer.MatricesIndicesExtraKind
  14487. * - VertexBuffer.MatricesWeightsKind
  14488. * - VertexBuffer.MatricesWeightsExtraKind
  14489. * @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
  14490. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  14491. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  14492. */
  14493. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  14494. /**
  14495. * Returns the mesh VertexBuffer object from the requested `kind`
  14496. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14497. * - VertexBuffer.PositionKind
  14498. * - VertexBuffer.NormalKind
  14499. * - VertexBuffer.UVKind
  14500. * - VertexBuffer.UV2Kind
  14501. * - VertexBuffer.UV3Kind
  14502. * - VertexBuffer.UV4Kind
  14503. * - VertexBuffer.UV5Kind
  14504. * - VertexBuffer.UV6Kind
  14505. * - VertexBuffer.ColorKind
  14506. * - VertexBuffer.MatricesIndicesKind
  14507. * - VertexBuffer.MatricesIndicesExtraKind
  14508. * - VertexBuffer.MatricesWeightsKind
  14509. * - VertexBuffer.MatricesWeightsExtraKind
  14510. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  14511. */
  14512. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  14513. /**
  14514. * Tests if a specific vertex buffer is associated with this mesh
  14515. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14516. * - VertexBuffer.PositionKind
  14517. * - VertexBuffer.NormalKind
  14518. * - VertexBuffer.UVKind
  14519. * - VertexBuffer.UV2Kind
  14520. * - VertexBuffer.UV3Kind
  14521. * - VertexBuffer.UV4Kind
  14522. * - VertexBuffer.UV5Kind
  14523. * - VertexBuffer.UV6Kind
  14524. * - VertexBuffer.ColorKind
  14525. * - VertexBuffer.MatricesIndicesKind
  14526. * - VertexBuffer.MatricesIndicesExtraKind
  14527. * - VertexBuffer.MatricesWeightsKind
  14528. * - VertexBuffer.MatricesWeightsExtraKind
  14529. * @returns a boolean
  14530. */
  14531. isVerticesDataPresent(kind: string): boolean;
  14532. /**
  14533. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  14534. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14535. * - VertexBuffer.PositionKind
  14536. * - VertexBuffer.UVKind
  14537. * - VertexBuffer.UV2Kind
  14538. * - VertexBuffer.UV3Kind
  14539. * - VertexBuffer.UV4Kind
  14540. * - VertexBuffer.UV5Kind
  14541. * - VertexBuffer.UV6Kind
  14542. * - VertexBuffer.ColorKind
  14543. * - VertexBuffer.MatricesIndicesKind
  14544. * - VertexBuffer.MatricesIndicesExtraKind
  14545. * - VertexBuffer.MatricesWeightsKind
  14546. * - VertexBuffer.MatricesWeightsExtraKind
  14547. * @returns a boolean
  14548. */
  14549. isVertexBufferUpdatable(kind: string): boolean;
  14550. /**
  14551. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  14552. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14553. * - VertexBuffer.PositionKind
  14554. * - VertexBuffer.NormalKind
  14555. * - VertexBuffer.UVKind
  14556. * - VertexBuffer.UV2Kind
  14557. * - VertexBuffer.UV3Kind
  14558. * - VertexBuffer.UV4Kind
  14559. * - VertexBuffer.UV5Kind
  14560. * - VertexBuffer.UV6Kind
  14561. * - VertexBuffer.ColorKind
  14562. * - VertexBuffer.MatricesIndicesKind
  14563. * - VertexBuffer.MatricesIndicesExtraKind
  14564. * - VertexBuffer.MatricesWeightsKind
  14565. * - VertexBuffer.MatricesWeightsExtraKind
  14566. * @returns an array of strings
  14567. */
  14568. getVerticesDataKinds(): string[];
  14569. /**
  14570. * Returns a positive integer : the total number of indices in this mesh geometry.
  14571. * @returns the numner of indices or zero if the mesh has no geometry.
  14572. */
  14573. getTotalIndices(): number;
  14574. /**
  14575. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  14576. * @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.
  14577. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  14578. * @returns the indices array or an empty array if the mesh has no geometry
  14579. */
  14580. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  14581. readonly isBlocked: boolean;
  14582. /**
  14583. * Determine if the current mesh is ready to be rendered
  14584. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  14585. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  14586. * @returns true if all associated assets are ready (material, textures, shaders)
  14587. */
  14588. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  14589. /**
  14590. * 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.
  14591. */
  14592. readonly areNormalsFrozen: boolean;
  14593. /**
  14594. * 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.
  14595. * @returns the current mesh
  14596. */
  14597. freezeNormals(): Mesh;
  14598. /**
  14599. * 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
  14600. * @returns the current mesh
  14601. */
  14602. unfreezeNormals(): Mesh;
  14603. /**
  14604. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  14605. */
  14606. overridenInstanceCount: number;
  14607. /** @hidden */
  14608. _preActivate(): Mesh;
  14609. /** @hidden */
  14610. _preActivateForIntermediateRendering(renderId: number): Mesh;
  14611. /** @hidden */
  14612. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  14613. /**
  14614. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  14615. * This means the mesh underlying bounding box and sphere are recomputed.
  14616. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  14617. * @returns the current mesh
  14618. */
  14619. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  14620. /** @hidden */
  14621. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  14622. /**
  14623. * This function will subdivide the mesh into multiple submeshes
  14624. * @param count defines the expected number of submeshes
  14625. */
  14626. subdivide(count: number): void;
  14627. /**
  14628. * Copy a FloatArray into a specific associated vertex buffer
  14629. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14630. * - VertexBuffer.PositionKind
  14631. * - VertexBuffer.UVKind
  14632. * - VertexBuffer.UV2Kind
  14633. * - VertexBuffer.UV3Kind
  14634. * - VertexBuffer.UV4Kind
  14635. * - VertexBuffer.UV5Kind
  14636. * - VertexBuffer.UV6Kind
  14637. * - VertexBuffer.ColorKind
  14638. * - VertexBuffer.MatricesIndicesKind
  14639. * - VertexBuffer.MatricesIndicesExtraKind
  14640. * - VertexBuffer.MatricesWeightsKind
  14641. * - VertexBuffer.MatricesWeightsExtraKind
  14642. * @param data defines the data source
  14643. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14644. * @param stride defines the data stride size (can be null)
  14645. * @returns the current mesh
  14646. */
  14647. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  14648. /**
  14649. * Flags an associated vertex buffer as updatable
  14650. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  14651. * - VertexBuffer.PositionKind
  14652. * - VertexBuffer.UVKind
  14653. * - VertexBuffer.UV2Kind
  14654. * - VertexBuffer.UV3Kind
  14655. * - VertexBuffer.UV4Kind
  14656. * - VertexBuffer.UV5Kind
  14657. * - VertexBuffer.UV6Kind
  14658. * - VertexBuffer.ColorKind
  14659. * - VertexBuffer.MatricesIndicesKind
  14660. * - VertexBuffer.MatricesIndicesExtraKind
  14661. * - VertexBuffer.MatricesWeightsKind
  14662. * - VertexBuffer.MatricesWeightsExtraKind
  14663. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14664. */
  14665. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  14666. /**
  14667. * Sets the mesh global Vertex Buffer
  14668. * @param buffer defines the buffer to use
  14669. * @returns the current mesh
  14670. */
  14671. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  14672. /**
  14673. * Update a specific associated vertex buffer
  14674. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14675. * - VertexBuffer.PositionKind
  14676. * - VertexBuffer.UVKind
  14677. * - VertexBuffer.UV2Kind
  14678. * - VertexBuffer.UV3Kind
  14679. * - VertexBuffer.UV4Kind
  14680. * - VertexBuffer.UV5Kind
  14681. * - VertexBuffer.UV6Kind
  14682. * - VertexBuffer.ColorKind
  14683. * - VertexBuffer.MatricesIndicesKind
  14684. * - VertexBuffer.MatricesIndicesExtraKind
  14685. * - VertexBuffer.MatricesWeightsKind
  14686. * - VertexBuffer.MatricesWeightsExtraKind
  14687. * @param data defines the data source
  14688. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  14689. * @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)
  14690. * @returns the current mesh
  14691. */
  14692. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  14693. /**
  14694. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  14695. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  14696. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  14697. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  14698. * @returns the current mesh
  14699. */
  14700. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  14701. /**
  14702. * Creates a un-shared specific occurence of the geometry for the mesh.
  14703. * @returns the current mesh
  14704. */
  14705. makeGeometryUnique(): Mesh;
  14706. /**
  14707. * Set the index buffer of this mesh
  14708. * @param indices defines the source data
  14709. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  14710. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  14711. * @returns the current mesh
  14712. */
  14713. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  14714. /**
  14715. * Update the current index buffer
  14716. * @param indices defines the source data
  14717. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  14718. * @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)
  14719. * @returns the current mesh
  14720. */
  14721. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  14722. /**
  14723. * Invert the geometry to move from a right handed system to a left handed one.
  14724. * @returns the current mesh
  14725. */
  14726. toLeftHanded(): Mesh;
  14727. /** @hidden */
  14728. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  14729. /** @hidden */
  14730. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  14731. /**
  14732. * Registers for this mesh a javascript function called just before the rendering process
  14733. * @param func defines the function to call before rendering this mesh
  14734. * @returns the current mesh
  14735. */
  14736. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14737. /**
  14738. * Disposes a previously registered javascript function called before the rendering
  14739. * @param func defines the function to remove
  14740. * @returns the current mesh
  14741. */
  14742. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14743. /**
  14744. * Registers for this mesh a javascript function called just after the rendering is complete
  14745. * @param func defines the function to call after rendering this mesh
  14746. * @returns the current mesh
  14747. */
  14748. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14749. /**
  14750. * Disposes a previously registered javascript function called after the rendering.
  14751. * @param func defines the function to remove
  14752. * @returns the current mesh
  14753. */
  14754. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14755. /** @hidden */
  14756. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  14757. /** @hidden */
  14758. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  14759. /** @hidden */
  14760. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  14761. /** @hidden */
  14762. _rebuild(): void;
  14763. /** @hidden */
  14764. _freeze(): void;
  14765. /** @hidden */
  14766. _unFreeze(): void;
  14767. /**
  14768. * 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
  14769. * @param subMesh defines the subMesh to render
  14770. * @param enableAlphaMode defines if alpha mode can be changed
  14771. * @returns the current mesh
  14772. */
  14773. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  14774. private _onBeforeDraw;
  14775. /**
  14776. * Renormalize the mesh and patch it up if there are no weights
  14777. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  14778. * However in the case of zero weights then we set just a single influence to 1.
  14779. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  14780. */
  14781. cleanMatrixWeights(): void;
  14782. private normalizeSkinFourWeights;
  14783. private normalizeSkinWeightsAndExtra;
  14784. /**
  14785. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  14786. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  14787. * the user know there was an issue with importing the mesh
  14788. * @returns a validation object with skinned, valid and report string
  14789. */
  14790. validateSkinning(): {
  14791. skinned: boolean;
  14792. valid: boolean;
  14793. report: string;
  14794. };
  14795. /** @hidden */
  14796. _checkDelayState(): Mesh;
  14797. private _queueLoad;
  14798. /**
  14799. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  14800. * A mesh is in the frustum if its bounding box intersects the frustum
  14801. * @param frustumPlanes defines the frustum to test
  14802. * @returns true if the mesh is in the frustum planes
  14803. */
  14804. isInFrustum(frustumPlanes: Plane[]): boolean;
  14805. /**
  14806. * Sets the mesh material by the material or multiMaterial `id` property
  14807. * @param id is a string identifying the material or the multiMaterial
  14808. * @returns the current mesh
  14809. */
  14810. setMaterialByID(id: string): Mesh;
  14811. /**
  14812. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  14813. * @returns an array of IAnimatable
  14814. */
  14815. getAnimatables(): IAnimatable[];
  14816. /**
  14817. * Modifies the mesh geometry according to the passed transformation matrix.
  14818. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  14819. * The mesh normals are modified using the same transformation.
  14820. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14821. * @param transform defines the transform matrix to use
  14822. * @see http://doc.babylonjs.com/resources/baking_transformations
  14823. * @returns the current mesh
  14824. */
  14825. bakeTransformIntoVertices(transform: Matrix): Mesh;
  14826. /**
  14827. * Modifies the mesh geometry according to its own current World Matrix.
  14828. * The mesh World Matrix is then reset.
  14829. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  14830. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14831. * @see http://doc.babylonjs.com/resources/baking_transformations
  14832. * @returns the current mesh
  14833. */
  14834. bakeCurrentTransformIntoVertices(): Mesh;
  14835. /** @hidden */
  14836. readonly _positions: Nullable<Vector3[]>;
  14837. /** @hidden */
  14838. _resetPointsArrayCache(): Mesh;
  14839. /** @hidden */
  14840. _generatePointsArray(): boolean;
  14841. /**
  14842. * Returns a new Mesh object generated from the current mesh properties.
  14843. * This method must not get confused with createInstance()
  14844. * @param name is a string, the name given to the new mesh
  14845. * @param newParent can be any Node object (default `null`)
  14846. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  14847. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  14848. * @returns a new mesh
  14849. */
  14850. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  14851. /**
  14852. * Releases resources associated with this mesh.
  14853. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14854. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14855. */
  14856. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14857. /**
  14858. * Modifies the mesh geometry according to a displacement map.
  14859. * 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.
  14860. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14861. * @param url is a string, the URL from the image file is to be downloaded.
  14862. * @param minHeight is the lower limit of the displacement.
  14863. * @param maxHeight is the upper limit of the displacement.
  14864. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  14865. * @param uvOffset is an optional vector2 used to offset UV.
  14866. * @param uvScale is an optional vector2 used to scale UV.
  14867. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  14868. * @returns the Mesh.
  14869. */
  14870. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14871. /**
  14872. * Modifies the mesh geometry according to a displacementMap buffer.
  14873. * 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.
  14874. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14875. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  14876. * @param heightMapWidth is the width of the buffer image.
  14877. * @param heightMapHeight is the height of the buffer image.
  14878. * @param minHeight is the lower limit of the displacement.
  14879. * @param maxHeight is the upper limit of the displacement.
  14880. * @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.
  14881. * @param uvOffset is an optional vector2 used to offset UV.
  14882. * @param uvScale is an optional vector2 used to scale UV.
  14883. * @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.
  14884. * @returns the Mesh.
  14885. */
  14886. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14887. /**
  14888. * Modify the mesh to get a flat shading rendering.
  14889. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  14890. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  14891. * @returns current mesh
  14892. */
  14893. convertToFlatShadedMesh(): Mesh;
  14894. /**
  14895. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  14896. * In other words, more vertices, no more indices and a single bigger VBO.
  14897. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  14898. * @returns current mesh
  14899. */
  14900. convertToUnIndexedMesh(): Mesh;
  14901. /**
  14902. * Inverses facet orientations.
  14903. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14904. * @param flipNormals will also inverts the normals
  14905. * @returns current mesh
  14906. */
  14907. flipFaces(flipNormals?: boolean): Mesh;
  14908. /**
  14909. * Increase the number of facets and hence vertices in a mesh
  14910. * Vertex normals are interpolated from existing vertex normals
  14911. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14912. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  14913. */
  14914. increaseVertices(numberPerEdge: number): void;
  14915. /**
  14916. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  14917. * This will undo any application of covertToFlatShadedMesh
  14918. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14919. */
  14920. forceSharedVertices(): void;
  14921. /** @hidden */
  14922. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  14923. /** @hidden */
  14924. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  14925. /**
  14926. * Creates a new InstancedMesh object from the mesh model.
  14927. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14928. * @param name defines the name of the new instance
  14929. * @returns a new InstancedMesh
  14930. */
  14931. createInstance(name: string): InstancedMesh;
  14932. /**
  14933. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  14934. * After this call, all the mesh instances have the same submeshes than the current mesh.
  14935. * @returns the current mesh
  14936. */
  14937. synchronizeInstances(): Mesh;
  14938. /**
  14939. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  14940. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  14941. * This should be used together with the simplification to avoid disappearing triangles.
  14942. * @param successCallback an optional success callback to be called after the optimization finished.
  14943. * @returns the current mesh
  14944. */
  14945. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  14946. /**
  14947. * Serialize current mesh
  14948. * @param serializationObject defines the object which will receive the serialization data
  14949. */
  14950. serialize(serializationObject: any): void;
  14951. /** @hidden */
  14952. _syncGeometryWithMorphTargetManager(): void;
  14953. /** @hidden */
  14954. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  14955. /**
  14956. * Returns a new Mesh object parsed from the source provided.
  14957. * @param parsedMesh is the source
  14958. * @param scene defines the hosting scene
  14959. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  14960. * @returns a new Mesh
  14961. */
  14962. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  14963. /**
  14964. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  14965. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14966. * @param name defines the name of the mesh to create
  14967. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  14968. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  14969. * @param closePath creates a seam between the first and the last points of each path of the path array
  14970. * @param offset is taken in account only if the `pathArray` is containing a single path
  14971. * @param scene defines the hosting scene
  14972. * @param updatable defines if the mesh must be flagged as updatable
  14973. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14974. * @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)
  14975. * @returns a new Mesh
  14976. */
  14977. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14978. /**
  14979. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  14980. * @param name defines the name of the mesh to create
  14981. * @param radius sets the radius size (float) of the polygon (default 0.5)
  14982. * @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
  14983. * @param scene defines the hosting scene
  14984. * @param updatable defines if the mesh must be flagged as updatable
  14985. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14986. * @returns a new Mesh
  14987. */
  14988. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14989. /**
  14990. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  14991. * @param name defines the name of the mesh to create
  14992. * @param size sets the size (float) of each box side (default 1)
  14993. * @param scene defines the hosting scene
  14994. * @param updatable defines if the mesh must be flagged as updatable
  14995. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14996. * @returns a new Mesh
  14997. */
  14998. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14999. /**
  15000. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  15001. * @param name defines the name of the mesh to create
  15002. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  15003. * @param diameter sets the diameter size (float) of the sphere (default 1)
  15004. * @param scene defines the hosting scene
  15005. * @param updatable defines if the mesh must be flagged as updatable
  15006. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15007. * @returns a new Mesh
  15008. */
  15009. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15010. /**
  15011. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  15012. * @param name defines the name of the mesh to create
  15013. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  15014. * @param diameter sets the diameter size (float) of the sphere (default 1)
  15015. * @param scene defines the hosting scene
  15016. * @returns a new Mesh
  15017. */
  15018. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  15019. /**
  15020. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  15021. * @param name defines the name of the mesh to create
  15022. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  15023. * @param diameterTop set the top cap diameter (floats, default 1)
  15024. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  15025. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  15026. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  15027. * @param scene defines the hosting scene
  15028. * @param updatable defines if the mesh must be flagged as updatable
  15029. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15030. * @returns a new Mesh
  15031. */
  15032. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  15033. /**
  15034. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  15035. * @param name defines the name of the mesh to create
  15036. * @param diameter sets the diameter size (float) of the torus (default 1)
  15037. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  15038. * @param tessellation sets the number of torus sides (postive integer, default 16)
  15039. * @param scene defines the hosting scene
  15040. * @param updatable defines if the mesh must be flagged as updatable
  15041. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15042. * @returns a new Mesh
  15043. */
  15044. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15045. /**
  15046. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  15047. * @param name defines the name of the mesh to create
  15048. * @param radius sets the global radius size (float) of the torus knot (default 2)
  15049. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  15050. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  15051. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  15052. * @param p the number of windings on X axis (positive integers, default 2)
  15053. * @param q the number of windings on Y axis (positive integers, default 3)
  15054. * @param scene defines the hosting scene
  15055. * @param updatable defines if the mesh must be flagged as updatable
  15056. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15057. * @returns a new Mesh
  15058. */
  15059. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15060. /**
  15061. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  15062. * @param name defines the name of the mesh to create
  15063. * @param points is an array successive Vector3
  15064. * @param scene defines the hosting scene
  15065. * @param updatable defines if the mesh must be flagged as updatable
  15066. * @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).
  15067. * @returns a new Mesh
  15068. */
  15069. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  15070. /**
  15071. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  15072. * @param name defines the name of the mesh to create
  15073. * @param points is an array successive Vector3
  15074. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  15075. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  15076. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  15077. * @param scene defines the hosting scene
  15078. * @param updatable defines if the mesh must be flagged as updatable
  15079. * @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)
  15080. * @returns a new Mesh
  15081. */
  15082. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  15083. /**
  15084. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  15085. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  15086. * 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.
  15087. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15088. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15089. * Remember you can only change the shape positions, not their number when updating a polygon.
  15090. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  15091. * @param name defines the name of the mesh to create
  15092. * @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
  15093. * @param scene defines the hosting scene
  15094. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  15095. * @param updatable defines if the mesh must be flagged as updatable
  15096. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15097. * @param earcutInjection can be used to inject your own earcut reference
  15098. * @returns a new Mesh
  15099. */
  15100. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  15101. /**
  15102. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  15103. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  15104. * @param name defines the name of the mesh to create
  15105. * @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
  15106. * @param depth defines the height of extrusion
  15107. * @param scene defines the hosting scene
  15108. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  15109. * @param updatable defines if the mesh must be flagged as updatable
  15110. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15111. * @param earcutInjection can be used to inject your own earcut reference
  15112. * @returns a new Mesh
  15113. */
  15114. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  15115. /**
  15116. * Creates an extruded shape mesh.
  15117. * 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
  15118. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  15119. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  15120. * @param name defines the name of the mesh to create
  15121. * @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
  15122. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  15123. * @param scale is the value to scale the shape
  15124. * @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
  15125. * @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
  15126. * @param scene defines the hosting scene
  15127. * @param updatable defines if the mesh must be flagged as updatable
  15128. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15129. * @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)
  15130. * @returns a new Mesh
  15131. */
  15132. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15133. /**
  15134. * Creates an custom extruded shape mesh.
  15135. * The custom extrusion is a parametric shape.
  15136. * It has no predefined shape. Its final shape will depend on the input parameters.
  15137. * Please consider using the same method from the MeshBuilder class instead
  15138. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  15139. * @param name defines the name of the mesh to create
  15140. * @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
  15141. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  15142. * @param scaleFunction is a custom Javascript function called on each path point
  15143. * @param rotationFunction is a custom Javascript function called on each path point
  15144. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  15145. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  15146. * @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
  15147. * @param scene defines the hosting scene
  15148. * @param updatable defines if the mesh must be flagged as updatable
  15149. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15150. * @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)
  15151. * @returns a new Mesh
  15152. */
  15153. 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;
  15154. /**
  15155. * Creates lathe mesh.
  15156. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  15157. * Please consider using the same method from the MeshBuilder class instead
  15158. * @param name defines the name of the mesh to create
  15159. * @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
  15160. * @param radius is the radius value of the lathe
  15161. * @param tessellation is the side number of the lathe.
  15162. * @param scene defines the hosting scene
  15163. * @param updatable defines if the mesh must be flagged as updatable
  15164. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15165. * @returns a new Mesh
  15166. */
  15167. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15168. /**
  15169. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  15170. * @param name defines the name of the mesh to create
  15171. * @param size sets the size (float) of both sides of the plane at once (default 1)
  15172. * @param scene defines the hosting scene
  15173. * @param updatable defines if the mesh must be flagged as updatable
  15174. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15175. * @returns a new Mesh
  15176. */
  15177. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15178. /**
  15179. * Creates a ground mesh.
  15180. * Please consider using the same method from the MeshBuilder class instead
  15181. * @param name defines the name of the mesh to create
  15182. * @param width set the width of the ground
  15183. * @param height set the height of the ground
  15184. * @param subdivisions sets the number of subdivisions per side
  15185. * @param scene defines the hosting scene
  15186. * @param updatable defines if the mesh must be flagged as updatable
  15187. * @returns a new Mesh
  15188. */
  15189. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  15190. /**
  15191. * Creates a tiled ground mesh.
  15192. * Please consider using the same method from the MeshBuilder class instead
  15193. * @param name defines the name of the mesh to create
  15194. * @param xmin set the ground minimum X coordinate
  15195. * @param zmin set the ground minimum Y coordinate
  15196. * @param xmax set the ground maximum X coordinate
  15197. * @param zmax set the ground maximum Z coordinate
  15198. * @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
  15199. * @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
  15200. * @param scene defines the hosting scene
  15201. * @param updatable defines if the mesh must be flagged as updatable
  15202. * @returns a new Mesh
  15203. */
  15204. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  15205. w: number;
  15206. h: number;
  15207. }, precision: {
  15208. w: number;
  15209. h: number;
  15210. }, scene: Scene, updatable?: boolean): Mesh;
  15211. /**
  15212. * Creates a ground mesh from a height map.
  15213. * Please consider using the same method from the MeshBuilder class instead
  15214. * @see http://doc.babylonjs.com/babylon101/height_map
  15215. * @param name defines the name of the mesh to create
  15216. * @param url sets the URL of the height map image resource
  15217. * @param width set the ground width size
  15218. * @param height set the ground height size
  15219. * @param subdivisions sets the number of subdivision per side
  15220. * @param minHeight is the minimum altitude on the ground
  15221. * @param maxHeight is the maximum altitude on the ground
  15222. * @param scene defines the hosting scene
  15223. * @param updatable defines if the mesh must be flagged as updatable
  15224. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  15225. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  15226. * @returns a new Mesh
  15227. */
  15228. 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;
  15229. /**
  15230. * Creates a tube mesh.
  15231. * The tube is a parametric shape.
  15232. * It has no predefined shape. Its final shape will depend on the input parameters.
  15233. * Please consider using the same method from the MeshBuilder class instead
  15234. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  15235. * @param name defines the name of the mesh to create
  15236. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  15237. * @param radius sets the tube radius size
  15238. * @param tessellation is the number of sides on the tubular surface
  15239. * @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
  15240. * @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
  15241. * @param scene defines the hosting scene
  15242. * @param updatable defines if the mesh must be flagged as updatable
  15243. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15244. * @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)
  15245. * @returns a new Mesh
  15246. */
  15247. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  15248. (i: number, distance: number): number;
  15249. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15250. /**
  15251. * Creates a polyhedron mesh.
  15252. * Please consider using the same method from the MeshBuilder class instead.
  15253. * * 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
  15254. * * The parameter `size` (positive float, default 1) sets the polygon size
  15255. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  15256. * * 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`
  15257. * * 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
  15258. * * 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)`)
  15259. * * 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
  15260. * * 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
  15261. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15262. * * If you create a double-sided mesh, you can choose what parts of 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
  15263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  15264. * @param name defines the name of the mesh to create
  15265. * @param options defines the options used to create the mesh
  15266. * @param scene defines the hosting scene
  15267. * @returns a new Mesh
  15268. */
  15269. static CreatePolyhedron(name: string, options: {
  15270. type?: number;
  15271. size?: number;
  15272. sizeX?: number;
  15273. sizeY?: number;
  15274. sizeZ?: number;
  15275. custom?: any;
  15276. faceUV?: Vector4[];
  15277. faceColors?: Color4[];
  15278. updatable?: boolean;
  15279. sideOrientation?: number;
  15280. }, scene: Scene): Mesh;
  15281. /**
  15282. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  15283. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  15284. * * 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`)
  15285. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  15286. * * 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
  15287. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15288. * * If you create a double-sided mesh, you can choose what parts of 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
  15289. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  15290. * @param name defines the name of the mesh
  15291. * @param options defines the options used to create the mesh
  15292. * @param scene defines the hosting scene
  15293. * @returns a new Mesh
  15294. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  15295. */
  15296. static CreateIcoSphere(name: string, options: {
  15297. radius?: number;
  15298. flat?: boolean;
  15299. subdivisions?: number;
  15300. sideOrientation?: number;
  15301. updatable?: boolean;
  15302. }, scene: Scene): Mesh;
  15303. /**
  15304. * Creates a decal mesh.
  15305. * Please consider using the same method from the MeshBuilder class instead.
  15306. * A decal is a mesh usually applied as a model onto the surface of another mesh
  15307. * @param name defines the name of the mesh
  15308. * @param sourceMesh defines the mesh receiving the decal
  15309. * @param position sets the position of the decal in world coordinates
  15310. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  15311. * @param size sets the decal scaling
  15312. * @param angle sets the angle to rotate the decal
  15313. * @returns a new Mesh
  15314. */
  15315. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  15316. /**
  15317. * Prepare internal position array for software CPU skinning
  15318. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  15319. */
  15320. setPositionsForCPUSkinning(): Float32Array;
  15321. /**
  15322. * Prepare internal normal array for software CPU skinning
  15323. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  15324. */
  15325. setNormalsForCPUSkinning(): Float32Array;
  15326. /**
  15327. * Updates the vertex buffer by applying transformation from the bones
  15328. * @param skeleton defines the skeleton to apply to current mesh
  15329. * @returns the current mesh
  15330. */
  15331. applySkeleton(skeleton: Skeleton): Mesh;
  15332. /**
  15333. * 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
  15334. * @param meshes defines the list of meshes to scan
  15335. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  15336. */
  15337. static MinMax(meshes: AbstractMesh[]): {
  15338. min: Vector3;
  15339. max: Vector3;
  15340. };
  15341. /**
  15342. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  15343. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  15344. * @returns a vector3
  15345. */
  15346. static Center(meshesOrMinMaxVector: {
  15347. min: Vector3;
  15348. max: Vector3;
  15349. } | AbstractMesh[]): Vector3;
  15350. /**
  15351. * Merge the array of meshes into a single mesh for performance reasons.
  15352. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  15353. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  15354. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  15355. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  15356. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  15357. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  15358. * @returns a new mesh
  15359. */
  15360. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  15361. /** @hidden */
  15362. addInstance(instance: InstancedMesh): void;
  15363. /** @hidden */
  15364. removeInstance(instance: InstancedMesh): void;
  15365. }
  15366. }
  15367. declare module "babylonjs/Actions/action" {
  15368. import { Observable } from "babylonjs/Misc/observable";
  15369. import { Condition } from "babylonjs/Actions/condition";
  15370. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  15371. import { ActionManager } from "babylonjs/Actions/actionManager";
  15372. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  15373. /**
  15374. * Interface used to define Action
  15375. */
  15376. export interface IAction {
  15377. /**
  15378. * Trigger for the action
  15379. */
  15380. trigger: number;
  15381. /** Options of the trigger */
  15382. triggerOptions: any;
  15383. /**
  15384. * Gets the trigger parameters
  15385. * @returns the trigger parameters
  15386. */
  15387. getTriggerParameter(): any;
  15388. /**
  15389. * Internal only - executes current action event
  15390. * @hidden
  15391. */
  15392. _executeCurrent(evt?: ActionEvent): void;
  15393. /**
  15394. * Serialize placeholder for child classes
  15395. * @param parent of child
  15396. * @returns the serialized object
  15397. */
  15398. serialize(parent: any): any;
  15399. /**
  15400. * Internal only
  15401. * @hidden
  15402. */
  15403. _prepare(): void;
  15404. /**
  15405. * Internal only - manager for action
  15406. * @hidden
  15407. */
  15408. _actionManager: AbstractActionManager;
  15409. /**
  15410. * Adds action to chain of actions, may be a DoNothingAction
  15411. * @param action defines the next action to execute
  15412. * @returns The action passed in
  15413. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15414. */
  15415. then(action: IAction): IAction;
  15416. }
  15417. /**
  15418. * The action to be carried out following a trigger
  15419. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  15420. */
  15421. export class Action implements IAction {
  15422. /** the trigger, with or without parameters, for the action */
  15423. triggerOptions: any;
  15424. /**
  15425. * Trigger for the action
  15426. */
  15427. trigger: number;
  15428. /**
  15429. * Internal only - manager for action
  15430. * @hidden
  15431. */
  15432. _actionManager: ActionManager;
  15433. private _nextActiveAction;
  15434. private _child;
  15435. private _condition?;
  15436. private _triggerParameter;
  15437. /**
  15438. * An event triggered prior to action being executed.
  15439. */
  15440. onBeforeExecuteObservable: Observable<Action>;
  15441. /**
  15442. * Creates a new Action
  15443. * @param triggerOptions the trigger, with or without parameters, for the action
  15444. * @param condition an optional determinant of action
  15445. */
  15446. constructor(
  15447. /** the trigger, with or without parameters, for the action */
  15448. triggerOptions: any, condition?: Condition);
  15449. /**
  15450. * Internal only
  15451. * @hidden
  15452. */
  15453. _prepare(): void;
  15454. /**
  15455. * Gets the trigger parameters
  15456. * @returns the trigger parameters
  15457. */
  15458. getTriggerParameter(): any;
  15459. /**
  15460. * Internal only - executes current action event
  15461. * @hidden
  15462. */
  15463. _executeCurrent(evt?: ActionEvent): void;
  15464. /**
  15465. * Execute placeholder for child classes
  15466. * @param evt optional action event
  15467. */
  15468. execute(evt?: ActionEvent): void;
  15469. /**
  15470. * Skips to next active action
  15471. */
  15472. skipToNextActiveAction(): void;
  15473. /**
  15474. * Adds action to chain of actions, may be a DoNothingAction
  15475. * @param action defines the next action to execute
  15476. * @returns The action passed in
  15477. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15478. */
  15479. then(action: Action): Action;
  15480. /**
  15481. * Internal only
  15482. * @hidden
  15483. */
  15484. _getProperty(propertyPath: string): string;
  15485. /**
  15486. * Internal only
  15487. * @hidden
  15488. */
  15489. _getEffectiveTarget(target: any, propertyPath: string): any;
  15490. /**
  15491. * Serialize placeholder for child classes
  15492. * @param parent of child
  15493. * @returns the serialized object
  15494. */
  15495. serialize(parent: any): any;
  15496. /**
  15497. * Internal only called by serialize
  15498. * @hidden
  15499. */
  15500. protected _serialize(serializedAction: any, parent?: any): any;
  15501. /**
  15502. * Internal only
  15503. * @hidden
  15504. */
  15505. static _SerializeValueAsString: (value: any) => string;
  15506. /**
  15507. * Internal only
  15508. * @hidden
  15509. */
  15510. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  15511. name: string;
  15512. targetType: string;
  15513. value: string;
  15514. };
  15515. }
  15516. }
  15517. declare module "babylonjs/Actions/condition" {
  15518. import { ActionManager } from "babylonjs/Actions/actionManager";
  15519. /**
  15520. * A Condition applied to an Action
  15521. */
  15522. export class Condition {
  15523. /**
  15524. * Internal only - manager for action
  15525. * @hidden
  15526. */
  15527. _actionManager: ActionManager;
  15528. /**
  15529. * Internal only
  15530. * @hidden
  15531. */
  15532. _evaluationId: number;
  15533. /**
  15534. * Internal only
  15535. * @hidden
  15536. */
  15537. _currentResult: boolean;
  15538. /**
  15539. * Creates a new Condition
  15540. * @param actionManager the manager of the action the condition is applied to
  15541. */
  15542. constructor(actionManager: ActionManager);
  15543. /**
  15544. * Check if the current condition is valid
  15545. * @returns a boolean
  15546. */
  15547. isValid(): boolean;
  15548. /**
  15549. * Internal only
  15550. * @hidden
  15551. */
  15552. _getProperty(propertyPath: string): string;
  15553. /**
  15554. * Internal only
  15555. * @hidden
  15556. */
  15557. _getEffectiveTarget(target: any, propertyPath: string): any;
  15558. /**
  15559. * Serialize placeholder for child classes
  15560. * @returns the serialized object
  15561. */
  15562. serialize(): any;
  15563. /**
  15564. * Internal only
  15565. * @hidden
  15566. */
  15567. protected _serialize(serializedCondition: any): any;
  15568. }
  15569. /**
  15570. * Defines specific conditional operators as extensions of Condition
  15571. */
  15572. export class ValueCondition extends Condition {
  15573. /** path to specify the property of the target the conditional operator uses */
  15574. propertyPath: string;
  15575. /** the value compared by the conditional operator against the current value of the property */
  15576. value: any;
  15577. /** the conditional operator, default ValueCondition.IsEqual */
  15578. operator: number;
  15579. /**
  15580. * Internal only
  15581. * @hidden
  15582. */
  15583. private static _IsEqual;
  15584. /**
  15585. * Internal only
  15586. * @hidden
  15587. */
  15588. private static _IsDifferent;
  15589. /**
  15590. * Internal only
  15591. * @hidden
  15592. */
  15593. private static _IsGreater;
  15594. /**
  15595. * Internal only
  15596. * @hidden
  15597. */
  15598. private static _IsLesser;
  15599. /**
  15600. * returns the number for IsEqual
  15601. */
  15602. static readonly IsEqual: number;
  15603. /**
  15604. * Returns the number for IsDifferent
  15605. */
  15606. static readonly IsDifferent: number;
  15607. /**
  15608. * Returns the number for IsGreater
  15609. */
  15610. static readonly IsGreater: number;
  15611. /**
  15612. * Returns the number for IsLesser
  15613. */
  15614. static readonly IsLesser: number;
  15615. /**
  15616. * Internal only The action manager for the condition
  15617. * @hidden
  15618. */
  15619. _actionManager: ActionManager;
  15620. /**
  15621. * Internal only
  15622. * @hidden
  15623. */
  15624. private _target;
  15625. /**
  15626. * Internal only
  15627. * @hidden
  15628. */
  15629. private _effectiveTarget;
  15630. /**
  15631. * Internal only
  15632. * @hidden
  15633. */
  15634. private _property;
  15635. /**
  15636. * Creates a new ValueCondition
  15637. * @param actionManager manager for the action the condition applies to
  15638. * @param target for the action
  15639. * @param propertyPath path to specify the property of the target the conditional operator uses
  15640. * @param value the value compared by the conditional operator against the current value of the property
  15641. * @param operator the conditional operator, default ValueCondition.IsEqual
  15642. */
  15643. constructor(actionManager: ActionManager, target: any,
  15644. /** path to specify the property of the target the conditional operator uses */
  15645. propertyPath: string,
  15646. /** the value compared by the conditional operator against the current value of the property */
  15647. value: any,
  15648. /** the conditional operator, default ValueCondition.IsEqual */
  15649. operator?: number);
  15650. /**
  15651. * Compares the given value with the property value for the specified conditional operator
  15652. * @returns the result of the comparison
  15653. */
  15654. isValid(): boolean;
  15655. /**
  15656. * Serialize the ValueCondition into a JSON compatible object
  15657. * @returns serialization object
  15658. */
  15659. serialize(): any;
  15660. /**
  15661. * Gets the name of the conditional operator for the ValueCondition
  15662. * @param operator the conditional operator
  15663. * @returns the name
  15664. */
  15665. static GetOperatorName(operator: number): string;
  15666. }
  15667. /**
  15668. * Defines a predicate condition as an extension of Condition
  15669. */
  15670. export class PredicateCondition extends Condition {
  15671. /** defines the predicate function used to validate the condition */
  15672. predicate: () => boolean;
  15673. /**
  15674. * Internal only - manager for action
  15675. * @hidden
  15676. */
  15677. _actionManager: ActionManager;
  15678. /**
  15679. * Creates a new PredicateCondition
  15680. * @param actionManager manager for the action the condition applies to
  15681. * @param predicate defines the predicate function used to validate the condition
  15682. */
  15683. constructor(actionManager: ActionManager,
  15684. /** defines the predicate function used to validate the condition */
  15685. predicate: () => boolean);
  15686. /**
  15687. * @returns the validity of the predicate condition
  15688. */
  15689. isValid(): boolean;
  15690. }
  15691. /**
  15692. * Defines a state condition as an extension of Condition
  15693. */
  15694. export class StateCondition extends Condition {
  15695. /** Value to compare with target state */
  15696. value: string;
  15697. /**
  15698. * Internal only - manager for action
  15699. * @hidden
  15700. */
  15701. _actionManager: ActionManager;
  15702. /**
  15703. * Internal only
  15704. * @hidden
  15705. */
  15706. private _target;
  15707. /**
  15708. * Creates a new StateCondition
  15709. * @param actionManager manager for the action the condition applies to
  15710. * @param target of the condition
  15711. * @param value to compare with target state
  15712. */
  15713. constructor(actionManager: ActionManager, target: any,
  15714. /** Value to compare with target state */
  15715. value: string);
  15716. /**
  15717. * Gets a boolean indicating if the current condition is met
  15718. * @returns the validity of the state
  15719. */
  15720. isValid(): boolean;
  15721. /**
  15722. * Serialize the StateCondition into a JSON compatible object
  15723. * @returns serialization object
  15724. */
  15725. serialize(): any;
  15726. }
  15727. }
  15728. declare module "babylonjs/Actions/directActions" {
  15729. import { Action } from "babylonjs/Actions/action";
  15730. import { Condition } from "babylonjs/Actions/condition";
  15731. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  15732. /**
  15733. * This defines an action responsible to toggle a boolean once triggered.
  15734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15735. */
  15736. export class SwitchBooleanAction extends Action {
  15737. /**
  15738. * The path to the boolean property in the target object
  15739. */
  15740. propertyPath: string;
  15741. private _target;
  15742. private _effectiveTarget;
  15743. private _property;
  15744. /**
  15745. * Instantiate the action
  15746. * @param triggerOptions defines the trigger options
  15747. * @param target defines the object containing the boolean
  15748. * @param propertyPath defines the path to the boolean property in the target object
  15749. * @param condition defines the trigger related conditions
  15750. */
  15751. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  15752. /** @hidden */
  15753. _prepare(): void;
  15754. /**
  15755. * Execute the action toggle the boolean value.
  15756. */
  15757. execute(): void;
  15758. /**
  15759. * Serializes the actions and its related information.
  15760. * @param parent defines the object to serialize in
  15761. * @returns the serialized object
  15762. */
  15763. serialize(parent: any): any;
  15764. }
  15765. /**
  15766. * This defines an action responsible to set a the state field of the target
  15767. * to a desired value once triggered.
  15768. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15769. */
  15770. export class SetStateAction extends Action {
  15771. /**
  15772. * The value to store in the state field.
  15773. */
  15774. value: string;
  15775. private _target;
  15776. /**
  15777. * Instantiate the action
  15778. * @param triggerOptions defines the trigger options
  15779. * @param target defines the object containing the state property
  15780. * @param value defines the value to store in the state field
  15781. * @param condition defines the trigger related conditions
  15782. */
  15783. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  15784. /**
  15785. * Execute the action and store the value on the target state property.
  15786. */
  15787. execute(): void;
  15788. /**
  15789. * Serializes the actions and its related information.
  15790. * @param parent defines the object to serialize in
  15791. * @returns the serialized object
  15792. */
  15793. serialize(parent: any): any;
  15794. }
  15795. /**
  15796. * This defines an action responsible to set a property of the target
  15797. * to a desired value once triggered.
  15798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15799. */
  15800. export class SetValueAction extends Action {
  15801. /**
  15802. * The path of the property to set in the target.
  15803. */
  15804. propertyPath: string;
  15805. /**
  15806. * The value to set in the property
  15807. */
  15808. value: any;
  15809. private _target;
  15810. private _effectiveTarget;
  15811. private _property;
  15812. /**
  15813. * Instantiate the action
  15814. * @param triggerOptions defines the trigger options
  15815. * @param target defines the object containing the property
  15816. * @param propertyPath defines the path of the property to set in the target
  15817. * @param value defines the value to set in the property
  15818. * @param condition defines the trigger related conditions
  15819. */
  15820. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15821. /** @hidden */
  15822. _prepare(): void;
  15823. /**
  15824. * Execute the action and set the targetted property to the desired value.
  15825. */
  15826. execute(): void;
  15827. /**
  15828. * Serializes the actions and its related information.
  15829. * @param parent defines the object to serialize in
  15830. * @returns the serialized object
  15831. */
  15832. serialize(parent: any): any;
  15833. }
  15834. /**
  15835. * This defines an action responsible to increment the target value
  15836. * to a desired value once triggered.
  15837. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15838. */
  15839. export class IncrementValueAction extends Action {
  15840. /**
  15841. * The path of the property to increment in the target.
  15842. */
  15843. propertyPath: string;
  15844. /**
  15845. * The value we should increment the property by.
  15846. */
  15847. value: any;
  15848. private _target;
  15849. private _effectiveTarget;
  15850. private _property;
  15851. /**
  15852. * Instantiate the action
  15853. * @param triggerOptions defines the trigger options
  15854. * @param target defines the object containing the property
  15855. * @param propertyPath defines the path of the property to increment in the target
  15856. * @param value defines the value value we should increment the property by
  15857. * @param condition defines the trigger related conditions
  15858. */
  15859. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15860. /** @hidden */
  15861. _prepare(): void;
  15862. /**
  15863. * Execute the action and increment the target of the value amount.
  15864. */
  15865. execute(): void;
  15866. /**
  15867. * Serializes the actions and its related information.
  15868. * @param parent defines the object to serialize in
  15869. * @returns the serialized object
  15870. */
  15871. serialize(parent: any): any;
  15872. }
  15873. /**
  15874. * This defines an action responsible to start an animation once triggered.
  15875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15876. */
  15877. export class PlayAnimationAction extends Action {
  15878. /**
  15879. * Where the animation should start (animation frame)
  15880. */
  15881. from: number;
  15882. /**
  15883. * Where the animation should stop (animation frame)
  15884. */
  15885. to: number;
  15886. /**
  15887. * Define if the animation should loop or stop after the first play.
  15888. */
  15889. loop?: boolean;
  15890. private _target;
  15891. /**
  15892. * Instantiate the action
  15893. * @param triggerOptions defines the trigger options
  15894. * @param target defines the target animation or animation name
  15895. * @param from defines from where the animation should start (animation frame)
  15896. * @param end defines where the animation should stop (animation frame)
  15897. * @param loop defines if the animation should loop or stop after the first play
  15898. * @param condition defines the trigger related conditions
  15899. */
  15900. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  15901. /** @hidden */
  15902. _prepare(): void;
  15903. /**
  15904. * Execute the action and play the animation.
  15905. */
  15906. execute(): void;
  15907. /**
  15908. * Serializes the actions and its related information.
  15909. * @param parent defines the object to serialize in
  15910. * @returns the serialized object
  15911. */
  15912. serialize(parent: any): any;
  15913. }
  15914. /**
  15915. * This defines an action responsible to stop an animation once triggered.
  15916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15917. */
  15918. export class StopAnimationAction extends Action {
  15919. private _target;
  15920. /**
  15921. * Instantiate the action
  15922. * @param triggerOptions defines the trigger options
  15923. * @param target defines the target animation or animation name
  15924. * @param condition defines the trigger related conditions
  15925. */
  15926. constructor(triggerOptions: any, target: any, condition?: Condition);
  15927. /** @hidden */
  15928. _prepare(): void;
  15929. /**
  15930. * Execute the action and stop the animation.
  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. * This defines an action responsible that does nothing once triggered.
  15942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15943. */
  15944. export class DoNothingAction extends Action {
  15945. /**
  15946. * Instantiate the action
  15947. * @param triggerOptions defines the trigger options
  15948. * @param condition defines the trigger related conditions
  15949. */
  15950. constructor(triggerOptions?: any, condition?: Condition);
  15951. /**
  15952. * Execute the action and do nothing.
  15953. */
  15954. execute(): void;
  15955. /**
  15956. * Serializes the actions and its related information.
  15957. * @param parent defines the object to serialize in
  15958. * @returns the serialized object
  15959. */
  15960. serialize(parent: any): any;
  15961. }
  15962. /**
  15963. * This defines an action responsible to trigger several actions once triggered.
  15964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15965. */
  15966. export class CombineAction extends Action {
  15967. /**
  15968. * The list of aggregated animations to run.
  15969. */
  15970. children: Action[];
  15971. /**
  15972. * Instantiate the action
  15973. * @param triggerOptions defines the trigger options
  15974. * @param children defines the list of aggregated animations to run
  15975. * @param condition defines the trigger related conditions
  15976. */
  15977. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  15978. /** @hidden */
  15979. _prepare(): void;
  15980. /**
  15981. * Execute the action and executes all the aggregated actions.
  15982. */
  15983. execute(evt: ActionEvent): void;
  15984. /**
  15985. * Serializes the actions and its related information.
  15986. * @param parent defines the object to serialize in
  15987. * @returns the serialized object
  15988. */
  15989. serialize(parent: any): any;
  15990. }
  15991. /**
  15992. * This defines an action responsible to run code (external event) once triggered.
  15993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15994. */
  15995. export class ExecuteCodeAction extends Action {
  15996. /**
  15997. * The callback function to run.
  15998. */
  15999. func: (evt: ActionEvent) => void;
  16000. /**
  16001. * Instantiate the action
  16002. * @param triggerOptions defines the trigger options
  16003. * @param func defines the callback function to run
  16004. * @param condition defines the trigger related conditions
  16005. */
  16006. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  16007. /**
  16008. * Execute the action and run the attached code.
  16009. */
  16010. execute(evt: ActionEvent): void;
  16011. }
  16012. /**
  16013. * This defines an action responsible to set the parent property of the target once triggered.
  16014. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  16015. */
  16016. export class SetParentAction extends Action {
  16017. private _parent;
  16018. private _target;
  16019. /**
  16020. * Instantiate the action
  16021. * @param triggerOptions defines the trigger options
  16022. * @param target defines the target containing the parent property
  16023. * @param parent defines from where the animation should start (animation frame)
  16024. * @param condition defines the trigger related conditions
  16025. */
  16026. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  16027. /** @hidden */
  16028. _prepare(): void;
  16029. /**
  16030. * Execute the action and set the parent property.
  16031. */
  16032. execute(): void;
  16033. /**
  16034. * Serializes the actions and its related information.
  16035. * @param parent defines the object to serialize in
  16036. * @returns the serialized object
  16037. */
  16038. serialize(parent: any): any;
  16039. }
  16040. }
  16041. declare module "babylonjs/Actions/actionManager" {
  16042. import { Nullable } from "babylonjs/types";
  16043. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16044. import { Scene } from "babylonjs/scene";
  16045. import { IAction } from "babylonjs/Actions/action";
  16046. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  16047. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  16048. /**
  16049. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  16050. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  16051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  16052. */
  16053. export class ActionManager extends AbstractActionManager {
  16054. /**
  16055. * Nothing
  16056. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16057. */
  16058. static readonly NothingTrigger: number;
  16059. /**
  16060. * On pick
  16061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16062. */
  16063. static readonly OnPickTrigger: number;
  16064. /**
  16065. * On left pick
  16066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16067. */
  16068. static readonly OnLeftPickTrigger: number;
  16069. /**
  16070. * On right pick
  16071. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16072. */
  16073. static readonly OnRightPickTrigger: number;
  16074. /**
  16075. * On center pick
  16076. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16077. */
  16078. static readonly OnCenterPickTrigger: number;
  16079. /**
  16080. * On pick down
  16081. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16082. */
  16083. static readonly OnPickDownTrigger: number;
  16084. /**
  16085. * On double pick
  16086. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16087. */
  16088. static readonly OnDoublePickTrigger: number;
  16089. /**
  16090. * On pick up
  16091. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16092. */
  16093. static readonly OnPickUpTrigger: number;
  16094. /**
  16095. * On pick out.
  16096. * This trigger will only be raised if you also declared a OnPickDown
  16097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16098. */
  16099. static readonly OnPickOutTrigger: number;
  16100. /**
  16101. * On long press
  16102. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16103. */
  16104. static readonly OnLongPressTrigger: number;
  16105. /**
  16106. * On pointer over
  16107. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16108. */
  16109. static readonly OnPointerOverTrigger: number;
  16110. /**
  16111. * On pointer out
  16112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16113. */
  16114. static readonly OnPointerOutTrigger: number;
  16115. /**
  16116. * On every frame
  16117. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16118. */
  16119. static readonly OnEveryFrameTrigger: number;
  16120. /**
  16121. * On intersection enter
  16122. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16123. */
  16124. static readonly OnIntersectionEnterTrigger: number;
  16125. /**
  16126. * On intersection exit
  16127. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16128. */
  16129. static readonly OnIntersectionExitTrigger: number;
  16130. /**
  16131. * On key down
  16132. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16133. */
  16134. static readonly OnKeyDownTrigger: number;
  16135. /**
  16136. * On key up
  16137. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16138. */
  16139. static readonly OnKeyUpTrigger: number;
  16140. private _scene;
  16141. /**
  16142. * Creates a new action manager
  16143. * @param scene defines the hosting scene
  16144. */
  16145. constructor(scene: Scene);
  16146. /**
  16147. * Releases all associated resources
  16148. */
  16149. dispose(): void;
  16150. /**
  16151. * Gets hosting scene
  16152. * @returns the hosting scene
  16153. */
  16154. getScene(): Scene;
  16155. /**
  16156. * Does this action manager handles actions of any of the given triggers
  16157. * @param triggers defines the triggers to be tested
  16158. * @return a boolean indicating whether one (or more) of the triggers is handled
  16159. */
  16160. hasSpecificTriggers(triggers: number[]): boolean;
  16161. /**
  16162. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  16163. * speed.
  16164. * @param triggerA defines the trigger to be tested
  16165. * @param triggerB defines the trigger to be tested
  16166. * @return a boolean indicating whether one (or more) of the triggers is handled
  16167. */
  16168. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  16169. /**
  16170. * Does this action manager handles actions of a given trigger
  16171. * @param trigger defines the trigger to be tested
  16172. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  16173. * @return whether the trigger is handled
  16174. */
  16175. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  16176. /**
  16177. * Does this action manager has pointer triggers
  16178. */
  16179. readonly hasPointerTriggers: boolean;
  16180. /**
  16181. * Does this action manager has pick triggers
  16182. */
  16183. readonly hasPickTriggers: boolean;
  16184. /**
  16185. * Registers an action to this action manager
  16186. * @param action defines the action to be registered
  16187. * @return the action amended (prepared) after registration
  16188. */
  16189. registerAction(action: IAction): Nullable<IAction>;
  16190. /**
  16191. * Unregisters an action to this action manager
  16192. * @param action defines the action to be unregistered
  16193. * @return a boolean indicating whether the action has been unregistered
  16194. */
  16195. unregisterAction(action: IAction): Boolean;
  16196. /**
  16197. * Process a specific trigger
  16198. * @param trigger defines the trigger to process
  16199. * @param evt defines the event details to be processed
  16200. */
  16201. processTrigger(trigger: number, evt?: IActionEvent): void;
  16202. /** @hidden */
  16203. _getEffectiveTarget(target: any, propertyPath: string): any;
  16204. /** @hidden */
  16205. _getProperty(propertyPath: string): string;
  16206. /**
  16207. * Serialize this manager to a JSON object
  16208. * @param name defines the property name to store this manager
  16209. * @returns a JSON representation of this manager
  16210. */
  16211. serialize(name: string): any;
  16212. /**
  16213. * Creates a new ActionManager from a JSON data
  16214. * @param parsedActions defines the JSON data to read from
  16215. * @param object defines the hosting mesh
  16216. * @param scene defines the hosting scene
  16217. */
  16218. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  16219. /**
  16220. * Get a trigger name by index
  16221. * @param trigger defines the trigger index
  16222. * @returns a trigger name
  16223. */
  16224. static GetTriggerName(trigger: number): string;
  16225. }
  16226. }
  16227. declare module "babylonjs/Culling/ray" {
  16228. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  16229. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  16230. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16231. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16232. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  16233. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  16234. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  16235. /**
  16236. * Class representing a ray with position and direction
  16237. */
  16238. export class Ray {
  16239. /** origin point */
  16240. origin: Vector3;
  16241. /** direction */
  16242. direction: Vector3;
  16243. /** length of the ray */
  16244. length: number;
  16245. private static readonly TmpVector3;
  16246. private _tmpRay;
  16247. /**
  16248. * Creates a new ray
  16249. * @param origin origin point
  16250. * @param direction direction
  16251. * @param length length of the ray
  16252. */
  16253. constructor(
  16254. /** origin point */
  16255. origin: Vector3,
  16256. /** direction */
  16257. direction: Vector3,
  16258. /** length of the ray */
  16259. length?: number);
  16260. /**
  16261. * Checks if the ray intersects a box
  16262. * @param minimum bound of the box
  16263. * @param maximum bound of the box
  16264. * @param intersectionTreshold extra extend to be added to the box in all direction
  16265. * @returns if the box was hit
  16266. */
  16267. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  16268. /**
  16269. * Checks if the ray intersects a box
  16270. * @param box the bounding box to check
  16271. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  16272. * @returns if the box was hit
  16273. */
  16274. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  16275. /**
  16276. * If the ray hits a sphere
  16277. * @param sphere the bounding sphere to check
  16278. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  16279. * @returns true if it hits the sphere
  16280. */
  16281. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  16282. /**
  16283. * If the ray hits a triange
  16284. * @param vertex0 triangle vertex
  16285. * @param vertex1 triangle vertex
  16286. * @param vertex2 triangle vertex
  16287. * @returns intersection information if hit
  16288. */
  16289. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  16290. /**
  16291. * Checks if ray intersects a plane
  16292. * @param plane the plane to check
  16293. * @returns the distance away it was hit
  16294. */
  16295. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  16296. /**
  16297. * Checks if ray intersects a mesh
  16298. * @param mesh the mesh to check
  16299. * @param fastCheck if only the bounding box should checked
  16300. * @returns picking info of the intersecton
  16301. */
  16302. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  16303. /**
  16304. * Checks if ray intersects a mesh
  16305. * @param meshes the meshes to check
  16306. * @param fastCheck if only the bounding box should checked
  16307. * @param results array to store result in
  16308. * @returns Array of picking infos
  16309. */
  16310. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  16311. private _comparePickingInfo;
  16312. private static smallnum;
  16313. private static rayl;
  16314. /**
  16315. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  16316. * @param sega the first point of the segment to test the intersection against
  16317. * @param segb the second point of the segment to test the intersection against
  16318. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  16319. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  16320. */
  16321. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  16322. /**
  16323. * Update the ray from viewport position
  16324. * @param x position
  16325. * @param y y position
  16326. * @param viewportWidth viewport width
  16327. * @param viewportHeight viewport height
  16328. * @param world world matrix
  16329. * @param view view matrix
  16330. * @param projection projection matrix
  16331. * @returns this ray updated
  16332. */
  16333. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16334. /**
  16335. * Creates a ray with origin and direction of 0,0,0
  16336. * @returns the new ray
  16337. */
  16338. static Zero(): Ray;
  16339. /**
  16340. * Creates a new ray from screen space and viewport
  16341. * @param x position
  16342. * @param y y position
  16343. * @param viewportWidth viewport width
  16344. * @param viewportHeight viewport height
  16345. * @param world world matrix
  16346. * @param view view matrix
  16347. * @param projection projection matrix
  16348. * @returns new ray
  16349. */
  16350. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16351. /**
  16352. * 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
  16353. * transformed to the given world matrix.
  16354. * @param origin The origin point
  16355. * @param end The end point
  16356. * @param world a matrix to transform the ray to. Default is the identity matrix.
  16357. * @returns the new ray
  16358. */
  16359. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  16360. /**
  16361. * Transforms a ray by a matrix
  16362. * @param ray ray to transform
  16363. * @param matrix matrix to apply
  16364. * @returns the resulting new ray
  16365. */
  16366. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  16367. /**
  16368. * Transforms a ray by a matrix
  16369. * @param ray ray to transform
  16370. * @param matrix matrix to apply
  16371. * @param result ray to store result in
  16372. */
  16373. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  16374. /**
  16375. * Unproject a ray from screen space to object space
  16376. * @param sourceX defines the screen space x coordinate to use
  16377. * @param sourceY defines the screen space y coordinate to use
  16378. * @param viewportWidth defines the current width of the viewport
  16379. * @param viewportHeight defines the current height of the viewport
  16380. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16381. * @param view defines the view matrix to use
  16382. * @param projection defines the projection matrix to use
  16383. */
  16384. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  16385. }
  16386. /**
  16387. * Type used to define predicate used to select faces when a mesh intersection is detected
  16388. */
  16389. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  16390. module "babylonjs/scene" {
  16391. interface Scene {
  16392. /** @hidden */
  16393. _tempPickingRay: Nullable<Ray>;
  16394. /** @hidden */
  16395. _cachedRayForTransform: Ray;
  16396. /** @hidden */
  16397. _pickWithRayInverseMatrix: Matrix;
  16398. /** @hidden */
  16399. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  16400. /** @hidden */
  16401. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  16402. }
  16403. }
  16404. }
  16405. declare module "babylonjs/Sprites/spriteSceneComponent" {
  16406. import { Nullable } from "babylonjs/types";
  16407. import { Observable } from "babylonjs/Misc/observable";
  16408. import { Scene } from "babylonjs/scene";
  16409. import { Sprite } from "babylonjs/Sprites/sprite";
  16410. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16411. import { Ray } from "babylonjs/Culling/ray";
  16412. import { Camera } from "babylonjs/Cameras/camera";
  16413. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16414. import { ISceneComponent } from "babylonjs/sceneComponent";
  16415. module "babylonjs/scene" {
  16416. interface Scene {
  16417. /** @hidden */
  16418. _pointerOverSprite: Nullable<Sprite>;
  16419. /** @hidden */
  16420. _pickedDownSprite: Nullable<Sprite>;
  16421. /** @hidden */
  16422. _tempSpritePickingRay: Nullable<Ray>;
  16423. /**
  16424. * All of the sprite managers added to this scene
  16425. * @see http://doc.babylonjs.com/babylon101/sprites
  16426. */
  16427. spriteManagers: Array<ISpriteManager>;
  16428. /**
  16429. * An event triggered when sprites rendering is about to start
  16430. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16431. */
  16432. onBeforeSpritesRenderingObservable: Observable<Scene>;
  16433. /**
  16434. * An event triggered when sprites rendering is done
  16435. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16436. */
  16437. onAfterSpritesRenderingObservable: Observable<Scene>;
  16438. /** @hidden */
  16439. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16440. /** Launch a ray to try to pick a sprite in the scene
  16441. * @param x position on screen
  16442. * @param y position on screen
  16443. * @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
  16444. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16445. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  16446. * @returns a PickingInfo
  16447. */
  16448. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16449. /** Use the given ray to pick a sprite in the scene
  16450. * @param ray The ray (in world space) to use to pick meshes
  16451. * @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
  16452. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16453. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  16454. * @returns a PickingInfo
  16455. */
  16456. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16457. /**
  16458. * Force the sprite under the pointer
  16459. * @param sprite defines the sprite to use
  16460. */
  16461. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  16462. /**
  16463. * Gets the sprite under the pointer
  16464. * @returns a Sprite or null if no sprite is under the pointer
  16465. */
  16466. getPointerOverSprite(): Nullable<Sprite>;
  16467. }
  16468. }
  16469. /**
  16470. * Defines the sprite scene component responsible to manage sprites
  16471. * in a given scene.
  16472. */
  16473. export class SpriteSceneComponent implements ISceneComponent {
  16474. /**
  16475. * The component name helpfull to identify the component in the list of scene components.
  16476. */
  16477. readonly name: string;
  16478. /**
  16479. * The scene the component belongs to.
  16480. */
  16481. scene: Scene;
  16482. /** @hidden */
  16483. private _spritePredicate;
  16484. /**
  16485. * Creates a new instance of the component for the given scene
  16486. * @param scene Defines the scene to register the component in
  16487. */
  16488. constructor(scene: Scene);
  16489. /**
  16490. * Registers the component in a given scene
  16491. */
  16492. register(): void;
  16493. /**
  16494. * Rebuilds the elements related to this component in case of
  16495. * context lost for instance.
  16496. */
  16497. rebuild(): void;
  16498. /**
  16499. * Disposes the component and the associated ressources.
  16500. */
  16501. dispose(): void;
  16502. private _pickSpriteButKeepRay;
  16503. private _pointerMove;
  16504. private _pointerDown;
  16505. private _pointerUp;
  16506. }
  16507. }
  16508. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  16509. /** @hidden */
  16510. export var fogFragmentDeclaration: {
  16511. name: string;
  16512. shader: string;
  16513. };
  16514. }
  16515. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  16516. /** @hidden */
  16517. export var fogFragment: {
  16518. name: string;
  16519. shader: string;
  16520. };
  16521. }
  16522. declare module "babylonjs/Shaders/sprites.fragment" {
  16523. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  16524. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  16525. /** @hidden */
  16526. export var spritesPixelShader: {
  16527. name: string;
  16528. shader: string;
  16529. };
  16530. }
  16531. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  16532. /** @hidden */
  16533. export var fogVertexDeclaration: {
  16534. name: string;
  16535. shader: string;
  16536. };
  16537. }
  16538. declare module "babylonjs/Shaders/sprites.vertex" {
  16539. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  16540. /** @hidden */
  16541. export var spritesVertexShader: {
  16542. name: string;
  16543. shader: string;
  16544. };
  16545. }
  16546. declare module "babylonjs/Sprites/spriteManager" {
  16547. import { IDisposable, Scene } from "babylonjs/scene";
  16548. import { Nullable } from "babylonjs/types";
  16549. import { Observable } from "babylonjs/Misc/observable";
  16550. import { Sprite } from "babylonjs/Sprites/sprite";
  16551. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16552. import { Camera } from "babylonjs/Cameras/camera";
  16553. import { Texture } from "babylonjs/Materials/Textures/texture";
  16554. import "babylonjs/Shaders/sprites.fragment";
  16555. import "babylonjs/Shaders/sprites.vertex";
  16556. import { Ray } from "babylonjs/Culling/ray";
  16557. /**
  16558. * Defines the minimum interface to fullfil in order to be a sprite manager.
  16559. */
  16560. export interface ISpriteManager extends IDisposable {
  16561. /**
  16562. * Restricts the camera to viewing objects with the same layerMask.
  16563. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  16564. */
  16565. layerMask: number;
  16566. /**
  16567. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  16568. */
  16569. isPickable: boolean;
  16570. /**
  16571. * Specifies the rendering group id for this mesh (0 by default)
  16572. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  16573. */
  16574. renderingGroupId: number;
  16575. /**
  16576. * Defines the list of sprites managed by the manager.
  16577. */
  16578. sprites: Array<Sprite>;
  16579. /**
  16580. * Tests the intersection of a sprite with a specific ray.
  16581. * @param ray The ray we are sending to test the collision
  16582. * @param camera The camera space we are sending rays in
  16583. * @param predicate A predicate allowing excluding sprites from the list of object to test
  16584. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  16585. * @returns picking info or null.
  16586. */
  16587. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16588. /**
  16589. * Renders the list of sprites on screen.
  16590. */
  16591. render(): void;
  16592. }
  16593. /**
  16594. * Class used to manage multiple sprites on the same spritesheet
  16595. * @see http://doc.babylonjs.com/babylon101/sprites
  16596. */
  16597. export class SpriteManager implements ISpriteManager {
  16598. /** defines the manager's name */
  16599. name: string;
  16600. /** Gets the list of sprites */
  16601. sprites: Sprite[];
  16602. /** Gets or sets the rendering group id (0 by default) */
  16603. renderingGroupId: number;
  16604. /** Gets or sets camera layer mask */
  16605. layerMask: number;
  16606. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  16607. fogEnabled: boolean;
  16608. /** Gets or sets a boolean indicating if the sprites are pickable */
  16609. isPickable: boolean;
  16610. /** Defines the default width of a cell in the spritesheet */
  16611. cellWidth: number;
  16612. /** Defines the default height of a cell in the spritesheet */
  16613. cellHeight: number;
  16614. /**
  16615. * An event triggered when the manager is disposed.
  16616. */
  16617. onDisposeObservable: Observable<SpriteManager>;
  16618. private _onDisposeObserver;
  16619. /**
  16620. * Callback called when the manager is disposed
  16621. */
  16622. onDispose: () => void;
  16623. private _capacity;
  16624. private _spriteTexture;
  16625. private _epsilon;
  16626. private _scene;
  16627. private _vertexData;
  16628. private _buffer;
  16629. private _vertexBuffers;
  16630. private _indexBuffer;
  16631. private _effectBase;
  16632. private _effectFog;
  16633. /**
  16634. * Gets or sets the spritesheet texture
  16635. */
  16636. texture: Texture;
  16637. /**
  16638. * Creates a new sprite manager
  16639. * @param name defines the manager's name
  16640. * @param imgUrl defines the sprite sheet url
  16641. * @param capacity defines the maximum allowed number of sprites
  16642. * @param cellSize defines the size of a sprite cell
  16643. * @param scene defines the hosting scene
  16644. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  16645. * @param samplingMode defines the smapling mode to use with spritesheet
  16646. */
  16647. constructor(
  16648. /** defines the manager's name */
  16649. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  16650. private _appendSpriteVertex;
  16651. /**
  16652. * Intersects the sprites with a ray
  16653. * @param ray defines the ray to intersect with
  16654. * @param camera defines the current active camera
  16655. * @param predicate defines a predicate used to select candidate sprites
  16656. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  16657. * @returns null if no hit or a PickingInfo
  16658. */
  16659. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16660. /**
  16661. * Render all child sprites
  16662. */
  16663. render(): void;
  16664. /**
  16665. * Release associated resources
  16666. */
  16667. dispose(): void;
  16668. }
  16669. }
  16670. declare module "babylonjs/Sprites/sprite" {
  16671. import { Vector3, Color4 } from "babylonjs/Maths/math";
  16672. import { Nullable } from "babylonjs/types";
  16673. import { ActionManager } from "babylonjs/Actions/actionManager";
  16674. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16675. /**
  16676. * Class used to represent a sprite
  16677. * @see http://doc.babylonjs.com/babylon101/sprites
  16678. */
  16679. export class Sprite {
  16680. /** defines the name */
  16681. name: string;
  16682. /** Gets or sets the current world position */
  16683. position: Vector3;
  16684. /** Gets or sets the main color */
  16685. color: Color4;
  16686. /** Gets or sets the width */
  16687. width: number;
  16688. /** Gets or sets the height */
  16689. height: number;
  16690. /** Gets or sets rotation angle */
  16691. angle: number;
  16692. /** Gets or sets the cell index in the sprite sheet */
  16693. cellIndex: number;
  16694. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  16695. invertU: number;
  16696. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  16697. invertV: number;
  16698. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  16699. disposeWhenFinishedAnimating: boolean;
  16700. /** Gets the list of attached animations */
  16701. animations: Animation[];
  16702. /** Gets or sets a boolean indicating if the sprite can be picked */
  16703. isPickable: boolean;
  16704. /**
  16705. * Gets or sets the associated action manager
  16706. */
  16707. actionManager: Nullable<ActionManager>;
  16708. private _animationStarted;
  16709. private _loopAnimation;
  16710. private _fromIndex;
  16711. private _toIndex;
  16712. private _delay;
  16713. private _direction;
  16714. private _manager;
  16715. private _time;
  16716. private _onAnimationEnd;
  16717. /**
  16718. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  16719. */
  16720. isVisible: boolean;
  16721. /**
  16722. * Gets or sets the sprite size
  16723. */
  16724. size: number;
  16725. /**
  16726. * Creates a new Sprite
  16727. * @param name defines the name
  16728. * @param manager defines the manager
  16729. */
  16730. constructor(
  16731. /** defines the name */
  16732. name: string, manager: ISpriteManager);
  16733. /**
  16734. * Starts an animation
  16735. * @param from defines the initial key
  16736. * @param to defines the end key
  16737. * @param loop defines if the animation must loop
  16738. * @param delay defines the start delay (in ms)
  16739. * @param onAnimationEnd defines a callback to call when animation ends
  16740. */
  16741. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  16742. /** Stops current animation (if any) */
  16743. stopAnimation(): void;
  16744. /** @hidden */
  16745. _animate(deltaTime: number): void;
  16746. /** Release associated resources */
  16747. dispose(): void;
  16748. }
  16749. }
  16750. declare module "babylonjs/Collisions/pickingInfo" {
  16751. import { Nullable } from "babylonjs/types";
  16752. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  16753. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16754. import { Sprite } from "babylonjs/Sprites/sprite";
  16755. import { Ray } from "babylonjs/Culling/ray";
  16756. /**
  16757. * Information about the result of picking within a scene
  16758. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  16759. */
  16760. export class PickingInfo {
  16761. /** @hidden */
  16762. _pickingUnavailable: boolean;
  16763. /**
  16764. * If the pick collided with an object
  16765. */
  16766. hit: boolean;
  16767. /**
  16768. * Distance away where the pick collided
  16769. */
  16770. distance: number;
  16771. /**
  16772. * The location of pick collision
  16773. */
  16774. pickedPoint: Nullable<Vector3>;
  16775. /**
  16776. * The mesh corresponding the the pick collision
  16777. */
  16778. pickedMesh: Nullable<AbstractMesh>;
  16779. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  16780. bu: number;
  16781. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  16782. bv: number;
  16783. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  16784. faceId: number;
  16785. /** Id of the the submesh that was picked */
  16786. subMeshId: number;
  16787. /** If a sprite was picked, this will be the sprite the pick collided with */
  16788. pickedSprite: Nullable<Sprite>;
  16789. /**
  16790. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  16791. */
  16792. originMesh: Nullable<AbstractMesh>;
  16793. /**
  16794. * The ray that was used to perform the picking.
  16795. */
  16796. ray: Nullable<Ray>;
  16797. /**
  16798. * Gets the normal correspodning to the face the pick collided with
  16799. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  16800. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  16801. * @returns The normal correspodning to the face the pick collided with
  16802. */
  16803. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  16804. /**
  16805. * Gets the texture coordinates of where the pick occured
  16806. * @returns the vector containing the coordnates of the texture
  16807. */
  16808. getTextureCoordinates(): Nullable<Vector2>;
  16809. }
  16810. }
  16811. declare module "babylonjs/Events/pointerEvents" {
  16812. import { Nullable } from "babylonjs/types";
  16813. import { Vector2 } from "babylonjs/Maths/math";
  16814. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16815. import { Ray } from "babylonjs/Culling/ray";
  16816. /**
  16817. * Gather the list of pointer event types as constants.
  16818. */
  16819. export class PointerEventTypes {
  16820. /**
  16821. * 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.
  16822. */
  16823. static readonly POINTERDOWN: number;
  16824. /**
  16825. * The pointerup event is fired when a pointer is no longer active.
  16826. */
  16827. static readonly POINTERUP: number;
  16828. /**
  16829. * The pointermove event is fired when a pointer changes coordinates.
  16830. */
  16831. static readonly POINTERMOVE: number;
  16832. /**
  16833. * The pointerwheel event is fired when a mouse wheel has been rotated.
  16834. */
  16835. static readonly POINTERWHEEL: number;
  16836. /**
  16837. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  16838. */
  16839. static readonly POINTERPICK: number;
  16840. /**
  16841. * The pointertap event is fired when a the object has been touched and released without drag.
  16842. */
  16843. static readonly POINTERTAP: number;
  16844. /**
  16845. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  16846. */
  16847. static readonly POINTERDOUBLETAP: number;
  16848. }
  16849. /**
  16850. * Base class of pointer info types.
  16851. */
  16852. export class PointerInfoBase {
  16853. /**
  16854. * Defines the type of event (PointerEventTypes)
  16855. */
  16856. type: number;
  16857. /**
  16858. * Defines the related dom event
  16859. */
  16860. event: PointerEvent | MouseWheelEvent;
  16861. /**
  16862. * Instantiates the base class of pointers info.
  16863. * @param type Defines the type of event (PointerEventTypes)
  16864. * @param event Defines the related dom event
  16865. */
  16866. constructor(
  16867. /**
  16868. * Defines the type of event (PointerEventTypes)
  16869. */
  16870. type: number,
  16871. /**
  16872. * Defines the related dom event
  16873. */
  16874. event: PointerEvent | MouseWheelEvent);
  16875. }
  16876. /**
  16877. * This class is used to store pointer related info for the onPrePointerObservable event.
  16878. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  16879. */
  16880. export class PointerInfoPre extends PointerInfoBase {
  16881. /**
  16882. * Ray from a pointer if availible (eg. 6dof controller)
  16883. */
  16884. ray: Nullable<Ray>;
  16885. /**
  16886. * Defines the local position of the pointer on the canvas.
  16887. */
  16888. localPosition: Vector2;
  16889. /**
  16890. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  16891. */
  16892. skipOnPointerObservable: boolean;
  16893. /**
  16894. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  16895. * @param type Defines the type of event (PointerEventTypes)
  16896. * @param event Defines the related dom event
  16897. * @param localX Defines the local x coordinates of the pointer when the event occured
  16898. * @param localY Defines the local y coordinates of the pointer when the event occured
  16899. */
  16900. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  16901. }
  16902. /**
  16903. * This type contains all the data related to a pointer event in Babylon.js.
  16904. * 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.
  16905. */
  16906. export class PointerInfo extends PointerInfoBase {
  16907. /**
  16908. * Defines the picking info associated to the info (if any)\
  16909. */
  16910. pickInfo: Nullable<PickingInfo>;
  16911. /**
  16912. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  16913. * @param type Defines the type of event (PointerEventTypes)
  16914. * @param event Defines the related dom event
  16915. * @param pickInfo Defines the picking info associated to the info (if any)\
  16916. */
  16917. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  16918. /**
  16919. * Defines the picking info associated to the info (if any)\
  16920. */
  16921. pickInfo: Nullable<PickingInfo>);
  16922. }
  16923. /**
  16924. * Data relating to a touch event on the screen.
  16925. */
  16926. export interface PointerTouch {
  16927. /**
  16928. * X coordinate of touch.
  16929. */
  16930. x: number;
  16931. /**
  16932. * Y coordinate of touch.
  16933. */
  16934. y: number;
  16935. /**
  16936. * Id of touch. Unique for each finger.
  16937. */
  16938. pointerId: number;
  16939. /**
  16940. * Event type passed from DOM.
  16941. */
  16942. type: any;
  16943. }
  16944. }
  16945. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  16946. import { Observable } from "babylonjs/Misc/observable";
  16947. import { Nullable } from "babylonjs/types";
  16948. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  16949. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  16950. /**
  16951. * Manage the mouse inputs to control the movement of a free camera.
  16952. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16953. */
  16954. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  16955. /**
  16956. * Define if touch is enabled in the mouse input
  16957. */
  16958. touchEnabled: boolean;
  16959. /**
  16960. * Defines the camera the input is attached to.
  16961. */
  16962. camera: FreeCamera;
  16963. /**
  16964. * Defines the buttons associated with the input to handle camera move.
  16965. */
  16966. buttons: number[];
  16967. /**
  16968. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  16969. */
  16970. angularSensibility: number;
  16971. private _pointerInput;
  16972. private _onMouseMove;
  16973. private _observer;
  16974. private previousPosition;
  16975. /**
  16976. * Observable for when a pointer move event occurs containing the move offset
  16977. */
  16978. onPointerMovedObservable: Observable<{
  16979. offsetX: number;
  16980. offsetY: number;
  16981. }>;
  16982. /**
  16983. * @hidden
  16984. * If the camera should be rotated automatically based on pointer movement
  16985. */
  16986. _allowCameraRotation: boolean;
  16987. /**
  16988. * Manage the mouse inputs to control the movement of a free camera.
  16989. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16990. * @param touchEnabled Defines if touch is enabled or not
  16991. */
  16992. constructor(
  16993. /**
  16994. * Define if touch is enabled in the mouse input
  16995. */
  16996. touchEnabled?: boolean);
  16997. /**
  16998. * Attach the input controls to a specific dom element to get the input from.
  16999. * @param element Defines the element the controls should be listened from
  17000. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  17001. */
  17002. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17003. /**
  17004. * Called on JS contextmenu event.
  17005. * Override this method to provide functionality.
  17006. */
  17007. protected onContextMenu(evt: PointerEvent): void;
  17008. /**
  17009. * Detach the current controls from the specified dom element.
  17010. * @param element Defines the element to stop listening the inputs from
  17011. */
  17012. detachControl(element: Nullable<HTMLElement>): void;
  17013. /**
  17014. * Gets the class name of the current intput.
  17015. * @returns the class name
  17016. */
  17017. getClassName(): string;
  17018. /**
  17019. * Get the friendly name associated with the input class.
  17020. * @returns the input friendly name
  17021. */
  17022. getSimpleName(): string;
  17023. }
  17024. }
  17025. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  17026. import { Nullable } from "babylonjs/types";
  17027. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  17028. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  17029. /**
  17030. * Manage the touch inputs to control the movement of a free camera.
  17031. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  17032. */
  17033. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  17034. /**
  17035. * Defines the camera the input is attached to.
  17036. */
  17037. camera: FreeCamera;
  17038. /**
  17039. * Defines the touch sensibility for rotation.
  17040. * The higher the faster.
  17041. */
  17042. touchAngularSensibility: number;
  17043. /**
  17044. * Defines the touch sensibility for move.
  17045. * The higher the faster.
  17046. */
  17047. touchMoveSensibility: number;
  17048. private _offsetX;
  17049. private _offsetY;
  17050. private _pointerPressed;
  17051. private _pointerInput;
  17052. private _observer;
  17053. private _onLostFocus;
  17054. /**
  17055. * Attach the input controls to a specific dom element to get the input from.
  17056. * @param element Defines the element the controls should be listened from
  17057. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  17058. */
  17059. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17060. /**
  17061. * Detach the current controls from the specified dom element.
  17062. * @param element Defines the element to stop listening the inputs from
  17063. */
  17064. detachControl(element: Nullable<HTMLElement>): void;
  17065. /**
  17066. * Update the current camera state depending on the inputs that have been used this frame.
  17067. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  17068. */
  17069. checkInputs(): void;
  17070. /**
  17071. * Gets the class name of the current intput.
  17072. * @returns the class name
  17073. */
  17074. getClassName(): string;
  17075. /**
  17076. * Get the friendly name associated with the input class.
  17077. * @returns the input friendly name
  17078. */
  17079. getSimpleName(): string;
  17080. }
  17081. }
  17082. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  17083. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  17084. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  17085. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  17086. import { Nullable } from "babylonjs/types";
  17087. /**
  17088. * Default Inputs manager for the FreeCamera.
  17089. * It groups all the default supported inputs for ease of use.
  17090. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  17091. */
  17092. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  17093. /**
  17094. * @hidden
  17095. */
  17096. _mouseInput: Nullable<FreeCameraMouseInput>;
  17097. /**
  17098. * Instantiates a new FreeCameraInputsManager.
  17099. * @param camera Defines the camera the inputs belong to
  17100. */
  17101. constructor(camera: FreeCamera);
  17102. /**
  17103. * Add keyboard input support to the input manager.
  17104. * @returns the current input manager
  17105. */
  17106. addKeyboard(): FreeCameraInputsManager;
  17107. /**
  17108. * Add mouse input support to the input manager.
  17109. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  17110. * @returns the current input manager
  17111. */
  17112. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  17113. /**
  17114. * Removes the mouse input support from the manager
  17115. * @returns the current input manager
  17116. */
  17117. removeMouse(): FreeCameraInputsManager;
  17118. /**
  17119. * Add touch input support to the input manager.
  17120. * @returns the current input manager
  17121. */
  17122. addTouch(): FreeCameraInputsManager;
  17123. /**
  17124. * Remove all attached input methods from a camera
  17125. */
  17126. clear(): void;
  17127. }
  17128. }
  17129. declare module "babylonjs/Cameras/freeCamera" {
  17130. import { Vector3 } from "babylonjs/Maths/math";
  17131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17132. import { Scene } from "babylonjs/scene";
  17133. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  17134. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  17135. /**
  17136. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  17137. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  17138. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  17139. */
  17140. export class FreeCamera extends TargetCamera {
  17141. /**
  17142. * Define the collision ellipsoid of the camera.
  17143. * This is helpful to simulate a camera body like the player body around the camera
  17144. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  17145. */
  17146. ellipsoid: Vector3;
  17147. /**
  17148. * Define an offset for the position of the ellipsoid around the camera.
  17149. * This can be helpful to determine the center of the body near the gravity center of the body
  17150. * instead of its head.
  17151. */
  17152. ellipsoidOffset: Vector3;
  17153. /**
  17154. * Enable or disable collisions of the camera with the rest of the scene objects.
  17155. */
  17156. checkCollisions: boolean;
  17157. /**
  17158. * Enable or disable gravity on the camera.
  17159. */
  17160. applyGravity: boolean;
  17161. /**
  17162. * Define the input manager associated to the camera.
  17163. */
  17164. inputs: FreeCameraInputsManager;
  17165. /**
  17166. * Gets the input sensibility for a mouse input. (default is 2000.0)
  17167. * Higher values reduce sensitivity.
  17168. */
  17169. /**
  17170. * Sets the input sensibility for a mouse input. (default is 2000.0)
  17171. * Higher values reduce sensitivity.
  17172. */
  17173. angularSensibility: number;
  17174. /**
  17175. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  17176. */
  17177. keysUp: number[];
  17178. /**
  17179. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  17180. */
  17181. keysDown: number[];
  17182. /**
  17183. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  17184. */
  17185. keysLeft: number[];
  17186. /**
  17187. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  17188. */
  17189. keysRight: number[];
  17190. /**
  17191. * Event raised when the camera collide with a mesh in the scene.
  17192. */
  17193. onCollide: (collidedMesh: AbstractMesh) => void;
  17194. private _collider;
  17195. private _needMoveForGravity;
  17196. private _oldPosition;
  17197. private _diffPosition;
  17198. private _newPosition;
  17199. /** @hidden */
  17200. _localDirection: Vector3;
  17201. /** @hidden */
  17202. _transformedDirection: Vector3;
  17203. /**
  17204. * Instantiates a Free Camera.
  17205. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  17206. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  17207. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  17208. * @param name Define the name of the camera in the scene
  17209. * @param position Define the start position of the camera in the scene
  17210. * @param scene Define the scene the camera belongs to
  17211. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  17212. */
  17213. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  17214. /**
  17215. * Attached controls to the current camera.
  17216. * @param element Defines the element the controls should be listened from
  17217. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  17218. */
  17219. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17220. /**
  17221. * Detach the current controls from the camera.
  17222. * The camera will stop reacting to inputs.
  17223. * @param element Defines the element to stop listening the inputs from
  17224. */
  17225. detachControl(element: HTMLElement): void;
  17226. private _collisionMask;
  17227. /**
  17228. * Define a collision mask to limit the list of object the camera can collide with
  17229. */
  17230. collisionMask: number;
  17231. /** @hidden */
  17232. _collideWithWorld(displacement: Vector3): void;
  17233. private _onCollisionPositionChange;
  17234. /** @hidden */
  17235. _checkInputs(): void;
  17236. /** @hidden */
  17237. _decideIfNeedsToMove(): boolean;
  17238. /** @hidden */
  17239. _updatePosition(): void;
  17240. /**
  17241. * Destroy the camera and release the current resources hold by it.
  17242. */
  17243. dispose(): void;
  17244. /**
  17245. * Gets the current object class name.
  17246. * @return the class name
  17247. */
  17248. getClassName(): string;
  17249. }
  17250. }
  17251. declare module "babylonjs/Gamepads/gamepad" {
  17252. import { Observable } from "babylonjs/Misc/observable";
  17253. /**
  17254. * Represents a gamepad control stick position
  17255. */
  17256. export class StickValues {
  17257. /**
  17258. * The x component of the control stick
  17259. */
  17260. x: number;
  17261. /**
  17262. * The y component of the control stick
  17263. */
  17264. y: number;
  17265. /**
  17266. * Initializes the gamepad x and y control stick values
  17267. * @param x The x component of the gamepad control stick value
  17268. * @param y The y component of the gamepad control stick value
  17269. */
  17270. constructor(
  17271. /**
  17272. * The x component of the control stick
  17273. */
  17274. x: number,
  17275. /**
  17276. * The y component of the control stick
  17277. */
  17278. y: number);
  17279. }
  17280. /**
  17281. * An interface which manages callbacks for gamepad button changes
  17282. */
  17283. export interface GamepadButtonChanges {
  17284. /**
  17285. * Called when a gamepad has been changed
  17286. */
  17287. changed: boolean;
  17288. /**
  17289. * Called when a gamepad press event has been triggered
  17290. */
  17291. pressChanged: boolean;
  17292. /**
  17293. * Called when a touch event has been triggered
  17294. */
  17295. touchChanged: boolean;
  17296. /**
  17297. * Called when a value has changed
  17298. */
  17299. valueChanged: boolean;
  17300. }
  17301. /**
  17302. * Represents a gamepad
  17303. */
  17304. export class Gamepad {
  17305. /**
  17306. * The id of the gamepad
  17307. */
  17308. id: string;
  17309. /**
  17310. * The index of the gamepad
  17311. */
  17312. index: number;
  17313. /**
  17314. * The browser gamepad
  17315. */
  17316. browserGamepad: any;
  17317. /**
  17318. * Specifies what type of gamepad this represents
  17319. */
  17320. type: number;
  17321. private _leftStick;
  17322. private _rightStick;
  17323. /** @hidden */
  17324. _isConnected: boolean;
  17325. private _leftStickAxisX;
  17326. private _leftStickAxisY;
  17327. private _rightStickAxisX;
  17328. private _rightStickAxisY;
  17329. /**
  17330. * Triggered when the left control stick has been changed
  17331. */
  17332. private _onleftstickchanged;
  17333. /**
  17334. * Triggered when the right control stick has been changed
  17335. */
  17336. private _onrightstickchanged;
  17337. /**
  17338. * Represents a gamepad controller
  17339. */
  17340. static GAMEPAD: number;
  17341. /**
  17342. * Represents a generic controller
  17343. */
  17344. static GENERIC: number;
  17345. /**
  17346. * Represents an XBox controller
  17347. */
  17348. static XBOX: number;
  17349. /**
  17350. * Represents a pose-enabled controller
  17351. */
  17352. static POSE_ENABLED: number;
  17353. /**
  17354. * Specifies whether the left control stick should be Y-inverted
  17355. */
  17356. protected _invertLeftStickY: boolean;
  17357. /**
  17358. * Specifies if the gamepad has been connected
  17359. */
  17360. readonly isConnected: boolean;
  17361. /**
  17362. * Initializes the gamepad
  17363. * @param id The id of the gamepad
  17364. * @param index The index of the gamepad
  17365. * @param browserGamepad The browser gamepad
  17366. * @param leftStickX The x component of the left joystick
  17367. * @param leftStickY The y component of the left joystick
  17368. * @param rightStickX The x component of the right joystick
  17369. * @param rightStickY The y component of the right joystick
  17370. */
  17371. constructor(
  17372. /**
  17373. * The id of the gamepad
  17374. */
  17375. id: string,
  17376. /**
  17377. * The index of the gamepad
  17378. */
  17379. index: number,
  17380. /**
  17381. * The browser gamepad
  17382. */
  17383. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  17384. /**
  17385. * Callback triggered when the left joystick has changed
  17386. * @param callback
  17387. */
  17388. onleftstickchanged(callback: (values: StickValues) => void): void;
  17389. /**
  17390. * Callback triggered when the right joystick has changed
  17391. * @param callback
  17392. */
  17393. onrightstickchanged(callback: (values: StickValues) => void): void;
  17394. /**
  17395. * Gets the left joystick
  17396. */
  17397. /**
  17398. * Sets the left joystick values
  17399. */
  17400. leftStick: StickValues;
  17401. /**
  17402. * Gets the right joystick
  17403. */
  17404. /**
  17405. * Sets the right joystick value
  17406. */
  17407. rightStick: StickValues;
  17408. /**
  17409. * Updates the gamepad joystick positions
  17410. */
  17411. update(): void;
  17412. /**
  17413. * Disposes the gamepad
  17414. */
  17415. dispose(): void;
  17416. }
  17417. /**
  17418. * Represents a generic gamepad
  17419. */
  17420. export class GenericPad extends Gamepad {
  17421. private _buttons;
  17422. private _onbuttondown;
  17423. private _onbuttonup;
  17424. /**
  17425. * Observable triggered when a button has been pressed
  17426. */
  17427. onButtonDownObservable: Observable<number>;
  17428. /**
  17429. * Observable triggered when a button has been released
  17430. */
  17431. onButtonUpObservable: Observable<number>;
  17432. /**
  17433. * Callback triggered when a button has been pressed
  17434. * @param callback Called when a button has been pressed
  17435. */
  17436. onbuttondown(callback: (buttonPressed: number) => void): void;
  17437. /**
  17438. * Callback triggered when a button has been released
  17439. * @param callback Called when a button has been released
  17440. */
  17441. onbuttonup(callback: (buttonReleased: number) => void): void;
  17442. /**
  17443. * Initializes the generic gamepad
  17444. * @param id The id of the generic gamepad
  17445. * @param index The index of the generic gamepad
  17446. * @param browserGamepad The browser gamepad
  17447. */
  17448. constructor(id: string, index: number, browserGamepad: any);
  17449. private _setButtonValue;
  17450. /**
  17451. * Updates the generic gamepad
  17452. */
  17453. update(): void;
  17454. /**
  17455. * Disposes the generic gamepad
  17456. */
  17457. dispose(): void;
  17458. }
  17459. }
  17460. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  17461. import { Observable } from "babylonjs/Misc/observable";
  17462. import { Nullable } from "babylonjs/types";
  17463. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  17464. import { TransformNode } from "babylonjs/Meshes/transformNode";
  17465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17466. import { Ray } from "babylonjs/Culling/ray";
  17467. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  17468. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  17469. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  17470. /**
  17471. * Defines the types of pose enabled controllers that are supported
  17472. */
  17473. export enum PoseEnabledControllerType {
  17474. /**
  17475. * HTC Vive
  17476. */
  17477. VIVE = 0,
  17478. /**
  17479. * Oculus Rift
  17480. */
  17481. OCULUS = 1,
  17482. /**
  17483. * Windows mixed reality
  17484. */
  17485. WINDOWS = 2,
  17486. /**
  17487. * Samsung gear VR
  17488. */
  17489. GEAR_VR = 3,
  17490. /**
  17491. * Google Daydream
  17492. */
  17493. DAYDREAM = 4,
  17494. /**
  17495. * Generic
  17496. */
  17497. GENERIC = 5
  17498. }
  17499. /**
  17500. * Defines the MutableGamepadButton interface for the state of a gamepad button
  17501. */
  17502. export interface MutableGamepadButton {
  17503. /**
  17504. * Value of the button/trigger
  17505. */
  17506. value: number;
  17507. /**
  17508. * If the button/trigger is currently touched
  17509. */
  17510. touched: boolean;
  17511. /**
  17512. * If the button/trigger is currently pressed
  17513. */
  17514. pressed: boolean;
  17515. }
  17516. /**
  17517. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  17518. * @hidden
  17519. */
  17520. export interface ExtendedGamepadButton extends GamepadButton {
  17521. /**
  17522. * If the button/trigger is currently pressed
  17523. */
  17524. readonly pressed: boolean;
  17525. /**
  17526. * If the button/trigger is currently touched
  17527. */
  17528. readonly touched: boolean;
  17529. /**
  17530. * Value of the button/trigger
  17531. */
  17532. readonly value: number;
  17533. }
  17534. /** @hidden */
  17535. export interface _GamePadFactory {
  17536. /**
  17537. * Returns wether or not the current gamepad can be created for this type of controller.
  17538. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17539. * @returns true if it can be created, otherwise false
  17540. */
  17541. canCreate(gamepadInfo: any): boolean;
  17542. /**
  17543. * Creates a new instance of the Gamepad.
  17544. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17545. * @returns the new gamepad instance
  17546. */
  17547. create(gamepadInfo: any): Gamepad;
  17548. }
  17549. /**
  17550. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17551. */
  17552. export class PoseEnabledControllerHelper {
  17553. /** @hidden */
  17554. static _ControllerFactories: _GamePadFactory[];
  17555. /** @hidden */
  17556. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  17557. /**
  17558. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17559. * @param vrGamepad the gamepad to initialized
  17560. * @returns a vr controller of the type the gamepad identified as
  17561. */
  17562. static InitiateController(vrGamepad: any): Gamepad;
  17563. }
  17564. /**
  17565. * Defines the PoseEnabledController object that contains state of a vr capable controller
  17566. */
  17567. export class PoseEnabledController extends Gamepad implements PoseControlled {
  17568. private _deviceRoomPosition;
  17569. private _deviceRoomRotationQuaternion;
  17570. /**
  17571. * The device position in babylon space
  17572. */
  17573. devicePosition: Vector3;
  17574. /**
  17575. * The device rotation in babylon space
  17576. */
  17577. deviceRotationQuaternion: Quaternion;
  17578. /**
  17579. * The scale factor of the device in babylon space
  17580. */
  17581. deviceScaleFactor: number;
  17582. /**
  17583. * (Likely devicePosition should be used instead) The device position in its room space
  17584. */
  17585. position: Vector3;
  17586. /**
  17587. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  17588. */
  17589. rotationQuaternion: Quaternion;
  17590. /**
  17591. * The type of controller (Eg. Windows mixed reality)
  17592. */
  17593. controllerType: PoseEnabledControllerType;
  17594. protected _calculatedPosition: Vector3;
  17595. private _calculatedRotation;
  17596. /**
  17597. * The raw pose from the device
  17598. */
  17599. rawPose: DevicePose;
  17600. private _trackPosition;
  17601. private _maxRotationDistFromHeadset;
  17602. private _draggedRoomRotation;
  17603. /**
  17604. * @hidden
  17605. */
  17606. _disableTrackPosition(fixedPosition: Vector3): void;
  17607. /**
  17608. * Internal, the mesh attached to the controller
  17609. * @hidden
  17610. */
  17611. _mesh: Nullable<AbstractMesh>;
  17612. private _poseControlledCamera;
  17613. private _leftHandSystemQuaternion;
  17614. /**
  17615. * Internal, matrix used to convert room space to babylon space
  17616. * @hidden
  17617. */
  17618. _deviceToWorld: Matrix;
  17619. /**
  17620. * Node to be used when casting a ray from the controller
  17621. * @hidden
  17622. */
  17623. _pointingPoseNode: Nullable<TransformNode>;
  17624. /**
  17625. * Name of the child mesh that can be used to cast a ray from the controller
  17626. */
  17627. static readonly POINTING_POSE: string;
  17628. /**
  17629. * Creates a new PoseEnabledController from a gamepad
  17630. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  17631. */
  17632. constructor(browserGamepad: any);
  17633. private _workingMatrix;
  17634. /**
  17635. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  17636. */
  17637. update(): void;
  17638. /**
  17639. * Updates only the pose device and mesh without doing any button event checking
  17640. */
  17641. protected _updatePoseAndMesh(): void;
  17642. /**
  17643. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  17644. * @param poseData raw pose fromthe device
  17645. */
  17646. updateFromDevice(poseData: DevicePose): void;
  17647. /**
  17648. * @hidden
  17649. */
  17650. _meshAttachedObservable: Observable<AbstractMesh>;
  17651. /**
  17652. * Attaches a mesh to the controller
  17653. * @param mesh the mesh to be attached
  17654. */
  17655. attachToMesh(mesh: AbstractMesh): void;
  17656. /**
  17657. * Attaches the controllers mesh to a camera
  17658. * @param camera the camera the mesh should be attached to
  17659. */
  17660. attachToPoseControlledCamera(camera: TargetCamera): void;
  17661. /**
  17662. * Disposes of the controller
  17663. */
  17664. dispose(): void;
  17665. /**
  17666. * The mesh that is attached to the controller
  17667. */
  17668. readonly mesh: Nullable<AbstractMesh>;
  17669. /**
  17670. * Gets the ray of the controller in the direction the controller is pointing
  17671. * @param length the length the resulting ray should be
  17672. * @returns a ray in the direction the controller is pointing
  17673. */
  17674. getForwardRay(length?: number): Ray;
  17675. }
  17676. }
  17677. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  17678. import { Observable } from "babylonjs/Misc/observable";
  17679. import { Scene } from "babylonjs/scene";
  17680. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17681. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  17682. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  17683. /**
  17684. * Defines the WebVRController object that represents controllers tracked in 3D space
  17685. */
  17686. export abstract class WebVRController extends PoseEnabledController {
  17687. /**
  17688. * Internal, the default controller model for the controller
  17689. */
  17690. protected _defaultModel: AbstractMesh;
  17691. /**
  17692. * Fired when the trigger state has changed
  17693. */
  17694. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  17695. /**
  17696. * Fired when the main button state has changed
  17697. */
  17698. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17699. /**
  17700. * Fired when the secondary button state has changed
  17701. */
  17702. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17703. /**
  17704. * Fired when the pad state has changed
  17705. */
  17706. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  17707. /**
  17708. * Fired when controllers stick values have changed
  17709. */
  17710. onPadValuesChangedObservable: Observable<StickValues>;
  17711. /**
  17712. * Array of button availible on the controller
  17713. */
  17714. protected _buttons: Array<MutableGamepadButton>;
  17715. private _onButtonStateChange;
  17716. /**
  17717. * Fired when a controller button's state has changed
  17718. * @param callback the callback containing the button that was modified
  17719. */
  17720. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  17721. /**
  17722. * X and Y axis corresponding to the controllers joystick
  17723. */
  17724. pad: StickValues;
  17725. /**
  17726. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  17727. */
  17728. hand: string;
  17729. /**
  17730. * The default controller model for the controller
  17731. */
  17732. readonly defaultModel: AbstractMesh;
  17733. /**
  17734. * Creates a new WebVRController from a gamepad
  17735. * @param vrGamepad the gamepad that the WebVRController should be created from
  17736. */
  17737. constructor(vrGamepad: any);
  17738. /**
  17739. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  17740. */
  17741. update(): void;
  17742. /**
  17743. * Function to be called when a button is modified
  17744. */
  17745. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  17746. /**
  17747. * Loads a mesh and attaches it to the controller
  17748. * @param scene the scene the mesh should be added to
  17749. * @param meshLoaded callback for when the mesh has been loaded
  17750. */
  17751. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  17752. private _setButtonValue;
  17753. private _changes;
  17754. private _checkChanges;
  17755. /**
  17756. * Disposes of th webVRCOntroller
  17757. */
  17758. dispose(): void;
  17759. }
  17760. }
  17761. declare module "babylonjs/Lights/hemisphericLight" {
  17762. import { Nullable } from "babylonjs/types";
  17763. import { Scene } from "babylonjs/scene";
  17764. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  17765. import { Effect } from "babylonjs/Materials/effect";
  17766. import { Light } from "babylonjs/Lights/light";
  17767. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17768. /**
  17769. * The HemisphericLight simulates the ambient environment light,
  17770. * so the passed direction is the light reflection direction, not the incoming direction.
  17771. */
  17772. export class HemisphericLight extends Light {
  17773. /**
  17774. * The groundColor is the light in the opposite direction to the one specified during creation.
  17775. * 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.
  17776. */
  17777. groundColor: Color3;
  17778. /**
  17779. * The light reflection direction, not the incoming direction.
  17780. */
  17781. direction: Vector3;
  17782. /**
  17783. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  17784. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  17785. * The HemisphericLight can't cast shadows.
  17786. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17787. * @param name The friendly name of the light
  17788. * @param direction The direction of the light reflection
  17789. * @param scene The scene the light belongs to
  17790. */
  17791. constructor(name: string, direction: Vector3, scene: Scene);
  17792. protected _buildUniformLayout(): void;
  17793. /**
  17794. * Returns the string "HemisphericLight".
  17795. * @return The class name
  17796. */
  17797. getClassName(): string;
  17798. /**
  17799. * Sets the HemisphericLight direction towards the passed target (Vector3).
  17800. * Returns the updated direction.
  17801. * @param target The target the direction should point to
  17802. * @return The computed direction
  17803. */
  17804. setDirectionToTarget(target: Vector3): Vector3;
  17805. /**
  17806. * Returns the shadow generator associated to the light.
  17807. * @returns Always null for hemispheric lights because it does not support shadows.
  17808. */
  17809. getShadowGenerator(): Nullable<IShadowGenerator>;
  17810. /**
  17811. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  17812. * @param effect The effect to update
  17813. * @param lightIndex The index of the light in the effect to update
  17814. * @returns The hemispheric light
  17815. */
  17816. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  17817. /**
  17818. * Computes the world matrix of the node
  17819. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  17820. * @param useWasUpdatedFlag defines a reserved property
  17821. * @returns the world matrix
  17822. */
  17823. computeWorldMatrix(): Matrix;
  17824. /**
  17825. * Returns the integer 3.
  17826. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17827. */
  17828. getTypeID(): number;
  17829. /**
  17830. * Prepares the list of defines specific to the light type.
  17831. * @param defines the list of defines
  17832. * @param lightIndex defines the index of the light for the effect
  17833. */
  17834. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17835. }
  17836. }
  17837. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  17838. /** @hidden */
  17839. export var vrMultiviewToSingleviewPixelShader: {
  17840. name: string;
  17841. shader: string;
  17842. };
  17843. }
  17844. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  17845. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17846. import { Scene } from "babylonjs/scene";
  17847. /**
  17848. * Renders to multiple views with a single draw call
  17849. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  17850. */
  17851. export class MultiviewRenderTarget extends RenderTargetTexture {
  17852. /**
  17853. * Creates a multiview render target
  17854. * @param scene scene used with the render target
  17855. * @param size the size of the render target (used for each view)
  17856. */
  17857. constructor(scene: Scene, size?: number | {
  17858. width: number;
  17859. height: number;
  17860. } | {
  17861. ratio: number;
  17862. });
  17863. /**
  17864. * @hidden
  17865. * @param faceIndex the face index, if its a cube texture
  17866. */
  17867. _bindFrameBuffer(faceIndex?: number): void;
  17868. /**
  17869. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17870. * @returns the view count
  17871. */
  17872. getViewCount(): number;
  17873. }
  17874. }
  17875. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  17876. import { Camera } from "babylonjs/Cameras/camera";
  17877. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17878. import { Nullable } from "babylonjs/types";
  17879. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17880. import { Matrix } from "babylonjs/Maths/math";
  17881. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17882. module "babylonjs/Engines/engine" {
  17883. interface Engine {
  17884. /**
  17885. * Creates a new multiview render target
  17886. * @param width defines the width of the texture
  17887. * @param height defines the height of the texture
  17888. * @returns the created multiview texture
  17889. */
  17890. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  17891. /**
  17892. * Binds a multiview framebuffer to be drawn to
  17893. * @param multiviewTexture texture to bind
  17894. */
  17895. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  17896. }
  17897. }
  17898. module "babylonjs/Cameras/camera" {
  17899. interface Camera {
  17900. /**
  17901. * @hidden
  17902. * 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)
  17903. */
  17904. _useMultiviewToSingleView: boolean;
  17905. /**
  17906. * @hidden
  17907. * 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)
  17908. */
  17909. _multiviewTexture: Nullable<RenderTargetTexture>;
  17910. /**
  17911. * @hidden
  17912. * ensures the multiview texture of the camera exists and has the specified width/height
  17913. * @param width height to set on the multiview texture
  17914. * @param height width to set on the multiview texture
  17915. */
  17916. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  17917. }
  17918. }
  17919. module "babylonjs/scene" {
  17920. interface Scene {
  17921. /** @hidden */
  17922. _transformMatrixR: Matrix;
  17923. /** @hidden */
  17924. _multiviewSceneUbo: Nullable<UniformBuffer>;
  17925. /** @hidden */
  17926. _createMultiviewUbo(): void;
  17927. /** @hidden */
  17928. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  17929. /** @hidden */
  17930. _renderMultiviewToSingleView(camera: Camera): void;
  17931. }
  17932. }
  17933. }
  17934. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  17935. import { Camera } from "babylonjs/Cameras/camera";
  17936. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17937. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  17938. import "babylonjs/Engines/Extensions/engine.multiview";
  17939. /**
  17940. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  17941. * This will not be used for webXR as it supports displaying texture arrays directly
  17942. */
  17943. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  17944. /**
  17945. * Initializes a VRMultiviewToSingleview
  17946. * @param name name of the post process
  17947. * @param camera camera to be applied to
  17948. * @param scaleFactor scaling factor to the size of the output texture
  17949. */
  17950. constructor(name: string, camera: Camera, scaleFactor: number);
  17951. }
  17952. }
  17953. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  17954. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  17955. import { Nullable } from "babylonjs/types";
  17956. import { Size } from "babylonjs/Maths/math";
  17957. import { Observable } from "babylonjs/Misc/observable";
  17958. module "babylonjs/Engines/engine" {
  17959. interface Engine {
  17960. /** @hidden */
  17961. _vrDisplay: any;
  17962. /** @hidden */
  17963. _vrSupported: boolean;
  17964. /** @hidden */
  17965. _oldSize: Size;
  17966. /** @hidden */
  17967. _oldHardwareScaleFactor: number;
  17968. /** @hidden */
  17969. _vrExclusivePointerMode: boolean;
  17970. /** @hidden */
  17971. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  17972. /** @hidden */
  17973. _onVRDisplayPointerRestricted: () => void;
  17974. /** @hidden */
  17975. _onVRDisplayPointerUnrestricted: () => void;
  17976. /** @hidden */
  17977. _onVrDisplayConnect: Nullable<(display: any) => void>;
  17978. /** @hidden */
  17979. _onVrDisplayDisconnect: Nullable<() => void>;
  17980. /** @hidden */
  17981. _onVrDisplayPresentChange: Nullable<() => void>;
  17982. /**
  17983. * Observable signaled when VR display mode changes
  17984. */
  17985. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  17986. /**
  17987. * Observable signaled when VR request present is complete
  17988. */
  17989. onVRRequestPresentComplete: Observable<boolean>;
  17990. /**
  17991. * Observable signaled when VR request present starts
  17992. */
  17993. onVRRequestPresentStart: Observable<Engine>;
  17994. /**
  17995. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  17996. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  17997. */
  17998. isInVRExclusivePointerMode: boolean;
  17999. /**
  18000. * Gets a boolean indicating if a webVR device was detected
  18001. * @returns true if a webVR device was detected
  18002. */
  18003. isVRDevicePresent(): boolean;
  18004. /**
  18005. * Gets the current webVR device
  18006. * @returns the current webVR device (or null)
  18007. */
  18008. getVRDevice(): any;
  18009. /**
  18010. * Initializes a webVR display and starts listening to display change events
  18011. * The onVRDisplayChangedObservable will be notified upon these changes
  18012. * @returns A promise containing a VRDisplay and if vr is supported
  18013. */
  18014. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  18015. /** @hidden */
  18016. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  18017. /**
  18018. * Call this function to switch to webVR mode
  18019. * Will do nothing if webVR is not supported or if there is no webVR device
  18020. * @see http://doc.babylonjs.com/how_to/webvr_camera
  18021. */
  18022. enableVR(): void;
  18023. /** @hidden */
  18024. _onVRFullScreenTriggered(): void;
  18025. }
  18026. }
  18027. }
  18028. declare module "babylonjs/Cameras/VR/webVRCamera" {
  18029. import { Nullable } from "babylonjs/types";
  18030. import { Observable } from "babylonjs/Misc/observable";
  18031. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18032. import { Scene } from "babylonjs/scene";
  18033. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  18034. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  18035. import { Node } from "babylonjs/node";
  18036. import { Ray } from "babylonjs/Culling/ray";
  18037. import "babylonjs/Cameras/RigModes/webVRRigMode";
  18038. import "babylonjs/Engines/Extensions/engine.webVR";
  18039. /**
  18040. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  18041. * IMPORTANT!! The data is right-hand data.
  18042. * @export
  18043. * @interface DevicePose
  18044. */
  18045. export interface DevicePose {
  18046. /**
  18047. * The position of the device, values in array are [x,y,z].
  18048. */
  18049. readonly position: Nullable<Float32Array>;
  18050. /**
  18051. * The linearVelocity of the device, values in array are [x,y,z].
  18052. */
  18053. readonly linearVelocity: Nullable<Float32Array>;
  18054. /**
  18055. * The linearAcceleration of the device, values in array are [x,y,z].
  18056. */
  18057. readonly linearAcceleration: Nullable<Float32Array>;
  18058. /**
  18059. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  18060. */
  18061. readonly orientation: Nullable<Float32Array>;
  18062. /**
  18063. * The angularVelocity of the device, values in array are [x,y,z].
  18064. */
  18065. readonly angularVelocity: Nullable<Float32Array>;
  18066. /**
  18067. * The angularAcceleration of the device, values in array are [x,y,z].
  18068. */
  18069. readonly angularAcceleration: Nullable<Float32Array>;
  18070. }
  18071. /**
  18072. * Interface representing a pose controlled object in Babylon.
  18073. * A pose controlled object has both regular pose values as well as pose values
  18074. * from an external device such as a VR head mounted display
  18075. */
  18076. export interface PoseControlled {
  18077. /**
  18078. * The position of the object in babylon space.
  18079. */
  18080. position: Vector3;
  18081. /**
  18082. * The rotation quaternion of the object in babylon space.
  18083. */
  18084. rotationQuaternion: Quaternion;
  18085. /**
  18086. * The position of the device in babylon space.
  18087. */
  18088. devicePosition?: Vector3;
  18089. /**
  18090. * The rotation quaternion of the device in babylon space.
  18091. */
  18092. deviceRotationQuaternion: Quaternion;
  18093. /**
  18094. * The raw pose coming from the device.
  18095. */
  18096. rawPose: Nullable<DevicePose>;
  18097. /**
  18098. * The scale of the device to be used when translating from device space to babylon space.
  18099. */
  18100. deviceScaleFactor: number;
  18101. /**
  18102. * Updates the poseControlled values based on the input device pose.
  18103. * @param poseData the pose data to update the object with
  18104. */
  18105. updateFromDevice(poseData: DevicePose): void;
  18106. }
  18107. /**
  18108. * Set of options to customize the webVRCamera
  18109. */
  18110. export interface WebVROptions {
  18111. /**
  18112. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  18113. */
  18114. trackPosition?: boolean;
  18115. /**
  18116. * Sets the scale of the vrDevice in babylon space. (default: 1)
  18117. */
  18118. positionScale?: number;
  18119. /**
  18120. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  18121. */
  18122. displayName?: string;
  18123. /**
  18124. * Should the native controller meshes be initialized. (default: true)
  18125. */
  18126. controllerMeshes?: boolean;
  18127. /**
  18128. * Creating a default HemiLight only on controllers. (default: true)
  18129. */
  18130. defaultLightingOnControllers?: boolean;
  18131. /**
  18132. * If you don't want to use the default VR button of the helper. (default: false)
  18133. */
  18134. useCustomVRButton?: boolean;
  18135. /**
  18136. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  18137. */
  18138. customVRButton?: HTMLButtonElement;
  18139. /**
  18140. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  18141. */
  18142. rayLength?: number;
  18143. /**
  18144. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  18145. */
  18146. defaultHeight?: number;
  18147. /**
  18148. * If multiview should be used if availible (default: false)
  18149. */
  18150. useMultiview?: boolean;
  18151. }
  18152. /**
  18153. * This represents a WebVR camera.
  18154. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  18155. * @example http://doc.babylonjs.com/how_to/webvr_camera
  18156. */
  18157. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  18158. private webVROptions;
  18159. /**
  18160. * @hidden
  18161. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  18162. */
  18163. _vrDevice: any;
  18164. /**
  18165. * The rawPose of the vrDevice.
  18166. */
  18167. rawPose: Nullable<DevicePose>;
  18168. private _onVREnabled;
  18169. private _specsVersion;
  18170. private _attached;
  18171. private _frameData;
  18172. protected _descendants: Array<Node>;
  18173. private _deviceRoomPosition;
  18174. /** @hidden */
  18175. _deviceRoomRotationQuaternion: Quaternion;
  18176. private _standingMatrix;
  18177. /**
  18178. * Represents device position in babylon space.
  18179. */
  18180. devicePosition: Vector3;
  18181. /**
  18182. * Represents device rotation in babylon space.
  18183. */
  18184. deviceRotationQuaternion: Quaternion;
  18185. /**
  18186. * The scale of the device to be used when translating from device space to babylon space.
  18187. */
  18188. deviceScaleFactor: number;
  18189. private _deviceToWorld;
  18190. private _worldToDevice;
  18191. /**
  18192. * References to the webVR controllers for the vrDevice.
  18193. */
  18194. controllers: Array<WebVRController>;
  18195. /**
  18196. * Emits an event when a controller is attached.
  18197. */
  18198. onControllersAttachedObservable: Observable<WebVRController[]>;
  18199. /**
  18200. * Emits an event when a controller's mesh has been loaded;
  18201. */
  18202. onControllerMeshLoadedObservable: Observable<WebVRController>;
  18203. /**
  18204. * Emits an event when the HMD's pose has been updated.
  18205. */
  18206. onPoseUpdatedFromDeviceObservable: Observable<any>;
  18207. private _poseSet;
  18208. /**
  18209. * If the rig cameras be used as parent instead of this camera.
  18210. */
  18211. rigParenting: boolean;
  18212. private _lightOnControllers;
  18213. private _defaultHeight?;
  18214. /**
  18215. * Instantiates a WebVRFreeCamera.
  18216. * @param name The name of the WebVRFreeCamera
  18217. * @param position The starting anchor position for the camera
  18218. * @param scene The scene the camera belongs to
  18219. * @param webVROptions a set of customizable options for the webVRCamera
  18220. */
  18221. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  18222. /**
  18223. * Gets the device distance from the ground in meters.
  18224. * @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.
  18225. */
  18226. deviceDistanceToRoomGround(): number;
  18227. /**
  18228. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18229. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  18230. */
  18231. useStandingMatrix(callback?: (bool: boolean) => void): void;
  18232. /**
  18233. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18234. * @returns A promise with a boolean set to if the standing matrix is supported.
  18235. */
  18236. useStandingMatrixAsync(): Promise<boolean>;
  18237. /**
  18238. * Disposes the camera
  18239. */
  18240. dispose(): void;
  18241. /**
  18242. * Gets a vrController by name.
  18243. * @param name The name of the controller to retreive
  18244. * @returns the controller matching the name specified or null if not found
  18245. */
  18246. getControllerByName(name: string): Nullable<WebVRController>;
  18247. private _leftController;
  18248. /**
  18249. * The controller corresponding to the users left hand.
  18250. */
  18251. readonly leftController: Nullable<WebVRController>;
  18252. private _rightController;
  18253. /**
  18254. * The controller corresponding to the users right hand.
  18255. */
  18256. readonly rightController: Nullable<WebVRController>;
  18257. /**
  18258. * Casts a ray forward from the vrCamera's gaze.
  18259. * @param length Length of the ray (default: 100)
  18260. * @returns the ray corresponding to the gaze
  18261. */
  18262. getForwardRay(length?: number): Ray;
  18263. /**
  18264. * @hidden
  18265. * Updates the camera based on device's frame data
  18266. */
  18267. _checkInputs(): void;
  18268. /**
  18269. * Updates the poseControlled values based on the input device pose.
  18270. * @param poseData Pose coming from the device
  18271. */
  18272. updateFromDevice(poseData: DevicePose): void;
  18273. private _htmlElementAttached;
  18274. private _detachIfAttached;
  18275. /**
  18276. * WebVR's attach control will start broadcasting frames to the device.
  18277. * Note that in certain browsers (chrome for example) this function must be called
  18278. * within a user-interaction callback. Example:
  18279. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  18280. *
  18281. * @param element html element to attach the vrDevice to
  18282. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  18283. */
  18284. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18285. /**
  18286. * Detaches the camera from the html element and disables VR
  18287. *
  18288. * @param element html element to detach from
  18289. */
  18290. detachControl(element: HTMLElement): void;
  18291. /**
  18292. * @returns the name of this class
  18293. */
  18294. getClassName(): string;
  18295. /**
  18296. * Calls resetPose on the vrDisplay
  18297. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  18298. */
  18299. resetToCurrentRotation(): void;
  18300. /**
  18301. * @hidden
  18302. * Updates the rig cameras (left and right eye)
  18303. */
  18304. _updateRigCameras(): void;
  18305. private _workingVector;
  18306. private _oneVector;
  18307. private _workingMatrix;
  18308. private updateCacheCalled;
  18309. private _correctPositionIfNotTrackPosition;
  18310. /**
  18311. * @hidden
  18312. * Updates the cached values of the camera
  18313. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  18314. */
  18315. _updateCache(ignoreParentClass?: boolean): void;
  18316. /**
  18317. * @hidden
  18318. * Get current device position in babylon world
  18319. */
  18320. _computeDevicePosition(): void;
  18321. /**
  18322. * Updates the current device position and rotation in the babylon world
  18323. */
  18324. update(): void;
  18325. /**
  18326. * @hidden
  18327. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  18328. * @returns an identity matrix
  18329. */
  18330. _getViewMatrix(): Matrix;
  18331. private _tmpMatrix;
  18332. /**
  18333. * This function is called by the two RIG cameras.
  18334. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  18335. * @hidden
  18336. */
  18337. _getWebVRViewMatrix(): Matrix;
  18338. /** @hidden */
  18339. _getWebVRProjectionMatrix(): Matrix;
  18340. private _onGamepadConnectedObserver;
  18341. private _onGamepadDisconnectedObserver;
  18342. private _updateCacheWhenTrackingDisabledObserver;
  18343. /**
  18344. * Initializes the controllers and their meshes
  18345. */
  18346. initControllers(): void;
  18347. }
  18348. }
  18349. declare module "babylonjs/PostProcesses/postProcess" {
  18350. import { Nullable } from "babylonjs/types";
  18351. import { SmartArray } from "babylonjs/Misc/smartArray";
  18352. import { Observable } from "babylonjs/Misc/observable";
  18353. import { Color4, Vector2 } from "babylonjs/Maths/math";
  18354. import { Camera } from "babylonjs/Cameras/camera";
  18355. import { Effect } from "babylonjs/Materials/effect";
  18356. import "babylonjs/Shaders/postprocess.vertex";
  18357. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18358. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18359. import { Engine } from "babylonjs/Engines/engine";
  18360. /**
  18361. * Size options for a post process
  18362. */
  18363. export type PostProcessOptions = {
  18364. width: number;
  18365. height: number;
  18366. };
  18367. /**
  18368. * PostProcess can be used to apply a shader to a texture after it has been rendered
  18369. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  18370. */
  18371. export class PostProcess {
  18372. /** Name of the PostProcess. */
  18373. name: string;
  18374. /**
  18375. * Gets or sets the unique id of the post process
  18376. */
  18377. uniqueId: number;
  18378. /**
  18379. * Width of the texture to apply the post process on
  18380. */
  18381. width: number;
  18382. /**
  18383. * Height of the texture to apply the post process on
  18384. */
  18385. height: number;
  18386. /**
  18387. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  18388. * @hidden
  18389. */
  18390. _outputTexture: Nullable<InternalTexture>;
  18391. /**
  18392. * Sampling mode used by the shader
  18393. * See https://doc.babylonjs.com/classes/3.1/texture
  18394. */
  18395. renderTargetSamplingMode: number;
  18396. /**
  18397. * Clear color to use when screen clearing
  18398. */
  18399. clearColor: Color4;
  18400. /**
  18401. * If the buffer needs to be cleared before applying the post process. (default: true)
  18402. * Should be set to false if shader will overwrite all previous pixels.
  18403. */
  18404. autoClear: boolean;
  18405. /**
  18406. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  18407. */
  18408. alphaMode: number;
  18409. /**
  18410. * Sets the setAlphaBlendConstants of the babylon engine
  18411. */
  18412. alphaConstants: Color4;
  18413. /**
  18414. * Animations to be used for the post processing
  18415. */
  18416. animations: import("babylonjs/Animations/animation").Animation[];
  18417. /**
  18418. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  18419. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  18420. */
  18421. enablePixelPerfectMode: boolean;
  18422. /**
  18423. * Force the postprocess to be applied without taking in account viewport
  18424. */
  18425. forceFullscreenViewport: boolean;
  18426. /**
  18427. * List of inspectable custom properties (used by the Inspector)
  18428. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18429. */
  18430. inspectableCustomProperties: IInspectable[];
  18431. /**
  18432. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  18433. *
  18434. * | Value | Type | Description |
  18435. * | ----- | ----------------------------------- | ----------- |
  18436. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  18437. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  18438. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  18439. *
  18440. */
  18441. scaleMode: number;
  18442. /**
  18443. * Force textures to be a power of two (default: false)
  18444. */
  18445. alwaysForcePOT: boolean;
  18446. private _samples;
  18447. /**
  18448. * Number of sample textures (default: 1)
  18449. */
  18450. samples: number;
  18451. /**
  18452. * Modify the scale of the post process to be the same as the viewport (default: false)
  18453. */
  18454. adaptScaleToCurrentViewport: boolean;
  18455. private _camera;
  18456. private _scene;
  18457. private _engine;
  18458. private _options;
  18459. private _reusable;
  18460. private _textureType;
  18461. /**
  18462. * Smart array of input and output textures for the post process.
  18463. * @hidden
  18464. */
  18465. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  18466. /**
  18467. * The index in _textures that corresponds to the output texture.
  18468. * @hidden
  18469. */
  18470. _currentRenderTextureInd: number;
  18471. private _effect;
  18472. private _samplers;
  18473. private _fragmentUrl;
  18474. private _vertexUrl;
  18475. private _parameters;
  18476. private _scaleRatio;
  18477. protected _indexParameters: any;
  18478. private _shareOutputWithPostProcess;
  18479. private _texelSize;
  18480. private _forcedOutputTexture;
  18481. /**
  18482. * Returns the fragment url or shader name used in the post process.
  18483. * @returns the fragment url or name in the shader store.
  18484. */
  18485. getEffectName(): string;
  18486. /**
  18487. * An event triggered when the postprocess is activated.
  18488. */
  18489. onActivateObservable: Observable<Camera>;
  18490. private _onActivateObserver;
  18491. /**
  18492. * A function that is added to the onActivateObservable
  18493. */
  18494. onActivate: Nullable<(camera: Camera) => void>;
  18495. /**
  18496. * An event triggered when the postprocess changes its size.
  18497. */
  18498. onSizeChangedObservable: Observable<PostProcess>;
  18499. private _onSizeChangedObserver;
  18500. /**
  18501. * A function that is added to the onSizeChangedObservable
  18502. */
  18503. onSizeChanged: (postProcess: PostProcess) => void;
  18504. /**
  18505. * An event triggered when the postprocess applies its effect.
  18506. */
  18507. onApplyObservable: Observable<Effect>;
  18508. private _onApplyObserver;
  18509. /**
  18510. * A function that is added to the onApplyObservable
  18511. */
  18512. onApply: (effect: Effect) => void;
  18513. /**
  18514. * An event triggered before rendering the postprocess
  18515. */
  18516. onBeforeRenderObservable: Observable<Effect>;
  18517. private _onBeforeRenderObserver;
  18518. /**
  18519. * A function that is added to the onBeforeRenderObservable
  18520. */
  18521. onBeforeRender: (effect: Effect) => void;
  18522. /**
  18523. * An event triggered after rendering the postprocess
  18524. */
  18525. onAfterRenderObservable: Observable<Effect>;
  18526. private _onAfterRenderObserver;
  18527. /**
  18528. * A function that is added to the onAfterRenderObservable
  18529. */
  18530. onAfterRender: (efect: Effect) => void;
  18531. /**
  18532. * 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
  18533. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  18534. */
  18535. inputTexture: InternalTexture;
  18536. /**
  18537. * Gets the camera which post process is applied to.
  18538. * @returns The camera the post process is applied to.
  18539. */
  18540. getCamera(): Camera;
  18541. /**
  18542. * Gets the texel size of the postprocess.
  18543. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  18544. */
  18545. readonly texelSize: Vector2;
  18546. /**
  18547. * Creates a new instance PostProcess
  18548. * @param name The name of the PostProcess.
  18549. * @param fragmentUrl The url of the fragment shader to be used.
  18550. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  18551. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  18552. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18553. * @param camera The camera to apply the render pass to.
  18554. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18555. * @param engine The engine which the post process will be applied. (default: current engine)
  18556. * @param reusable If the post process can be reused on the same frame. (default: false)
  18557. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  18558. * @param textureType Type of textures used when performing the post process. (default: 0)
  18559. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  18560. * @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
  18561. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  18562. */
  18563. constructor(
  18564. /** Name of the PostProcess. */
  18565. 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);
  18566. /**
  18567. * Gets a string idenfifying the name of the class
  18568. * @returns "PostProcess" string
  18569. */
  18570. getClassName(): string;
  18571. /**
  18572. * Gets the engine which this post process belongs to.
  18573. * @returns The engine the post process was enabled with.
  18574. */
  18575. getEngine(): Engine;
  18576. /**
  18577. * The effect that is created when initializing the post process.
  18578. * @returns The created effect corresponding the the postprocess.
  18579. */
  18580. getEffect(): Effect;
  18581. /**
  18582. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  18583. * @param postProcess The post process to share the output with.
  18584. * @returns This post process.
  18585. */
  18586. shareOutputWith(postProcess: PostProcess): PostProcess;
  18587. /**
  18588. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  18589. * This should be called if the post process that shares output with this post process is disabled/disposed.
  18590. */
  18591. useOwnOutput(): void;
  18592. /**
  18593. * Updates the effect with the current post process compile time values and recompiles the shader.
  18594. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18595. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18596. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18597. * @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
  18598. * @param onCompiled Called when the shader has been compiled.
  18599. * @param onError Called if there is an error when compiling a shader.
  18600. */
  18601. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18602. /**
  18603. * The post process is reusable if it can be used multiple times within one frame.
  18604. * @returns If the post process is reusable
  18605. */
  18606. isReusable(): boolean;
  18607. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  18608. markTextureDirty(): void;
  18609. /**
  18610. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  18611. * 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.
  18612. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  18613. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  18614. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  18615. * @returns The target texture that was bound to be written to.
  18616. */
  18617. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  18618. /**
  18619. * If the post process is supported.
  18620. */
  18621. readonly isSupported: boolean;
  18622. /**
  18623. * The aspect ratio of the output texture.
  18624. */
  18625. readonly aspectRatio: number;
  18626. /**
  18627. * Get a value indicating if the post-process is ready to be used
  18628. * @returns true if the post-process is ready (shader is compiled)
  18629. */
  18630. isReady(): boolean;
  18631. /**
  18632. * Binds all textures and uniforms to the shader, this will be run on every pass.
  18633. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  18634. */
  18635. apply(): Nullable<Effect>;
  18636. private _disposeTextures;
  18637. /**
  18638. * Disposes the post process.
  18639. * @param camera The camera to dispose the post process on.
  18640. */
  18641. dispose(camera?: Camera): void;
  18642. }
  18643. }
  18644. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  18645. /** @hidden */
  18646. export var kernelBlurVaryingDeclaration: {
  18647. name: string;
  18648. shader: string;
  18649. };
  18650. }
  18651. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  18652. /** @hidden */
  18653. export var kernelBlurFragment: {
  18654. name: string;
  18655. shader: string;
  18656. };
  18657. }
  18658. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  18659. /** @hidden */
  18660. export var kernelBlurFragment2: {
  18661. name: string;
  18662. shader: string;
  18663. };
  18664. }
  18665. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  18666. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  18667. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  18668. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  18669. /** @hidden */
  18670. export var kernelBlurPixelShader: {
  18671. name: string;
  18672. shader: string;
  18673. };
  18674. }
  18675. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  18676. /** @hidden */
  18677. export var kernelBlurVertex: {
  18678. name: string;
  18679. shader: string;
  18680. };
  18681. }
  18682. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  18683. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  18684. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  18685. /** @hidden */
  18686. export var kernelBlurVertexShader: {
  18687. name: string;
  18688. shader: string;
  18689. };
  18690. }
  18691. declare module "babylonjs/PostProcesses/blurPostProcess" {
  18692. import { Vector2 } from "babylonjs/Maths/math";
  18693. import { Nullable } from "babylonjs/types";
  18694. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  18695. import { Camera } from "babylonjs/Cameras/camera";
  18696. import { Effect } from "babylonjs/Materials/effect";
  18697. import { Engine } from "babylonjs/Engines/engine";
  18698. import "babylonjs/Shaders/kernelBlur.fragment";
  18699. import "babylonjs/Shaders/kernelBlur.vertex";
  18700. /**
  18701. * The Blur Post Process which blurs an image based on a kernel and direction.
  18702. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  18703. */
  18704. export class BlurPostProcess extends PostProcess {
  18705. /** The direction in which to blur the image. */
  18706. direction: Vector2;
  18707. private blockCompilation;
  18708. protected _kernel: number;
  18709. protected _idealKernel: number;
  18710. protected _packedFloat: boolean;
  18711. private _staticDefines;
  18712. /**
  18713. * Sets the length in pixels of the blur sample region
  18714. */
  18715. /**
  18716. * Gets the length in pixels of the blur sample region
  18717. */
  18718. kernel: number;
  18719. /**
  18720. * Sets wether or not the blur needs to unpack/repack floats
  18721. */
  18722. /**
  18723. * Gets wether or not the blur is unpacking/repacking floats
  18724. */
  18725. packedFloat: boolean;
  18726. /**
  18727. * Creates a new instance BlurPostProcess
  18728. * @param name The name of the effect.
  18729. * @param direction The direction in which to blur the image.
  18730. * @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.
  18731. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18732. * @param camera The camera to apply the render pass to.
  18733. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18734. * @param engine The engine which the post process will be applied. (default: current engine)
  18735. * @param reusable If the post process can be reused on the same frame. (default: false)
  18736. * @param textureType Type of textures used when performing the post process. (default: 0)
  18737. * @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)
  18738. */
  18739. constructor(name: string,
  18740. /** The direction in which to blur the image. */
  18741. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  18742. /**
  18743. * Updates the effect with the current post process compile time values and recompiles the shader.
  18744. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18745. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18746. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18747. * @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
  18748. * @param onCompiled Called when the shader has been compiled.
  18749. * @param onError Called if there is an error when compiling a shader.
  18750. */
  18751. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18752. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18753. /**
  18754. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  18755. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  18756. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  18757. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  18758. * The gaps between physical kernels are compensated for in the weighting of the samples
  18759. * @param idealKernel Ideal blur kernel.
  18760. * @return Nearest best kernel.
  18761. */
  18762. protected _nearestBestKernel(idealKernel: number): number;
  18763. /**
  18764. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  18765. * @param x The point on the Gaussian distribution to sample.
  18766. * @return the value of the Gaussian function at x.
  18767. */
  18768. protected _gaussianWeight(x: number): number;
  18769. /**
  18770. * Generates a string that can be used as a floating point number in GLSL.
  18771. * @param x Value to print.
  18772. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  18773. * @return GLSL float string.
  18774. */
  18775. protected _glslFloat(x: number, decimalFigures?: number): string;
  18776. }
  18777. }
  18778. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18779. import { Scene } from "babylonjs/scene";
  18780. import { Plane } from "babylonjs/Maths/math";
  18781. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18782. /**
  18783. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18784. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18785. * You can then easily use it as a reflectionTexture on a flat surface.
  18786. * In case the surface is not a plane, please consider relying on reflection probes.
  18787. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18788. */
  18789. export class MirrorTexture extends RenderTargetTexture {
  18790. private scene;
  18791. /**
  18792. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18793. * 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.
  18794. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18795. */
  18796. mirrorPlane: Plane;
  18797. /**
  18798. * Define the blur ratio used to blur the reflection if needed.
  18799. */
  18800. blurRatio: number;
  18801. /**
  18802. * Define the adaptive blur kernel used to blur the reflection if needed.
  18803. * This will autocompute the closest best match for the `blurKernel`
  18804. */
  18805. adaptiveBlurKernel: number;
  18806. /**
  18807. * Define the blur kernel used to blur the reflection if needed.
  18808. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18809. */
  18810. blurKernel: number;
  18811. /**
  18812. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18813. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18814. */
  18815. blurKernelX: number;
  18816. /**
  18817. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18818. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18819. */
  18820. blurKernelY: number;
  18821. private _autoComputeBlurKernel;
  18822. protected _onRatioRescale(): void;
  18823. private _updateGammaSpace;
  18824. private _imageProcessingConfigChangeObserver;
  18825. private _transformMatrix;
  18826. private _mirrorMatrix;
  18827. private _savedViewMatrix;
  18828. private _blurX;
  18829. private _blurY;
  18830. private _adaptiveBlurKernel;
  18831. private _blurKernelX;
  18832. private _blurKernelY;
  18833. private _blurRatio;
  18834. /**
  18835. * Instantiates a Mirror Texture.
  18836. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18837. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18838. * You can then easily use it as a reflectionTexture on a flat surface.
  18839. * In case the surface is not a plane, please consider relying on reflection probes.
  18840. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18841. * @param name
  18842. * @param size
  18843. * @param scene
  18844. * @param generateMipMaps
  18845. * @param type
  18846. * @param samplingMode
  18847. * @param generateDepthBuffer
  18848. */
  18849. constructor(name: string, size: number | {
  18850. width: number;
  18851. height: number;
  18852. } | {
  18853. ratio: number;
  18854. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18855. private _preparePostProcesses;
  18856. /**
  18857. * Clone the mirror texture.
  18858. * @returns the cloned texture
  18859. */
  18860. clone(): MirrorTexture;
  18861. /**
  18862. * Serialize the texture to a JSON representation you could use in Parse later on
  18863. * @returns the serialized JSON representation
  18864. */
  18865. serialize(): any;
  18866. /**
  18867. * Dispose the texture and release its associated resources.
  18868. */
  18869. dispose(): void;
  18870. }
  18871. }
  18872. declare module "babylonjs/Materials/Textures/texture" {
  18873. import { Observable } from "babylonjs/Misc/observable";
  18874. import { Nullable } from "babylonjs/types";
  18875. import { Scene } from "babylonjs/scene";
  18876. import { Matrix } from "babylonjs/Maths/math";
  18877. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18878. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18879. /**
  18880. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18881. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18882. */
  18883. export class Texture extends BaseTexture {
  18884. /** @hidden */
  18885. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18886. /** @hidden */
  18887. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18888. /** @hidden */
  18889. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18890. /** nearest is mag = nearest and min = nearest and mip = linear */
  18891. static readonly NEAREST_SAMPLINGMODE: number;
  18892. /** nearest is mag = nearest and min = nearest and mip = linear */
  18893. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18894. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18895. static readonly BILINEAR_SAMPLINGMODE: number;
  18896. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18897. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18898. /** Trilinear is mag = linear and min = linear and mip = linear */
  18899. static readonly TRILINEAR_SAMPLINGMODE: number;
  18900. /** Trilinear is mag = linear and min = linear and mip = linear */
  18901. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18902. /** mag = nearest and min = nearest and mip = nearest */
  18903. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18904. /** mag = nearest and min = linear and mip = nearest */
  18905. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18906. /** mag = nearest and min = linear and mip = linear */
  18907. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18908. /** mag = nearest and min = linear and mip = none */
  18909. static readonly NEAREST_LINEAR: number;
  18910. /** mag = nearest and min = nearest and mip = none */
  18911. static readonly NEAREST_NEAREST: number;
  18912. /** mag = linear and min = nearest and mip = nearest */
  18913. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18914. /** mag = linear and min = nearest and mip = linear */
  18915. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18916. /** mag = linear and min = linear and mip = none */
  18917. static readonly LINEAR_LINEAR: number;
  18918. /** mag = linear and min = nearest and mip = none */
  18919. static readonly LINEAR_NEAREST: number;
  18920. /** Explicit coordinates mode */
  18921. static readonly EXPLICIT_MODE: number;
  18922. /** Spherical coordinates mode */
  18923. static readonly SPHERICAL_MODE: number;
  18924. /** Planar coordinates mode */
  18925. static readonly PLANAR_MODE: number;
  18926. /** Cubic coordinates mode */
  18927. static readonly CUBIC_MODE: number;
  18928. /** Projection coordinates mode */
  18929. static readonly PROJECTION_MODE: number;
  18930. /** Inverse Cubic coordinates mode */
  18931. static readonly SKYBOX_MODE: number;
  18932. /** Inverse Cubic coordinates mode */
  18933. static readonly INVCUBIC_MODE: number;
  18934. /** Equirectangular coordinates mode */
  18935. static readonly EQUIRECTANGULAR_MODE: number;
  18936. /** Equirectangular Fixed coordinates mode */
  18937. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18938. /** Equirectangular Fixed Mirrored coordinates mode */
  18939. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18940. /** Texture is not repeating outside of 0..1 UVs */
  18941. static readonly CLAMP_ADDRESSMODE: number;
  18942. /** Texture is repeating outside of 0..1 UVs */
  18943. static readonly WRAP_ADDRESSMODE: number;
  18944. /** Texture is repeating and mirrored */
  18945. static readonly MIRROR_ADDRESSMODE: number;
  18946. /**
  18947. * 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
  18948. */
  18949. static UseSerializedUrlIfAny: boolean;
  18950. /**
  18951. * Define the url of the texture.
  18952. */
  18953. url: Nullable<string>;
  18954. /**
  18955. * Define an offset on the texture to offset the u coordinates of the UVs
  18956. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18957. */
  18958. uOffset: number;
  18959. /**
  18960. * Define an offset on the texture to offset the v coordinates of the UVs
  18961. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18962. */
  18963. vOffset: number;
  18964. /**
  18965. * Define an offset on the texture to scale the u coordinates of the UVs
  18966. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18967. */
  18968. uScale: number;
  18969. /**
  18970. * Define an offset on the texture to scale the v coordinates of the UVs
  18971. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18972. */
  18973. vScale: number;
  18974. /**
  18975. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18976. * @see http://doc.babylonjs.com/how_to/more_materials
  18977. */
  18978. uAng: number;
  18979. /**
  18980. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18981. * @see http://doc.babylonjs.com/how_to/more_materials
  18982. */
  18983. vAng: number;
  18984. /**
  18985. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18986. * @see http://doc.babylonjs.com/how_to/more_materials
  18987. */
  18988. wAng: number;
  18989. /**
  18990. * Defines the center of rotation (U)
  18991. */
  18992. uRotationCenter: number;
  18993. /**
  18994. * Defines the center of rotation (V)
  18995. */
  18996. vRotationCenter: number;
  18997. /**
  18998. * Defines the center of rotation (W)
  18999. */
  19000. wRotationCenter: number;
  19001. /**
  19002. * Are mip maps generated for this texture or not.
  19003. */
  19004. readonly noMipmap: boolean;
  19005. /**
  19006. * List of inspectable custom properties (used by the Inspector)
  19007. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19008. */
  19009. inspectableCustomProperties: Nullable<IInspectable[]>;
  19010. private _noMipmap;
  19011. /** @hidden */
  19012. _invertY: boolean;
  19013. private _rowGenerationMatrix;
  19014. private _cachedTextureMatrix;
  19015. private _projectionModeMatrix;
  19016. private _t0;
  19017. private _t1;
  19018. private _t2;
  19019. private _cachedUOffset;
  19020. private _cachedVOffset;
  19021. private _cachedUScale;
  19022. private _cachedVScale;
  19023. private _cachedUAng;
  19024. private _cachedVAng;
  19025. private _cachedWAng;
  19026. private _cachedProjectionMatrixId;
  19027. private _cachedCoordinatesMode;
  19028. /** @hidden */
  19029. protected _initialSamplingMode: number;
  19030. /** @hidden */
  19031. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  19032. private _deleteBuffer;
  19033. protected _format: Nullable<number>;
  19034. private _delayedOnLoad;
  19035. private _delayedOnError;
  19036. /**
  19037. * Observable triggered once the texture has been loaded.
  19038. */
  19039. onLoadObservable: Observable<Texture>;
  19040. protected _isBlocking: boolean;
  19041. /**
  19042. * Is the texture preventing material to render while loading.
  19043. * If false, a default texture will be used instead of the loading one during the preparation step.
  19044. */
  19045. isBlocking: boolean;
  19046. /**
  19047. * Get the current sampling mode associated with the texture.
  19048. */
  19049. readonly samplingMode: number;
  19050. /**
  19051. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  19052. */
  19053. readonly invertY: boolean;
  19054. /**
  19055. * Instantiates a new texture.
  19056. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  19057. * @see http://doc.babylonjs.com/babylon101/materials#texture
  19058. * @param url define the url of the picture to load as a texture
  19059. * @param scene define the scene the texture will belong to
  19060. * @param noMipmap define if the texture will require mip maps or not
  19061. * @param invertY define if the texture needs to be inverted on the y axis during loading
  19062. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  19063. * @param onLoad define a callback triggered when the texture has been loaded
  19064. * @param onError define a callback triggered when an error occurred during the loading session
  19065. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  19066. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  19067. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  19068. */
  19069. 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);
  19070. /**
  19071. * Update the url (and optional buffer) of this texture if url was null during construction.
  19072. * @param url the url of the texture
  19073. * @param buffer the buffer of the texture (defaults to null)
  19074. * @param onLoad callback called when the texture is loaded (defaults to null)
  19075. */
  19076. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  19077. /**
  19078. * Finish the loading sequence of a texture flagged as delayed load.
  19079. * @hidden
  19080. */
  19081. delayLoad(): void;
  19082. private _prepareRowForTextureGeneration;
  19083. /**
  19084. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  19085. * @returns the transform matrix of the texture.
  19086. */
  19087. getTextureMatrix(): Matrix;
  19088. /**
  19089. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  19090. * @returns The reflection texture transform
  19091. */
  19092. getReflectionTextureMatrix(): Matrix;
  19093. /**
  19094. * Clones the texture.
  19095. * @returns the cloned texture
  19096. */
  19097. clone(): Texture;
  19098. /**
  19099. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19100. * @returns The JSON representation of the texture
  19101. */
  19102. serialize(): any;
  19103. /**
  19104. * Get the current class name of the texture useful for serialization or dynamic coding.
  19105. * @returns "Texture"
  19106. */
  19107. getClassName(): string;
  19108. /**
  19109. * Dispose the texture and release its associated resources.
  19110. */
  19111. dispose(): void;
  19112. /**
  19113. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  19114. * @param parsedTexture Define the JSON representation of the texture
  19115. * @param scene Define the scene the parsed texture should be instantiated in
  19116. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  19117. * @returns The parsed texture if successful
  19118. */
  19119. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  19120. /**
  19121. * Creates a texture from its base 64 representation.
  19122. * @param data Define the base64 payload without the data: prefix
  19123. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  19124. * @param scene Define the scene the texture should belong to
  19125. * @param noMipmap Forces the texture to not create mip map information if true
  19126. * @param invertY define if the texture needs to be inverted on the y axis during loading
  19127. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  19128. * @param onLoad define a callback triggered when the texture has been loaded
  19129. * @param onError define a callback triggered when an error occurred during the loading session
  19130. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  19131. * @returns the created texture
  19132. */
  19133. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  19134. /**
  19135. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  19136. * @param data Define the base64 payload without the data: prefix
  19137. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  19138. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  19139. * @param scene Define the scene the texture should belong to
  19140. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  19141. * @param noMipmap Forces the texture to not create mip map information if true
  19142. * @param invertY define if the texture needs to be inverted on the y axis during loading
  19143. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  19144. * @param onLoad define a callback triggered when the texture has been loaded
  19145. * @param onError define a callback triggered when an error occurred during the loading session
  19146. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  19147. * @returns the created texture
  19148. */
  19149. 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;
  19150. }
  19151. }
  19152. declare module "babylonjs/PostProcesses/postProcessManager" {
  19153. import { Nullable } from "babylonjs/types";
  19154. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19155. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19156. import { Scene } from "babylonjs/scene";
  19157. /**
  19158. * PostProcessManager is used to manage one or more post processes or post process pipelines
  19159. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19160. */
  19161. export class PostProcessManager {
  19162. private _scene;
  19163. private _indexBuffer;
  19164. private _vertexBuffers;
  19165. /**
  19166. * Creates a new instance PostProcess
  19167. * @param scene The scene that the post process is associated with.
  19168. */
  19169. constructor(scene: Scene);
  19170. private _prepareBuffers;
  19171. private _buildIndexBuffer;
  19172. /**
  19173. * Rebuilds the vertex buffers of the manager.
  19174. * @hidden
  19175. */
  19176. _rebuild(): void;
  19177. /**
  19178. * Prepares a frame to be run through a post process.
  19179. * @param sourceTexture The input texture to the post procesess. (default: null)
  19180. * @param postProcesses An array of post processes to be run. (default: null)
  19181. * @returns True if the post processes were able to be run.
  19182. * @hidden
  19183. */
  19184. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  19185. /**
  19186. * Manually render a set of post processes to a texture.
  19187. * @param postProcesses An array of post processes to be run.
  19188. * @param targetTexture The target texture to render to.
  19189. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  19190. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  19191. * @param lodLevel defines which lod of the texture to render to
  19192. */
  19193. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  19194. /**
  19195. * Finalize the result of the output of the postprocesses.
  19196. * @param doNotPresent If true the result will not be displayed to the screen.
  19197. * @param targetTexture The target texture to render to.
  19198. * @param faceIndex The index of the face to bind the target texture to.
  19199. * @param postProcesses The array of post processes to render.
  19200. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  19201. * @hidden
  19202. */
  19203. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  19204. /**
  19205. * Disposes of the post process manager.
  19206. */
  19207. dispose(): void;
  19208. }
  19209. }
  19210. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  19211. import { Scene } from "babylonjs/scene";
  19212. import { ISceneComponent } from "babylonjs/sceneComponent";
  19213. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  19214. module "babylonjs/abstractScene" {
  19215. interface AbstractScene {
  19216. /**
  19217. * The list of procedural textures added to the scene
  19218. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19219. */
  19220. proceduralTextures: Array<ProceduralTexture>;
  19221. }
  19222. }
  19223. /**
  19224. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  19225. * in a given scene.
  19226. */
  19227. export class ProceduralTextureSceneComponent implements ISceneComponent {
  19228. /**
  19229. * The component name helpfull to identify the component in the list of scene components.
  19230. */
  19231. readonly name: string;
  19232. /**
  19233. * The scene the component belongs to.
  19234. */
  19235. scene: Scene;
  19236. /**
  19237. * Creates a new instance of the component for the given scene
  19238. * @param scene Defines the scene to register the component in
  19239. */
  19240. constructor(scene: Scene);
  19241. /**
  19242. * Registers the component in a given scene
  19243. */
  19244. register(): void;
  19245. /**
  19246. * Rebuilds the elements related to this component in case of
  19247. * context lost for instance.
  19248. */
  19249. rebuild(): void;
  19250. /**
  19251. * Disposes the component and the associated ressources.
  19252. */
  19253. dispose(): void;
  19254. private _beforeClear;
  19255. }
  19256. }
  19257. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  19258. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19259. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  19260. module "babylonjs/Engines/engine" {
  19261. interface Engine {
  19262. /**
  19263. * Creates a new render target cube texture
  19264. * @param size defines the size of the texture
  19265. * @param options defines the options used to create the texture
  19266. * @returns a new render target cube texture stored in an InternalTexture
  19267. */
  19268. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  19269. }
  19270. }
  19271. }
  19272. declare module "babylonjs/Shaders/procedural.vertex" {
  19273. /** @hidden */
  19274. export var proceduralVertexShader: {
  19275. name: string;
  19276. shader: string;
  19277. };
  19278. }
  19279. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  19280. import { Observable } from "babylonjs/Misc/observable";
  19281. import { Nullable } from "babylonjs/types";
  19282. import { Scene } from "babylonjs/scene";
  19283. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  19284. import { Effect } from "babylonjs/Materials/effect";
  19285. import { Texture } from "babylonjs/Materials/Textures/texture";
  19286. import "babylonjs/Engines/Extensions/engine.renderTarget";
  19287. import "babylonjs/Shaders/procedural.vertex";
  19288. /**
  19289. * 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.
  19290. * This is the base class of any Procedural texture and contains most of the shareable code.
  19291. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19292. */
  19293. export class ProceduralTexture extends Texture {
  19294. isCube: boolean;
  19295. /**
  19296. * Define if the texture is enabled or not (disabled texture will not render)
  19297. */
  19298. isEnabled: boolean;
  19299. /**
  19300. * Define if the texture must be cleared before rendering (default is true)
  19301. */
  19302. autoClear: boolean;
  19303. /**
  19304. * Callback called when the texture is generated
  19305. */
  19306. onGenerated: () => void;
  19307. /**
  19308. * Event raised when the texture is generated
  19309. */
  19310. onGeneratedObservable: Observable<ProceduralTexture>;
  19311. /** @hidden */
  19312. _generateMipMaps: boolean;
  19313. /** @hidden **/
  19314. _effect: Effect;
  19315. /** @hidden */
  19316. _textures: {
  19317. [key: string]: Texture;
  19318. };
  19319. private _size;
  19320. private _currentRefreshId;
  19321. private _refreshRate;
  19322. private _vertexBuffers;
  19323. private _indexBuffer;
  19324. private _uniforms;
  19325. private _samplers;
  19326. private _fragment;
  19327. private _floats;
  19328. private _ints;
  19329. private _floatsArrays;
  19330. private _colors3;
  19331. private _colors4;
  19332. private _vectors2;
  19333. private _vectors3;
  19334. private _matrices;
  19335. private _fallbackTexture;
  19336. private _fallbackTextureUsed;
  19337. private _engine;
  19338. private _cachedDefines;
  19339. private _contentUpdateId;
  19340. private _contentData;
  19341. /**
  19342. * Instantiates a new procedural texture.
  19343. * 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.
  19344. * This is the base class of any Procedural texture and contains most of the shareable code.
  19345. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19346. * @param name Define the name of the texture
  19347. * @param size Define the size of the texture to create
  19348. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  19349. * @param scene Define the scene the texture belongs to
  19350. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  19351. * @param generateMipMaps Define if the texture should creates mip maps or not
  19352. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  19353. */
  19354. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  19355. /**
  19356. * The effect that is created when initializing the post process.
  19357. * @returns The created effect corresponding the the postprocess.
  19358. */
  19359. getEffect(): Effect;
  19360. /**
  19361. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  19362. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  19363. */
  19364. getContent(): Nullable<ArrayBufferView>;
  19365. private _createIndexBuffer;
  19366. /** @hidden */
  19367. _rebuild(): void;
  19368. /**
  19369. * Resets the texture in order to recreate its associated resources.
  19370. * This can be called in case of context loss
  19371. */
  19372. reset(): void;
  19373. protected _getDefines(): string;
  19374. /**
  19375. * Is the texture ready to be used ? (rendered at least once)
  19376. * @returns true if ready, otherwise, false.
  19377. */
  19378. isReady(): boolean;
  19379. /**
  19380. * Resets the refresh counter of the texture and start bak from scratch.
  19381. * Could be useful to regenerate the texture if it is setup to render only once.
  19382. */
  19383. resetRefreshCounter(): void;
  19384. /**
  19385. * Set the fragment shader to use in order to render the texture.
  19386. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  19387. */
  19388. setFragment(fragment: any): void;
  19389. /**
  19390. * Define the refresh rate of the texture or the rendering frequency.
  19391. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19392. */
  19393. refreshRate: number;
  19394. /** @hidden */
  19395. _shouldRender(): boolean;
  19396. /**
  19397. * Get the size the texture is rendering at.
  19398. * @returns the size (texture is always squared)
  19399. */
  19400. getRenderSize(): number;
  19401. /**
  19402. * Resize the texture to new value.
  19403. * @param size Define the new size the texture should have
  19404. * @param generateMipMaps Define whether the new texture should create mip maps
  19405. */
  19406. resize(size: number, generateMipMaps: boolean): void;
  19407. private _checkUniform;
  19408. /**
  19409. * Set a texture in the shader program used to render.
  19410. * @param name Define the name of the uniform samplers as defined in the shader
  19411. * @param texture Define the texture to bind to this sampler
  19412. * @return the texture itself allowing "fluent" like uniform updates
  19413. */
  19414. setTexture(name: string, texture: Texture): ProceduralTexture;
  19415. /**
  19416. * Set a float in the shader.
  19417. * @param name Define the name of the uniform as defined in the shader
  19418. * @param value Define the value to give to the uniform
  19419. * @return the texture itself allowing "fluent" like uniform updates
  19420. */
  19421. setFloat(name: string, value: number): ProceduralTexture;
  19422. /**
  19423. * Set a int in the shader.
  19424. * @param name Define the name of the uniform as defined in the shader
  19425. * @param value Define the value to give to the uniform
  19426. * @return the texture itself allowing "fluent" like uniform updates
  19427. */
  19428. setInt(name: string, value: number): ProceduralTexture;
  19429. /**
  19430. * Set an array of floats in the shader.
  19431. * @param name Define the name of the uniform as defined in the shader
  19432. * @param value Define the value to give to the uniform
  19433. * @return the texture itself allowing "fluent" like uniform updates
  19434. */
  19435. setFloats(name: string, value: number[]): ProceduralTexture;
  19436. /**
  19437. * Set a vec3 in the shader from a Color3.
  19438. * @param name Define the name of the uniform as defined in the shader
  19439. * @param value Define the value to give to the uniform
  19440. * @return the texture itself allowing "fluent" like uniform updates
  19441. */
  19442. setColor3(name: string, value: Color3): ProceduralTexture;
  19443. /**
  19444. * Set a vec4 in the shader from a Color4.
  19445. * @param name Define the name of the uniform as defined in the shader
  19446. * @param value Define the value to give to the uniform
  19447. * @return the texture itself allowing "fluent" like uniform updates
  19448. */
  19449. setColor4(name: string, value: Color4): ProceduralTexture;
  19450. /**
  19451. * Set a vec2 in the shader from a Vector2.
  19452. * @param name Define the name of the uniform as defined in the shader
  19453. * @param value Define the value to give to the uniform
  19454. * @return the texture itself allowing "fluent" like uniform updates
  19455. */
  19456. setVector2(name: string, value: Vector2): ProceduralTexture;
  19457. /**
  19458. * Set a vec3 in the shader from a Vector3.
  19459. * @param name Define the name of the uniform as defined in the shader
  19460. * @param value Define the value to give to the uniform
  19461. * @return the texture itself allowing "fluent" like uniform updates
  19462. */
  19463. setVector3(name: string, value: Vector3): ProceduralTexture;
  19464. /**
  19465. * Set a mat4 in the shader from a MAtrix.
  19466. * @param name Define the name of the uniform as defined in the shader
  19467. * @param value Define the value to give to the uniform
  19468. * @return the texture itself allowing "fluent" like uniform updates
  19469. */
  19470. setMatrix(name: string, value: Matrix): ProceduralTexture;
  19471. /**
  19472. * Render the texture to its associated render target.
  19473. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  19474. */
  19475. render(useCameraPostProcess?: boolean): void;
  19476. /**
  19477. * Clone the texture.
  19478. * @returns the cloned texture
  19479. */
  19480. clone(): ProceduralTexture;
  19481. /**
  19482. * Dispose the texture and release its asoociated resources.
  19483. */
  19484. dispose(): void;
  19485. }
  19486. }
  19487. declare module "babylonjs/Particles/baseParticleSystem" {
  19488. import { Nullable } from "babylonjs/types";
  19489. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  19490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19491. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  19492. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  19493. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19494. import { Scene } from "babylonjs/scene";
  19495. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  19496. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  19497. import { Texture } from "babylonjs/Materials/Textures/texture";
  19498. import { Animation } from "babylonjs/Animations/animation";
  19499. /**
  19500. * This represents the base class for particle system in Babylon.
  19501. * 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.
  19502. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  19503. * @example https://doc.babylonjs.com/babylon101/particles
  19504. */
  19505. export class BaseParticleSystem {
  19506. /**
  19507. * Source color is added to the destination color without alpha affecting the result
  19508. */
  19509. static BLENDMODE_ONEONE: number;
  19510. /**
  19511. * Blend current color and particle color using particle’s alpha
  19512. */
  19513. static BLENDMODE_STANDARD: number;
  19514. /**
  19515. * Add current color and particle color multiplied by particle’s alpha
  19516. */
  19517. static BLENDMODE_ADD: number;
  19518. /**
  19519. * Multiply current color with particle color
  19520. */
  19521. static BLENDMODE_MULTIPLY: number;
  19522. /**
  19523. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  19524. */
  19525. static BLENDMODE_MULTIPLYADD: number;
  19526. /**
  19527. * List of animations used by the particle system.
  19528. */
  19529. animations: Animation[];
  19530. /**
  19531. * The id of the Particle system.
  19532. */
  19533. id: string;
  19534. /**
  19535. * The friendly name of the Particle system.
  19536. */
  19537. name: string;
  19538. /**
  19539. * The rendering group used by the Particle system to chose when to render.
  19540. */
  19541. renderingGroupId: number;
  19542. /**
  19543. * The emitter represents the Mesh or position we are attaching the particle system to.
  19544. */
  19545. emitter: Nullable<AbstractMesh | Vector3>;
  19546. /**
  19547. * The maximum number of particles to emit per frame
  19548. */
  19549. emitRate: number;
  19550. /**
  19551. * If you want to launch only a few particles at once, that can be done, as well.
  19552. */
  19553. manualEmitCount: number;
  19554. /**
  19555. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19556. */
  19557. updateSpeed: number;
  19558. /**
  19559. * The amount of time the particle system is running (depends of the overall update speed).
  19560. */
  19561. targetStopDuration: number;
  19562. /**
  19563. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19564. */
  19565. disposeOnStop: boolean;
  19566. /**
  19567. * Minimum power of emitting particles.
  19568. */
  19569. minEmitPower: number;
  19570. /**
  19571. * Maximum power of emitting particles.
  19572. */
  19573. maxEmitPower: number;
  19574. /**
  19575. * Minimum life time of emitting particles.
  19576. */
  19577. minLifeTime: number;
  19578. /**
  19579. * Maximum life time of emitting particles.
  19580. */
  19581. maxLifeTime: number;
  19582. /**
  19583. * Minimum Size of emitting particles.
  19584. */
  19585. minSize: number;
  19586. /**
  19587. * Maximum Size of emitting particles.
  19588. */
  19589. maxSize: number;
  19590. /**
  19591. * Minimum scale of emitting particles on X axis.
  19592. */
  19593. minScaleX: number;
  19594. /**
  19595. * Maximum scale of emitting particles on X axis.
  19596. */
  19597. maxScaleX: number;
  19598. /**
  19599. * Minimum scale of emitting particles on Y axis.
  19600. */
  19601. minScaleY: number;
  19602. /**
  19603. * Maximum scale of emitting particles on Y axis.
  19604. */
  19605. maxScaleY: number;
  19606. /**
  19607. * Gets or sets the minimal initial rotation in radians.
  19608. */
  19609. minInitialRotation: number;
  19610. /**
  19611. * Gets or sets the maximal initial rotation in radians.
  19612. */
  19613. maxInitialRotation: number;
  19614. /**
  19615. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19616. */
  19617. minAngularSpeed: number;
  19618. /**
  19619. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19620. */
  19621. maxAngularSpeed: number;
  19622. /**
  19623. * The texture used to render each particle. (this can be a spritesheet)
  19624. */
  19625. particleTexture: Nullable<Texture>;
  19626. /**
  19627. * The layer mask we are rendering the particles through.
  19628. */
  19629. layerMask: number;
  19630. /**
  19631. * This can help using your own shader to render the particle system.
  19632. * The according effect will be created
  19633. */
  19634. customShader: any;
  19635. /**
  19636. * By default particle system starts as soon as they are created. This prevents the
  19637. * automatic start to happen and let you decide when to start emitting particles.
  19638. */
  19639. preventAutoStart: boolean;
  19640. private _noiseTexture;
  19641. /**
  19642. * Gets or sets a texture used to add random noise to particle positions
  19643. */
  19644. noiseTexture: Nullable<ProceduralTexture>;
  19645. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19646. noiseStrength: Vector3;
  19647. /**
  19648. * Callback triggered when the particle animation is ending.
  19649. */
  19650. onAnimationEnd: Nullable<() => void>;
  19651. /**
  19652. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  19653. */
  19654. blendMode: number;
  19655. /**
  19656. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  19657. * to override the particles.
  19658. */
  19659. forceDepthWrite: boolean;
  19660. /** 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 */
  19661. preWarmCycles: number;
  19662. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  19663. preWarmStepOffset: number;
  19664. /**
  19665. * 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)
  19666. */
  19667. spriteCellChangeSpeed: number;
  19668. /**
  19669. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19670. */
  19671. startSpriteCellID: number;
  19672. /**
  19673. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19674. */
  19675. endSpriteCellID: number;
  19676. /**
  19677. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19678. */
  19679. spriteCellWidth: number;
  19680. /**
  19681. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19682. */
  19683. spriteCellHeight: number;
  19684. /**
  19685. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19686. */
  19687. spriteRandomStartCell: boolean;
  19688. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19689. translationPivot: Vector2;
  19690. /** @hidden */
  19691. protected _isAnimationSheetEnabled: boolean;
  19692. /**
  19693. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19694. */
  19695. beginAnimationOnStart: boolean;
  19696. /**
  19697. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19698. */
  19699. beginAnimationFrom: number;
  19700. /**
  19701. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19702. */
  19703. beginAnimationTo: number;
  19704. /**
  19705. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19706. */
  19707. beginAnimationLoop: boolean;
  19708. /**
  19709. * Gets or sets a world offset applied to all particles
  19710. */
  19711. worldOffset: Vector3;
  19712. /**
  19713. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  19714. */
  19715. isAnimationSheetEnabled: boolean;
  19716. /**
  19717. * Get hosting scene
  19718. * @returns the scene
  19719. */
  19720. getScene(): Scene;
  19721. /**
  19722. * You can use gravity if you want to give an orientation to your particles.
  19723. */
  19724. gravity: Vector3;
  19725. protected _colorGradients: Nullable<Array<ColorGradient>>;
  19726. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  19727. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  19728. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  19729. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  19730. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  19731. protected _dragGradients: Nullable<Array<FactorGradient>>;
  19732. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  19733. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  19734. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  19735. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  19736. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  19737. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  19738. /**
  19739. * Defines the delay in milliseconds before starting the system (0 by default)
  19740. */
  19741. startDelay: number;
  19742. /**
  19743. * Gets the current list of drag gradients.
  19744. * You must use addDragGradient and removeDragGradient to udpate this list
  19745. * @returns the list of drag gradients
  19746. */
  19747. getDragGradients(): Nullable<Array<FactorGradient>>;
  19748. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19749. limitVelocityDamping: number;
  19750. /**
  19751. * Gets the current list of limit velocity gradients.
  19752. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19753. * @returns the list of limit velocity gradients
  19754. */
  19755. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19756. /**
  19757. * Gets the current list of color gradients.
  19758. * You must use addColorGradient and removeColorGradient to udpate this list
  19759. * @returns the list of color gradients
  19760. */
  19761. getColorGradients(): Nullable<Array<ColorGradient>>;
  19762. /**
  19763. * Gets the current list of size gradients.
  19764. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19765. * @returns the list of size gradients
  19766. */
  19767. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19768. /**
  19769. * Gets the current list of color remap gradients.
  19770. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19771. * @returns the list of color remap gradients
  19772. */
  19773. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19774. /**
  19775. * Gets the current list of alpha remap gradients.
  19776. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19777. * @returns the list of alpha remap gradients
  19778. */
  19779. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19780. /**
  19781. * Gets the current list of life time gradients.
  19782. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19783. * @returns the list of life time gradients
  19784. */
  19785. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19786. /**
  19787. * Gets the current list of angular speed gradients.
  19788. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19789. * @returns the list of angular speed gradients
  19790. */
  19791. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19792. /**
  19793. * Gets the current list of velocity gradients.
  19794. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19795. * @returns the list of velocity gradients
  19796. */
  19797. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19798. /**
  19799. * Gets the current list of start size gradients.
  19800. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19801. * @returns the list of start size gradients
  19802. */
  19803. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19804. /**
  19805. * Gets the current list of emit rate gradients.
  19806. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19807. * @returns the list of emit rate gradients
  19808. */
  19809. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19810. /**
  19811. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19812. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19813. */
  19814. direction1: Vector3;
  19815. /**
  19816. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19817. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19818. */
  19819. direction2: Vector3;
  19820. /**
  19821. * 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.
  19822. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19823. */
  19824. minEmitBox: Vector3;
  19825. /**
  19826. * 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.
  19827. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19828. */
  19829. maxEmitBox: Vector3;
  19830. /**
  19831. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19832. */
  19833. color1: Color4;
  19834. /**
  19835. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19836. */
  19837. color2: Color4;
  19838. /**
  19839. * Color the particle will have at the end of its lifetime
  19840. */
  19841. colorDead: Color4;
  19842. /**
  19843. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  19844. */
  19845. textureMask: Color4;
  19846. /**
  19847. * The particle emitter type defines the emitter used by the particle system.
  19848. * It can be for example box, sphere, or cone...
  19849. */
  19850. particleEmitterType: IParticleEmitterType;
  19851. /** @hidden */
  19852. _isSubEmitter: boolean;
  19853. /**
  19854. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19855. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19856. */
  19857. billboardMode: number;
  19858. protected _isBillboardBased: boolean;
  19859. /**
  19860. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19861. */
  19862. isBillboardBased: boolean;
  19863. /**
  19864. * The scene the particle system belongs to.
  19865. */
  19866. protected _scene: Scene;
  19867. /**
  19868. * Local cache of defines for image processing.
  19869. */
  19870. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  19871. /**
  19872. * Default configuration related to image processing available in the standard Material.
  19873. */
  19874. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19875. /**
  19876. * Gets the image processing configuration used either in this material.
  19877. */
  19878. /**
  19879. * Sets the Default image processing configuration used either in the this material.
  19880. *
  19881. * If sets to null, the scene one is in use.
  19882. */
  19883. imageProcessingConfiguration: ImageProcessingConfiguration;
  19884. /**
  19885. * Attaches a new image processing configuration to the Standard Material.
  19886. * @param configuration
  19887. */
  19888. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19889. /** @hidden */
  19890. protected _reset(): void;
  19891. /** @hidden */
  19892. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  19893. /**
  19894. * Instantiates a particle system.
  19895. * 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.
  19896. * @param name The name of the particle system
  19897. */
  19898. constructor(name: string);
  19899. /**
  19900. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19901. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19902. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19903. * @returns the emitter
  19904. */
  19905. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19906. /**
  19907. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19908. * @param radius The radius of the hemisphere to emit from
  19909. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19910. * @returns the emitter
  19911. */
  19912. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  19913. /**
  19914. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19915. * @param radius The radius of the sphere to emit from
  19916. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19917. * @returns the emitter
  19918. */
  19919. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  19920. /**
  19921. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19922. * @param radius The radius of the sphere to emit from
  19923. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19924. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19925. * @returns the emitter
  19926. */
  19927. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  19928. /**
  19929. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19930. * @param radius The radius of the emission cylinder
  19931. * @param height The height of the emission cylinder
  19932. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19933. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19934. * @returns the emitter
  19935. */
  19936. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  19937. /**
  19938. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19939. * @param radius The radius of the cylinder to emit from
  19940. * @param height The height of the emission cylinder
  19941. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19942. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19943. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19944. * @returns the emitter
  19945. */
  19946. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  19947. /**
  19948. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19949. * @param radius The radius of the cone to emit from
  19950. * @param angle The base angle of the cone
  19951. * @returns the emitter
  19952. */
  19953. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  19954. /**
  19955. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19956. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19957. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19958. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19959. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19960. * @returns the emitter
  19961. */
  19962. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19963. }
  19964. }
  19965. declare module "babylonjs/Particles/subEmitter" {
  19966. import { Scene } from "babylonjs/scene";
  19967. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  19968. /**
  19969. * Type of sub emitter
  19970. */
  19971. export enum SubEmitterType {
  19972. /**
  19973. * Attached to the particle over it's lifetime
  19974. */
  19975. ATTACHED = 0,
  19976. /**
  19977. * Created when the particle dies
  19978. */
  19979. END = 1
  19980. }
  19981. /**
  19982. * Sub emitter class used to emit particles from an existing particle
  19983. */
  19984. export class SubEmitter {
  19985. /**
  19986. * the particle system to be used by the sub emitter
  19987. */
  19988. particleSystem: ParticleSystem;
  19989. /**
  19990. * Type of the submitter (Default: END)
  19991. */
  19992. type: SubEmitterType;
  19993. /**
  19994. * 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)
  19995. * Note: This only is supported when using an emitter of type Mesh
  19996. */
  19997. inheritDirection: boolean;
  19998. /**
  19999. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  20000. */
  20001. inheritedVelocityAmount: number;
  20002. /**
  20003. * Creates a sub emitter
  20004. * @param particleSystem the particle system to be used by the sub emitter
  20005. */
  20006. constructor(
  20007. /**
  20008. * the particle system to be used by the sub emitter
  20009. */
  20010. particleSystem: ParticleSystem);
  20011. /**
  20012. * Clones the sub emitter
  20013. * @returns the cloned sub emitter
  20014. */
  20015. clone(): SubEmitter;
  20016. /**
  20017. * Serialize current object to a JSON object
  20018. * @returns the serialized object
  20019. */
  20020. serialize(): any;
  20021. /** @hidden */
  20022. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  20023. /**
  20024. * Creates a new SubEmitter from a serialized JSON version
  20025. * @param serializationObject defines the JSON object to read from
  20026. * @param scene defines the hosting scene
  20027. * @param rootUrl defines the rootUrl for data loading
  20028. * @returns a new SubEmitter
  20029. */
  20030. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  20031. /** Release associated resources */
  20032. dispose(): void;
  20033. }
  20034. }
  20035. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  20036. /** @hidden */
  20037. export var imageProcessingDeclaration: {
  20038. name: string;
  20039. shader: string;
  20040. };
  20041. }
  20042. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  20043. /** @hidden */
  20044. export var imageProcessingFunctions: {
  20045. name: string;
  20046. shader: string;
  20047. };
  20048. }
  20049. declare module "babylonjs/Shaders/particles.fragment" {
  20050. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20051. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  20052. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  20053. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  20054. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20055. /** @hidden */
  20056. export var particlesPixelShader: {
  20057. name: string;
  20058. shader: string;
  20059. };
  20060. }
  20061. declare module "babylonjs/Shaders/particles.vertex" {
  20062. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20063. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20064. /** @hidden */
  20065. export var particlesVertexShader: {
  20066. name: string;
  20067. shader: string;
  20068. };
  20069. }
  20070. declare module "babylonjs/Particles/particleSystem" {
  20071. import { Nullable } from "babylonjs/types";
  20072. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  20073. import { Observable } from "babylonjs/Misc/observable";
  20074. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  20075. import { Effect } from "babylonjs/Materials/effect";
  20076. import { Scene, IDisposable } from "babylonjs/scene";
  20077. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20078. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  20079. import { Particle } from "babylonjs/Particles/particle";
  20080. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  20081. import "babylonjs/Shaders/particles.fragment";
  20082. import "babylonjs/Shaders/particles.vertex";
  20083. /**
  20084. * This represents a particle system in Babylon.
  20085. * 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.
  20086. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  20087. * @example https://doc.babylonjs.com/babylon101/particles
  20088. */
  20089. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  20090. /**
  20091. * Billboard mode will only apply to Y axis
  20092. */
  20093. static readonly BILLBOARDMODE_Y: number;
  20094. /**
  20095. * Billboard mode will apply to all axes
  20096. */
  20097. static readonly BILLBOARDMODE_ALL: number;
  20098. /**
  20099. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  20100. */
  20101. static readonly BILLBOARDMODE_STRETCHED: number;
  20102. /**
  20103. * This function can be defined to provide custom update for active particles.
  20104. * This function will be called instead of regular update (age, position, color, etc.).
  20105. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  20106. */
  20107. updateFunction: (particles: Particle[]) => void;
  20108. private _emitterWorldMatrix;
  20109. /**
  20110. * This function can be defined to specify initial direction for every new particle.
  20111. * It by default use the emitterType defined function
  20112. */
  20113. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  20114. /**
  20115. * This function can be defined to specify initial position for every new particle.
  20116. * It by default use the emitterType defined function
  20117. */
  20118. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  20119. /**
  20120. * @hidden
  20121. */
  20122. _inheritedVelocityOffset: Vector3;
  20123. /**
  20124. * An event triggered when the system is disposed
  20125. */
  20126. onDisposeObservable: Observable<ParticleSystem>;
  20127. private _onDisposeObserver;
  20128. /**
  20129. * Sets a callback that will be triggered when the system is disposed
  20130. */
  20131. onDispose: () => void;
  20132. private _particles;
  20133. private _epsilon;
  20134. private _capacity;
  20135. private _stockParticles;
  20136. private _newPartsExcess;
  20137. private _vertexData;
  20138. private _vertexBuffer;
  20139. private _vertexBuffers;
  20140. private _spriteBuffer;
  20141. private _indexBuffer;
  20142. private _effect;
  20143. private _customEffect;
  20144. private _cachedDefines;
  20145. private _scaledColorStep;
  20146. private _colorDiff;
  20147. private _scaledDirection;
  20148. private _scaledGravity;
  20149. private _currentRenderId;
  20150. private _alive;
  20151. private _useInstancing;
  20152. private _started;
  20153. private _stopped;
  20154. private _actualFrame;
  20155. private _scaledUpdateSpeed;
  20156. private _vertexBufferSize;
  20157. /** @hidden */
  20158. _currentEmitRateGradient: Nullable<FactorGradient>;
  20159. /** @hidden */
  20160. _currentEmitRate1: number;
  20161. /** @hidden */
  20162. _currentEmitRate2: number;
  20163. /** @hidden */
  20164. _currentStartSizeGradient: Nullable<FactorGradient>;
  20165. /** @hidden */
  20166. _currentStartSize1: number;
  20167. /** @hidden */
  20168. _currentStartSize2: number;
  20169. private readonly _rawTextureWidth;
  20170. private _rampGradientsTexture;
  20171. private _useRampGradients;
  20172. /** Gets or sets a boolean indicating that ramp gradients must be used
  20173. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  20174. */
  20175. useRampGradients: boolean;
  20176. /**
  20177. * 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.
  20178. * 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: [])
  20179. */
  20180. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  20181. private _subEmitters;
  20182. /**
  20183. * @hidden
  20184. * If the particle systems emitter should be disposed when the particle system is disposed
  20185. */
  20186. _disposeEmitterOnDispose: boolean;
  20187. /**
  20188. * The current active Sub-systems, this property is used by the root particle system only.
  20189. */
  20190. activeSubSystems: Array<ParticleSystem>;
  20191. private _rootParticleSystem;
  20192. /**
  20193. * Gets the current list of active particles
  20194. */
  20195. readonly particles: Particle[];
  20196. /**
  20197. * Returns the string "ParticleSystem"
  20198. * @returns a string containing the class name
  20199. */
  20200. getClassName(): string;
  20201. /**
  20202. * Instantiates a particle system.
  20203. * 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.
  20204. * @param name The name of the particle system
  20205. * @param capacity The max number of particles alive at the same time
  20206. * @param scene The scene the particle system belongs to
  20207. * @param customEffect a custom effect used to change the way particles are rendered by default
  20208. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  20209. * @param epsilon Offset used to render the particles
  20210. */
  20211. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  20212. private _addFactorGradient;
  20213. private _removeFactorGradient;
  20214. /**
  20215. * Adds a new life time gradient
  20216. * @param gradient defines the gradient to use (between 0 and 1)
  20217. * @param factor defines the life time factor to affect to the specified gradient
  20218. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20219. * @returns the current particle system
  20220. */
  20221. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20222. /**
  20223. * Remove a specific life time gradient
  20224. * @param gradient defines the gradient to remove
  20225. * @returns the current particle system
  20226. */
  20227. removeLifeTimeGradient(gradient: number): IParticleSystem;
  20228. /**
  20229. * Adds a new size gradient
  20230. * @param gradient defines the gradient to use (between 0 and 1)
  20231. * @param factor defines the size factor to affect to the specified gradient
  20232. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20233. * @returns the current particle system
  20234. */
  20235. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20236. /**
  20237. * Remove a specific size gradient
  20238. * @param gradient defines the gradient to remove
  20239. * @returns the current particle system
  20240. */
  20241. removeSizeGradient(gradient: number): IParticleSystem;
  20242. /**
  20243. * Adds a new color remap gradient
  20244. * @param gradient defines the gradient to use (between 0 and 1)
  20245. * @param min defines the color remap minimal range
  20246. * @param max defines the color remap maximal range
  20247. * @returns the current particle system
  20248. */
  20249. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  20250. /**
  20251. * Remove a specific color remap gradient
  20252. * @param gradient defines the gradient to remove
  20253. * @returns the current particle system
  20254. */
  20255. removeColorRemapGradient(gradient: number): IParticleSystem;
  20256. /**
  20257. * Adds a new alpha remap gradient
  20258. * @param gradient defines the gradient to use (between 0 and 1)
  20259. * @param min defines the alpha remap minimal range
  20260. * @param max defines the alpha remap maximal range
  20261. * @returns the current particle system
  20262. */
  20263. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  20264. /**
  20265. * Remove a specific alpha remap gradient
  20266. * @param gradient defines the gradient to remove
  20267. * @returns the current particle system
  20268. */
  20269. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  20270. /**
  20271. * Adds a new angular speed gradient
  20272. * @param gradient defines the gradient to use (between 0 and 1)
  20273. * @param factor defines the angular speed to affect to the specified gradient
  20274. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20275. * @returns the current particle system
  20276. */
  20277. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20278. /**
  20279. * Remove a specific angular speed gradient
  20280. * @param gradient defines the gradient to remove
  20281. * @returns the current particle system
  20282. */
  20283. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  20284. /**
  20285. * Adds a new velocity gradient
  20286. * @param gradient defines the gradient to use (between 0 and 1)
  20287. * @param factor defines the velocity to affect to the specified gradient
  20288. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20289. * @returns the current particle system
  20290. */
  20291. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20292. /**
  20293. * Remove a specific velocity gradient
  20294. * @param gradient defines the gradient to remove
  20295. * @returns the current particle system
  20296. */
  20297. removeVelocityGradient(gradient: number): IParticleSystem;
  20298. /**
  20299. * Adds a new limit velocity gradient
  20300. * @param gradient defines the gradient to use (between 0 and 1)
  20301. * @param factor defines the limit velocity value to affect to the specified gradient
  20302. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20303. * @returns the current particle system
  20304. */
  20305. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20306. /**
  20307. * Remove a specific limit velocity gradient
  20308. * @param gradient defines the gradient to remove
  20309. * @returns the current particle system
  20310. */
  20311. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  20312. /**
  20313. * Adds a new drag gradient
  20314. * @param gradient defines the gradient to use (between 0 and 1)
  20315. * @param factor defines the drag value to affect to the specified gradient
  20316. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20317. * @returns the current particle system
  20318. */
  20319. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20320. /**
  20321. * Remove a specific drag gradient
  20322. * @param gradient defines the gradient to remove
  20323. * @returns the current particle system
  20324. */
  20325. removeDragGradient(gradient: number): IParticleSystem;
  20326. /**
  20327. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  20328. * @param gradient defines the gradient to use (between 0 and 1)
  20329. * @param factor defines the emit rate value to affect to the specified gradient
  20330. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20331. * @returns the current particle system
  20332. */
  20333. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20334. /**
  20335. * Remove a specific emit rate gradient
  20336. * @param gradient defines the gradient to remove
  20337. * @returns the current particle system
  20338. */
  20339. removeEmitRateGradient(gradient: number): IParticleSystem;
  20340. /**
  20341. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  20342. * @param gradient defines the gradient to use (between 0 and 1)
  20343. * @param factor defines the start size value to affect to the specified gradient
  20344. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20345. * @returns the current particle system
  20346. */
  20347. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20348. /**
  20349. * Remove a specific start size gradient
  20350. * @param gradient defines the gradient to remove
  20351. * @returns the current particle system
  20352. */
  20353. removeStartSizeGradient(gradient: number): IParticleSystem;
  20354. private _createRampGradientTexture;
  20355. /**
  20356. * Gets the current list of ramp gradients.
  20357. * You must use addRampGradient and removeRampGradient to udpate this list
  20358. * @returns the list of ramp gradients
  20359. */
  20360. getRampGradients(): Nullable<Array<Color3Gradient>>;
  20361. /**
  20362. * Adds a new ramp gradient used to remap particle colors
  20363. * @param gradient defines the gradient to use (between 0 and 1)
  20364. * @param color defines the color to affect to the specified gradient
  20365. * @returns the current particle system
  20366. */
  20367. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  20368. /**
  20369. * Remove a specific ramp gradient
  20370. * @param gradient defines the gradient to remove
  20371. * @returns the current particle system
  20372. */
  20373. removeRampGradient(gradient: number): ParticleSystem;
  20374. /**
  20375. * Adds a new color gradient
  20376. * @param gradient defines the gradient to use (between 0 and 1)
  20377. * @param color1 defines the color to affect to the specified gradient
  20378. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  20379. * @returns this particle system
  20380. */
  20381. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  20382. /**
  20383. * Remove a specific color gradient
  20384. * @param gradient defines the gradient to remove
  20385. * @returns this particle system
  20386. */
  20387. removeColorGradient(gradient: number): IParticleSystem;
  20388. private _fetchR;
  20389. protected _reset(): void;
  20390. private _resetEffect;
  20391. private _createVertexBuffers;
  20392. private _createIndexBuffer;
  20393. /**
  20394. * Gets the maximum number of particles active at the same time.
  20395. * @returns The max number of active particles.
  20396. */
  20397. getCapacity(): number;
  20398. /**
  20399. * Gets whether there are still active particles in the system.
  20400. * @returns True if it is alive, otherwise false.
  20401. */
  20402. isAlive(): boolean;
  20403. /**
  20404. * Gets if the system has been started. (Note: this will still be true after stop is called)
  20405. * @returns True if it has been started, otherwise false.
  20406. */
  20407. isStarted(): boolean;
  20408. private _prepareSubEmitterInternalArray;
  20409. /**
  20410. * Starts the particle system and begins to emit
  20411. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  20412. */
  20413. start(delay?: number): void;
  20414. /**
  20415. * Stops the particle system.
  20416. * @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.
  20417. */
  20418. stop(stopSubEmitters?: boolean): void;
  20419. /**
  20420. * Remove all active particles
  20421. */
  20422. reset(): void;
  20423. /**
  20424. * @hidden (for internal use only)
  20425. */
  20426. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  20427. /**
  20428. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  20429. * Its lifetime will start back at 0.
  20430. */
  20431. recycleParticle: (particle: Particle) => void;
  20432. private _stopSubEmitters;
  20433. private _createParticle;
  20434. private _removeFromRoot;
  20435. private _emitFromParticle;
  20436. private _update;
  20437. /** @hidden */
  20438. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  20439. /** @hidden */
  20440. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  20441. /** @hidden */
  20442. private _getEffect;
  20443. /**
  20444. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  20445. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  20446. */
  20447. animate(preWarmOnly?: boolean): void;
  20448. private _appendParticleVertices;
  20449. /**
  20450. * Rebuilds the particle system.
  20451. */
  20452. rebuild(): void;
  20453. /**
  20454. * Is this system ready to be used/rendered
  20455. * @return true if the system is ready
  20456. */
  20457. isReady(): boolean;
  20458. private _render;
  20459. /**
  20460. * Renders the particle system in its current state.
  20461. * @returns the current number of particles
  20462. */
  20463. render(): number;
  20464. /**
  20465. * Disposes the particle system and free the associated resources
  20466. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  20467. */
  20468. dispose(disposeTexture?: boolean): void;
  20469. /**
  20470. * Clones the particle system.
  20471. * @param name The name of the cloned object
  20472. * @param newEmitter The new emitter to use
  20473. * @returns the cloned particle system
  20474. */
  20475. clone(name: string, newEmitter: any): ParticleSystem;
  20476. /**
  20477. * Serializes the particle system to a JSON object.
  20478. * @returns the JSON object
  20479. */
  20480. serialize(): any;
  20481. /** @hidden */
  20482. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  20483. /** @hidden */
  20484. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  20485. /**
  20486. * Parses a JSON object to create a particle system.
  20487. * @param parsedParticleSystem The JSON object to parse
  20488. * @param scene The scene to create the particle system in
  20489. * @param rootUrl The root url to use to load external dependencies like texture
  20490. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  20491. * @returns the Parsed particle system
  20492. */
  20493. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  20494. }
  20495. }
  20496. declare module "babylonjs/Particles/particle" {
  20497. import { Nullable } from "babylonjs/types";
  20498. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  20499. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  20500. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  20501. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  20502. /**
  20503. * A particle represents one of the element emitted by a particle system.
  20504. * This is mainly define by its coordinates, direction, velocity and age.
  20505. */
  20506. export class Particle {
  20507. /**
  20508. * The particle system the particle belongs to.
  20509. */
  20510. particleSystem: ParticleSystem;
  20511. private static _Count;
  20512. /**
  20513. * Unique ID of the particle
  20514. */
  20515. id: number;
  20516. /**
  20517. * The world position of the particle in the scene.
  20518. */
  20519. position: Vector3;
  20520. /**
  20521. * The world direction of the particle in the scene.
  20522. */
  20523. direction: Vector3;
  20524. /**
  20525. * The color of the particle.
  20526. */
  20527. color: Color4;
  20528. /**
  20529. * The color change of the particle per step.
  20530. */
  20531. colorStep: Color4;
  20532. /**
  20533. * Defines how long will the life of the particle be.
  20534. */
  20535. lifeTime: number;
  20536. /**
  20537. * The current age of the particle.
  20538. */
  20539. age: number;
  20540. /**
  20541. * The current size of the particle.
  20542. */
  20543. size: number;
  20544. /**
  20545. * The current scale of the particle.
  20546. */
  20547. scale: Vector2;
  20548. /**
  20549. * The current angle of the particle.
  20550. */
  20551. angle: number;
  20552. /**
  20553. * Defines how fast is the angle changing.
  20554. */
  20555. angularSpeed: number;
  20556. /**
  20557. * Defines the cell index used by the particle to be rendered from a sprite.
  20558. */
  20559. cellIndex: number;
  20560. /**
  20561. * The information required to support color remapping
  20562. */
  20563. remapData: Vector4;
  20564. /** @hidden */
  20565. _randomCellOffset?: number;
  20566. /** @hidden */
  20567. _initialDirection: Nullable<Vector3>;
  20568. /** @hidden */
  20569. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  20570. /** @hidden */
  20571. _initialStartSpriteCellID: number;
  20572. /** @hidden */
  20573. _initialEndSpriteCellID: number;
  20574. /** @hidden */
  20575. _currentColorGradient: Nullable<ColorGradient>;
  20576. /** @hidden */
  20577. _currentColor1: Color4;
  20578. /** @hidden */
  20579. _currentColor2: Color4;
  20580. /** @hidden */
  20581. _currentSizeGradient: Nullable<FactorGradient>;
  20582. /** @hidden */
  20583. _currentSize1: number;
  20584. /** @hidden */
  20585. _currentSize2: number;
  20586. /** @hidden */
  20587. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  20588. /** @hidden */
  20589. _currentAngularSpeed1: number;
  20590. /** @hidden */
  20591. _currentAngularSpeed2: number;
  20592. /** @hidden */
  20593. _currentVelocityGradient: Nullable<FactorGradient>;
  20594. /** @hidden */
  20595. _currentVelocity1: number;
  20596. /** @hidden */
  20597. _currentVelocity2: number;
  20598. /** @hidden */
  20599. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  20600. /** @hidden */
  20601. _currentLimitVelocity1: number;
  20602. /** @hidden */
  20603. _currentLimitVelocity2: number;
  20604. /** @hidden */
  20605. _currentDragGradient: Nullable<FactorGradient>;
  20606. /** @hidden */
  20607. _currentDrag1: number;
  20608. /** @hidden */
  20609. _currentDrag2: number;
  20610. /** @hidden */
  20611. _randomNoiseCoordinates1: Vector3;
  20612. /** @hidden */
  20613. _randomNoiseCoordinates2: Vector3;
  20614. /**
  20615. * Creates a new instance Particle
  20616. * @param particleSystem the particle system the particle belongs to
  20617. */
  20618. constructor(
  20619. /**
  20620. * The particle system the particle belongs to.
  20621. */
  20622. particleSystem: ParticleSystem);
  20623. private updateCellInfoFromSystem;
  20624. /**
  20625. * Defines how the sprite cell index is updated for the particle
  20626. */
  20627. updateCellIndex(): void;
  20628. /** @hidden */
  20629. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  20630. /** @hidden */
  20631. _inheritParticleInfoToSubEmitters(): void;
  20632. /** @hidden */
  20633. _reset(): void;
  20634. /**
  20635. * Copy the properties of particle to another one.
  20636. * @param other the particle to copy the information to.
  20637. */
  20638. copyTo(other: Particle): void;
  20639. }
  20640. }
  20641. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  20642. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20643. import { Effect } from "babylonjs/Materials/effect";
  20644. import { Particle } from "babylonjs/Particles/particle";
  20645. /**
  20646. * Particle emitter represents a volume emitting particles.
  20647. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  20648. */
  20649. export interface IParticleEmitterType {
  20650. /**
  20651. * Called by the particle System when the direction is computed for the created particle.
  20652. * @param worldMatrix is the world matrix of the particle system
  20653. * @param directionToUpdate is the direction vector to update with the result
  20654. * @param particle is the particle we are computed the direction for
  20655. */
  20656. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20657. /**
  20658. * Called by the particle System when the position is computed for the created particle.
  20659. * @param worldMatrix is the world matrix of the particle system
  20660. * @param positionToUpdate is the position vector to update with the result
  20661. * @param particle is the particle we are computed the position for
  20662. */
  20663. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20664. /**
  20665. * Clones the current emitter and returns a copy of it
  20666. * @returns the new emitter
  20667. */
  20668. clone(): IParticleEmitterType;
  20669. /**
  20670. * Called by the GPUParticleSystem to setup the update shader
  20671. * @param effect defines the update shader
  20672. */
  20673. applyToShader(effect: Effect): void;
  20674. /**
  20675. * Returns a string to use to update the GPU particles update shader
  20676. * @returns the effect defines string
  20677. */
  20678. getEffectDefines(): string;
  20679. /**
  20680. * Returns a string representing the class name
  20681. * @returns a string containing the class name
  20682. */
  20683. getClassName(): string;
  20684. /**
  20685. * Serializes the particle system to a JSON object.
  20686. * @returns the JSON object
  20687. */
  20688. serialize(): any;
  20689. /**
  20690. * Parse properties from a JSON object
  20691. * @param serializationObject defines the JSON object
  20692. */
  20693. parse(serializationObject: any): void;
  20694. }
  20695. }
  20696. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  20697. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20698. import { Effect } from "babylonjs/Materials/effect";
  20699. import { Particle } from "babylonjs/Particles/particle";
  20700. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20701. /**
  20702. * Particle emitter emitting particles from the inside of a box.
  20703. * It emits the particles randomly between 2 given directions.
  20704. */
  20705. export class BoxParticleEmitter implements IParticleEmitterType {
  20706. /**
  20707. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20708. */
  20709. direction1: Vector3;
  20710. /**
  20711. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20712. */
  20713. direction2: Vector3;
  20714. /**
  20715. * 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.
  20716. */
  20717. minEmitBox: Vector3;
  20718. /**
  20719. * 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.
  20720. */
  20721. maxEmitBox: Vector3;
  20722. /**
  20723. * Creates a new instance BoxParticleEmitter
  20724. */
  20725. constructor();
  20726. /**
  20727. * Called by the particle System when the direction is computed for the created particle.
  20728. * @param worldMatrix is the world matrix of the particle system
  20729. * @param directionToUpdate is the direction vector to update with the result
  20730. * @param particle is the particle we are computed the direction for
  20731. */
  20732. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20733. /**
  20734. * Called by the particle System when the position is computed for the created particle.
  20735. * @param worldMatrix is the world matrix of the particle system
  20736. * @param positionToUpdate is the position vector to update with the result
  20737. * @param particle is the particle we are computed the position for
  20738. */
  20739. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20740. /**
  20741. * Clones the current emitter and returns a copy of it
  20742. * @returns the new emitter
  20743. */
  20744. clone(): BoxParticleEmitter;
  20745. /**
  20746. * Called by the GPUParticleSystem to setup the update shader
  20747. * @param effect defines the update shader
  20748. */
  20749. applyToShader(effect: Effect): void;
  20750. /**
  20751. * Returns a string to use to update the GPU particles update shader
  20752. * @returns a string containng the defines string
  20753. */
  20754. getEffectDefines(): string;
  20755. /**
  20756. * Returns the string "BoxParticleEmitter"
  20757. * @returns a string containing the class name
  20758. */
  20759. getClassName(): string;
  20760. /**
  20761. * Serializes the particle system to a JSON object.
  20762. * @returns the JSON object
  20763. */
  20764. serialize(): any;
  20765. /**
  20766. * Parse properties from a JSON object
  20767. * @param serializationObject defines the JSON object
  20768. */
  20769. parse(serializationObject: any): void;
  20770. }
  20771. }
  20772. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  20773. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20774. import { Effect } from "babylonjs/Materials/effect";
  20775. import { Particle } from "babylonjs/Particles/particle";
  20776. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20777. /**
  20778. * Particle emitter emitting particles from the inside of a cone.
  20779. * It emits the particles alongside the cone volume from the base to the particle.
  20780. * The emission direction might be randomized.
  20781. */
  20782. export class ConeParticleEmitter implements IParticleEmitterType {
  20783. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20784. directionRandomizer: number;
  20785. private _radius;
  20786. private _angle;
  20787. private _height;
  20788. /**
  20789. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  20790. */
  20791. radiusRange: number;
  20792. /**
  20793. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  20794. */
  20795. heightRange: number;
  20796. /**
  20797. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  20798. */
  20799. emitFromSpawnPointOnly: boolean;
  20800. /**
  20801. * Gets or sets the radius of the emission cone
  20802. */
  20803. radius: number;
  20804. /**
  20805. * Gets or sets the angle of the emission cone
  20806. */
  20807. angle: number;
  20808. private _buildHeight;
  20809. /**
  20810. * Creates a new instance ConeParticleEmitter
  20811. * @param radius the radius of the emission cone (1 by default)
  20812. * @param angle the cone base angle (PI by default)
  20813. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  20814. */
  20815. constructor(radius?: number, angle?: number,
  20816. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20817. directionRandomizer?: number);
  20818. /**
  20819. * Called by the particle System when the direction is computed for the created particle.
  20820. * @param worldMatrix is the world matrix of the particle system
  20821. * @param directionToUpdate is the direction vector to update with the result
  20822. * @param particle is the particle we are computed the direction for
  20823. */
  20824. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20825. /**
  20826. * Called by the particle System when the position is computed for the created particle.
  20827. * @param worldMatrix is the world matrix of the particle system
  20828. * @param positionToUpdate is the position vector to update with the result
  20829. * @param particle is the particle we are computed the position for
  20830. */
  20831. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20832. /**
  20833. * Clones the current emitter and returns a copy of it
  20834. * @returns the new emitter
  20835. */
  20836. clone(): ConeParticleEmitter;
  20837. /**
  20838. * Called by the GPUParticleSystem to setup the update shader
  20839. * @param effect defines the update shader
  20840. */
  20841. applyToShader(effect: Effect): void;
  20842. /**
  20843. * Returns a string to use to update the GPU particles update shader
  20844. * @returns a string containng the defines string
  20845. */
  20846. getEffectDefines(): string;
  20847. /**
  20848. * Returns the string "ConeParticleEmitter"
  20849. * @returns a string containing the class name
  20850. */
  20851. getClassName(): string;
  20852. /**
  20853. * Serializes the particle system to a JSON object.
  20854. * @returns the JSON object
  20855. */
  20856. serialize(): any;
  20857. /**
  20858. * Parse properties from a JSON object
  20859. * @param serializationObject defines the JSON object
  20860. */
  20861. parse(serializationObject: any): void;
  20862. }
  20863. }
  20864. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  20865. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20866. import { Effect } from "babylonjs/Materials/effect";
  20867. import { Particle } from "babylonjs/Particles/particle";
  20868. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20869. /**
  20870. * Particle emitter emitting particles from the inside of a cylinder.
  20871. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  20872. */
  20873. export class CylinderParticleEmitter implements IParticleEmitterType {
  20874. /**
  20875. * The radius of the emission cylinder.
  20876. */
  20877. radius: number;
  20878. /**
  20879. * The height of the emission cylinder.
  20880. */
  20881. height: number;
  20882. /**
  20883. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20884. */
  20885. radiusRange: number;
  20886. /**
  20887. * How much to randomize the particle direction [0-1].
  20888. */
  20889. directionRandomizer: number;
  20890. /**
  20891. * Creates a new instance CylinderParticleEmitter
  20892. * @param radius the radius of the emission cylinder (1 by default)
  20893. * @param height the height of the emission cylinder (1 by default)
  20894. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20895. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20896. */
  20897. constructor(
  20898. /**
  20899. * The radius of the emission cylinder.
  20900. */
  20901. radius?: number,
  20902. /**
  20903. * The height of the emission cylinder.
  20904. */
  20905. height?: number,
  20906. /**
  20907. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20908. */
  20909. radiusRange?: number,
  20910. /**
  20911. * How much to randomize the particle direction [0-1].
  20912. */
  20913. directionRandomizer?: number);
  20914. /**
  20915. * Called by the particle System when the direction is computed for the created particle.
  20916. * @param worldMatrix is the world matrix of the particle system
  20917. * @param directionToUpdate is the direction vector to update with the result
  20918. * @param particle is the particle we are computed the direction for
  20919. */
  20920. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20921. /**
  20922. * Called by the particle System when the position is computed for the created particle.
  20923. * @param worldMatrix is the world matrix of the particle system
  20924. * @param positionToUpdate is the position vector to update with the result
  20925. * @param particle is the particle we are computed the position for
  20926. */
  20927. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20928. /**
  20929. * Clones the current emitter and returns a copy of it
  20930. * @returns the new emitter
  20931. */
  20932. clone(): CylinderParticleEmitter;
  20933. /**
  20934. * Called by the GPUParticleSystem to setup the update shader
  20935. * @param effect defines the update shader
  20936. */
  20937. applyToShader(effect: Effect): void;
  20938. /**
  20939. * Returns a string to use to update the GPU particles update shader
  20940. * @returns a string containng the defines string
  20941. */
  20942. getEffectDefines(): string;
  20943. /**
  20944. * Returns the string "CylinderParticleEmitter"
  20945. * @returns a string containing the class name
  20946. */
  20947. getClassName(): string;
  20948. /**
  20949. * Serializes the particle system to a JSON object.
  20950. * @returns the JSON object
  20951. */
  20952. serialize(): any;
  20953. /**
  20954. * Parse properties from a JSON object
  20955. * @param serializationObject defines the JSON object
  20956. */
  20957. parse(serializationObject: any): void;
  20958. }
  20959. /**
  20960. * Particle emitter emitting particles from the inside of a cylinder.
  20961. * It emits the particles randomly between two vectors.
  20962. */
  20963. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  20964. /**
  20965. * The min limit of the emission direction.
  20966. */
  20967. direction1: Vector3;
  20968. /**
  20969. * The max limit of the emission direction.
  20970. */
  20971. direction2: Vector3;
  20972. /**
  20973. * Creates a new instance CylinderDirectedParticleEmitter
  20974. * @param radius the radius of the emission cylinder (1 by default)
  20975. * @param height the height of the emission cylinder (1 by default)
  20976. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20977. * @param direction1 the min limit of the emission direction (up vector by default)
  20978. * @param direction2 the max limit of the emission direction (up vector by default)
  20979. */
  20980. constructor(radius?: number, height?: number, radiusRange?: number,
  20981. /**
  20982. * The min limit of the emission direction.
  20983. */
  20984. direction1?: Vector3,
  20985. /**
  20986. * The max limit of the emission direction.
  20987. */
  20988. direction2?: Vector3);
  20989. /**
  20990. * Called by the particle System when the direction is computed for the created particle.
  20991. * @param worldMatrix is the world matrix of the particle system
  20992. * @param directionToUpdate is the direction vector to update with the result
  20993. * @param particle is the particle we are computed the direction for
  20994. */
  20995. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20996. /**
  20997. * Clones the current emitter and returns a copy of it
  20998. * @returns the new emitter
  20999. */
  21000. clone(): CylinderDirectedParticleEmitter;
  21001. /**
  21002. * Called by the GPUParticleSystem to setup the update shader
  21003. * @param effect defines the update shader
  21004. */
  21005. applyToShader(effect: Effect): void;
  21006. /**
  21007. * Returns a string to use to update the GPU particles update shader
  21008. * @returns a string containng the defines string
  21009. */
  21010. getEffectDefines(): string;
  21011. /**
  21012. * Returns the string "CylinderDirectedParticleEmitter"
  21013. * @returns a string containing the class name
  21014. */
  21015. getClassName(): string;
  21016. /**
  21017. * Serializes the particle system to a JSON object.
  21018. * @returns the JSON object
  21019. */
  21020. serialize(): any;
  21021. /**
  21022. * Parse properties from a JSON object
  21023. * @param serializationObject defines the JSON object
  21024. */
  21025. parse(serializationObject: any): void;
  21026. }
  21027. }
  21028. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  21029. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21030. import { Effect } from "babylonjs/Materials/effect";
  21031. import { Particle } from "babylonjs/Particles/particle";
  21032. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21033. /**
  21034. * Particle emitter emitting particles from the inside of a hemisphere.
  21035. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  21036. */
  21037. export class HemisphericParticleEmitter implements IParticleEmitterType {
  21038. /**
  21039. * The radius of the emission hemisphere.
  21040. */
  21041. radius: number;
  21042. /**
  21043. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21044. */
  21045. radiusRange: number;
  21046. /**
  21047. * How much to randomize the particle direction [0-1].
  21048. */
  21049. directionRandomizer: number;
  21050. /**
  21051. * Creates a new instance HemisphericParticleEmitter
  21052. * @param radius the radius of the emission hemisphere (1 by default)
  21053. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21054. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  21055. */
  21056. constructor(
  21057. /**
  21058. * The radius of the emission hemisphere.
  21059. */
  21060. radius?: number,
  21061. /**
  21062. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21063. */
  21064. radiusRange?: number,
  21065. /**
  21066. * How much to randomize the particle direction [0-1].
  21067. */
  21068. directionRandomizer?: number);
  21069. /**
  21070. * Called by the particle System when the direction is computed for the created particle.
  21071. * @param worldMatrix is the world matrix of the particle system
  21072. * @param directionToUpdate is the direction vector to update with the result
  21073. * @param particle is the particle we are computed the direction for
  21074. */
  21075. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21076. /**
  21077. * Called by the particle System when the position is computed for the created particle.
  21078. * @param worldMatrix is the world matrix of the particle system
  21079. * @param positionToUpdate is the position vector to update with the result
  21080. * @param particle is the particle we are computed the position for
  21081. */
  21082. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21083. /**
  21084. * Clones the current emitter and returns a copy of it
  21085. * @returns the new emitter
  21086. */
  21087. clone(): HemisphericParticleEmitter;
  21088. /**
  21089. * Called by the GPUParticleSystem to setup the update shader
  21090. * @param effect defines the update shader
  21091. */
  21092. applyToShader(effect: Effect): void;
  21093. /**
  21094. * Returns a string to use to update the GPU particles update shader
  21095. * @returns a string containng the defines string
  21096. */
  21097. getEffectDefines(): string;
  21098. /**
  21099. * Returns the string "HemisphericParticleEmitter"
  21100. * @returns a string containing the class name
  21101. */
  21102. getClassName(): string;
  21103. /**
  21104. * Serializes the particle system to a JSON object.
  21105. * @returns the JSON object
  21106. */
  21107. serialize(): any;
  21108. /**
  21109. * Parse properties from a JSON object
  21110. * @param serializationObject defines the JSON object
  21111. */
  21112. parse(serializationObject: any): void;
  21113. }
  21114. }
  21115. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  21116. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21117. import { Effect } from "babylonjs/Materials/effect";
  21118. import { Particle } from "babylonjs/Particles/particle";
  21119. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21120. /**
  21121. * Particle emitter emitting particles from a point.
  21122. * It emits the particles randomly between 2 given directions.
  21123. */
  21124. export class PointParticleEmitter implements IParticleEmitterType {
  21125. /**
  21126. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  21127. */
  21128. direction1: Vector3;
  21129. /**
  21130. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  21131. */
  21132. direction2: Vector3;
  21133. /**
  21134. * Creates a new instance PointParticleEmitter
  21135. */
  21136. constructor();
  21137. /**
  21138. * Called by the particle System when the direction is computed for the created particle.
  21139. * @param worldMatrix is the world matrix of the particle system
  21140. * @param directionToUpdate is the direction vector to update with the result
  21141. * @param particle is the particle we are computed the direction for
  21142. */
  21143. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21144. /**
  21145. * Called by the particle System when the position is computed for the created particle.
  21146. * @param worldMatrix is the world matrix of the particle system
  21147. * @param positionToUpdate is the position vector to update with the result
  21148. * @param particle is the particle we are computed the position for
  21149. */
  21150. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21151. /**
  21152. * Clones the current emitter and returns a copy of it
  21153. * @returns the new emitter
  21154. */
  21155. clone(): PointParticleEmitter;
  21156. /**
  21157. * Called by the GPUParticleSystem to setup the update shader
  21158. * @param effect defines the update shader
  21159. */
  21160. applyToShader(effect: Effect): void;
  21161. /**
  21162. * Returns a string to use to update the GPU particles update shader
  21163. * @returns a string containng the defines string
  21164. */
  21165. getEffectDefines(): string;
  21166. /**
  21167. * Returns the string "PointParticleEmitter"
  21168. * @returns a string containing the class name
  21169. */
  21170. getClassName(): string;
  21171. /**
  21172. * Serializes the particle system to a JSON object.
  21173. * @returns the JSON object
  21174. */
  21175. serialize(): any;
  21176. /**
  21177. * Parse properties from a JSON object
  21178. * @param serializationObject defines the JSON object
  21179. */
  21180. parse(serializationObject: any): void;
  21181. }
  21182. }
  21183. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  21184. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21185. import { Effect } from "babylonjs/Materials/effect";
  21186. import { Particle } from "babylonjs/Particles/particle";
  21187. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21188. /**
  21189. * Particle emitter emitting particles from the inside of a sphere.
  21190. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  21191. */
  21192. export class SphereParticleEmitter implements IParticleEmitterType {
  21193. /**
  21194. * The radius of the emission sphere.
  21195. */
  21196. radius: number;
  21197. /**
  21198. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21199. */
  21200. radiusRange: number;
  21201. /**
  21202. * How much to randomize the particle direction [0-1].
  21203. */
  21204. directionRandomizer: number;
  21205. /**
  21206. * Creates a new instance SphereParticleEmitter
  21207. * @param radius the radius of the emission sphere (1 by default)
  21208. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21209. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  21210. */
  21211. constructor(
  21212. /**
  21213. * The radius of the emission sphere.
  21214. */
  21215. radius?: number,
  21216. /**
  21217. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21218. */
  21219. radiusRange?: number,
  21220. /**
  21221. * How much to randomize the particle direction [0-1].
  21222. */
  21223. directionRandomizer?: number);
  21224. /**
  21225. * Called by the particle System when the direction is computed for the created particle.
  21226. * @param worldMatrix is the world matrix of the particle system
  21227. * @param directionToUpdate is the direction vector to update with the result
  21228. * @param particle is the particle we are computed the direction for
  21229. */
  21230. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21231. /**
  21232. * Called by the particle System when the position is computed for the created particle.
  21233. * @param worldMatrix is the world matrix of the particle system
  21234. * @param positionToUpdate is the position vector to update with the result
  21235. * @param particle is the particle we are computed the position for
  21236. */
  21237. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21238. /**
  21239. * Clones the current emitter and returns a copy of it
  21240. * @returns the new emitter
  21241. */
  21242. clone(): SphereParticleEmitter;
  21243. /**
  21244. * Called by the GPUParticleSystem to setup the update shader
  21245. * @param effect defines the update shader
  21246. */
  21247. applyToShader(effect: Effect): void;
  21248. /**
  21249. * Returns a string to use to update the GPU particles update shader
  21250. * @returns a string containng the defines string
  21251. */
  21252. getEffectDefines(): string;
  21253. /**
  21254. * Returns the string "SphereParticleEmitter"
  21255. * @returns a string containing the class name
  21256. */
  21257. getClassName(): string;
  21258. /**
  21259. * Serializes the particle system to a JSON object.
  21260. * @returns the JSON object
  21261. */
  21262. serialize(): any;
  21263. /**
  21264. * Parse properties from a JSON object
  21265. * @param serializationObject defines the JSON object
  21266. */
  21267. parse(serializationObject: any): void;
  21268. }
  21269. /**
  21270. * Particle emitter emitting particles from the inside of a sphere.
  21271. * It emits the particles randomly between two vectors.
  21272. */
  21273. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  21274. /**
  21275. * The min limit of the emission direction.
  21276. */
  21277. direction1: Vector3;
  21278. /**
  21279. * The max limit of the emission direction.
  21280. */
  21281. direction2: Vector3;
  21282. /**
  21283. * Creates a new instance SphereDirectedParticleEmitter
  21284. * @param radius the radius of the emission sphere (1 by default)
  21285. * @param direction1 the min limit of the emission direction (up vector by default)
  21286. * @param direction2 the max limit of the emission direction (up vector by default)
  21287. */
  21288. constructor(radius?: number,
  21289. /**
  21290. * The min limit of the emission direction.
  21291. */
  21292. direction1?: Vector3,
  21293. /**
  21294. * The max limit of the emission direction.
  21295. */
  21296. direction2?: Vector3);
  21297. /**
  21298. * Called by the particle System when the direction is computed for the created particle.
  21299. * @param worldMatrix is the world matrix of the particle system
  21300. * @param directionToUpdate is the direction vector to update with the result
  21301. * @param particle is the particle we are computed the direction for
  21302. */
  21303. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21304. /**
  21305. * Clones the current emitter and returns a copy of it
  21306. * @returns the new emitter
  21307. */
  21308. clone(): SphereDirectedParticleEmitter;
  21309. /**
  21310. * Called by the GPUParticleSystem to setup the update shader
  21311. * @param effect defines the update shader
  21312. */
  21313. applyToShader(effect: Effect): void;
  21314. /**
  21315. * Returns a string to use to update the GPU particles update shader
  21316. * @returns a string containng the defines string
  21317. */
  21318. getEffectDefines(): string;
  21319. /**
  21320. * Returns the string "SphereDirectedParticleEmitter"
  21321. * @returns a string containing the class name
  21322. */
  21323. getClassName(): string;
  21324. /**
  21325. * Serializes the particle system to a JSON object.
  21326. * @returns the JSON object
  21327. */
  21328. serialize(): any;
  21329. /**
  21330. * Parse properties from a JSON object
  21331. * @param serializationObject defines the JSON object
  21332. */
  21333. parse(serializationObject: any): void;
  21334. }
  21335. }
  21336. declare module "babylonjs/Particles/EmitterTypes/index" {
  21337. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  21338. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  21339. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  21340. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  21341. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21342. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  21343. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  21344. }
  21345. declare module "babylonjs/Particles/IParticleSystem" {
  21346. import { Nullable } from "babylonjs/types";
  21347. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  21348. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21349. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21350. import { Texture } from "babylonjs/Materials/Textures/texture";
  21351. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  21352. import { Scene } from "babylonjs/scene";
  21353. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  21354. import { Animation } from "babylonjs/Animations/animation";
  21355. /**
  21356. * Interface representing a particle system in Babylon.js.
  21357. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  21358. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  21359. */
  21360. export interface IParticleSystem {
  21361. /**
  21362. * List of animations used by the particle system.
  21363. */
  21364. animations: Animation[];
  21365. /**
  21366. * The id of the Particle system.
  21367. */
  21368. id: string;
  21369. /**
  21370. * The name of the Particle system.
  21371. */
  21372. name: string;
  21373. /**
  21374. * The emitter represents the Mesh or position we are attaching the particle system to.
  21375. */
  21376. emitter: Nullable<AbstractMesh | Vector3>;
  21377. /**
  21378. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  21379. */
  21380. isBillboardBased: boolean;
  21381. /**
  21382. * The rendering group used by the Particle system to chose when to render.
  21383. */
  21384. renderingGroupId: number;
  21385. /**
  21386. * The layer mask we are rendering the particles through.
  21387. */
  21388. layerMask: number;
  21389. /**
  21390. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  21391. */
  21392. updateSpeed: number;
  21393. /**
  21394. * The amount of time the particle system is running (depends of the overall update speed).
  21395. */
  21396. targetStopDuration: number;
  21397. /**
  21398. * The texture used to render each particle. (this can be a spritesheet)
  21399. */
  21400. particleTexture: Nullable<Texture>;
  21401. /**
  21402. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  21403. */
  21404. blendMode: number;
  21405. /**
  21406. * Minimum life time of emitting particles.
  21407. */
  21408. minLifeTime: number;
  21409. /**
  21410. * Maximum life time of emitting particles.
  21411. */
  21412. maxLifeTime: number;
  21413. /**
  21414. * Minimum Size of emitting particles.
  21415. */
  21416. minSize: number;
  21417. /**
  21418. * Maximum Size of emitting particles.
  21419. */
  21420. maxSize: number;
  21421. /**
  21422. * Minimum scale of emitting particles on X axis.
  21423. */
  21424. minScaleX: number;
  21425. /**
  21426. * Maximum scale of emitting particles on X axis.
  21427. */
  21428. maxScaleX: number;
  21429. /**
  21430. * Minimum scale of emitting particles on Y axis.
  21431. */
  21432. minScaleY: number;
  21433. /**
  21434. * Maximum scale of emitting particles on Y axis.
  21435. */
  21436. maxScaleY: number;
  21437. /**
  21438. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  21439. */
  21440. color1: Color4;
  21441. /**
  21442. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  21443. */
  21444. color2: Color4;
  21445. /**
  21446. * Color the particle will have at the end of its lifetime.
  21447. */
  21448. colorDead: Color4;
  21449. /**
  21450. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  21451. */
  21452. emitRate: number;
  21453. /**
  21454. * You can use gravity if you want to give an orientation to your particles.
  21455. */
  21456. gravity: Vector3;
  21457. /**
  21458. * Minimum power of emitting particles.
  21459. */
  21460. minEmitPower: number;
  21461. /**
  21462. * Maximum power of emitting particles.
  21463. */
  21464. maxEmitPower: number;
  21465. /**
  21466. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  21467. */
  21468. minAngularSpeed: number;
  21469. /**
  21470. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  21471. */
  21472. maxAngularSpeed: number;
  21473. /**
  21474. * Gets or sets the minimal initial rotation in radians.
  21475. */
  21476. minInitialRotation: number;
  21477. /**
  21478. * Gets or sets the maximal initial rotation in radians.
  21479. */
  21480. maxInitialRotation: number;
  21481. /**
  21482. * The particle emitter type defines the emitter used by the particle system.
  21483. * It can be for example box, sphere, or cone...
  21484. */
  21485. particleEmitterType: Nullable<IParticleEmitterType>;
  21486. /**
  21487. * Defines the delay in milliseconds before starting the system (0 by default)
  21488. */
  21489. startDelay: number;
  21490. /**
  21491. * 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
  21492. */
  21493. preWarmCycles: number;
  21494. /**
  21495. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  21496. */
  21497. preWarmStepOffset: number;
  21498. /**
  21499. * 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)
  21500. */
  21501. spriteCellChangeSpeed: number;
  21502. /**
  21503. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  21504. */
  21505. startSpriteCellID: number;
  21506. /**
  21507. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  21508. */
  21509. endSpriteCellID: number;
  21510. /**
  21511. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  21512. */
  21513. spriteCellWidth: number;
  21514. /**
  21515. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  21516. */
  21517. spriteCellHeight: number;
  21518. /**
  21519. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  21520. */
  21521. spriteRandomStartCell: boolean;
  21522. /**
  21523. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  21524. */
  21525. isAnimationSheetEnabled: boolean;
  21526. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  21527. translationPivot: Vector2;
  21528. /**
  21529. * Gets or sets a texture used to add random noise to particle positions
  21530. */
  21531. noiseTexture: Nullable<BaseTexture>;
  21532. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  21533. noiseStrength: Vector3;
  21534. /**
  21535. * Gets or sets the billboard mode to use when isBillboardBased = true.
  21536. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  21537. */
  21538. billboardMode: number;
  21539. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  21540. limitVelocityDamping: number;
  21541. /**
  21542. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  21543. */
  21544. beginAnimationOnStart: boolean;
  21545. /**
  21546. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  21547. */
  21548. beginAnimationFrom: number;
  21549. /**
  21550. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  21551. */
  21552. beginAnimationTo: number;
  21553. /**
  21554. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  21555. */
  21556. beginAnimationLoop: boolean;
  21557. /**
  21558. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  21559. */
  21560. disposeOnStop: boolean;
  21561. /**
  21562. * Gets the maximum number of particles active at the same time.
  21563. * @returns The max number of active particles.
  21564. */
  21565. getCapacity(): number;
  21566. /**
  21567. * Gets if the system has been started. (Note: this will still be true after stop is called)
  21568. * @returns True if it has been started, otherwise false.
  21569. */
  21570. isStarted(): boolean;
  21571. /**
  21572. * Animates the particle system for this frame.
  21573. */
  21574. animate(): void;
  21575. /**
  21576. * Renders the particle system in its current state.
  21577. * @returns the current number of particles
  21578. */
  21579. render(): number;
  21580. /**
  21581. * Dispose the particle system and frees its associated resources.
  21582. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  21583. */
  21584. dispose(disposeTexture?: boolean): void;
  21585. /**
  21586. * Clones the particle system.
  21587. * @param name The name of the cloned object
  21588. * @param newEmitter The new emitter to use
  21589. * @returns the cloned particle system
  21590. */
  21591. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  21592. /**
  21593. * Serializes the particle system to a JSON object.
  21594. * @returns the JSON object
  21595. */
  21596. serialize(): any;
  21597. /**
  21598. * Rebuild the particle system
  21599. */
  21600. rebuild(): void;
  21601. /**
  21602. * Starts the particle system and begins to emit
  21603. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  21604. */
  21605. start(delay?: number): void;
  21606. /**
  21607. * Stops the particle system.
  21608. */
  21609. stop(): void;
  21610. /**
  21611. * Remove all active particles
  21612. */
  21613. reset(): void;
  21614. /**
  21615. * Is this system ready to be used/rendered
  21616. * @return true if the system is ready
  21617. */
  21618. isReady(): boolean;
  21619. /**
  21620. * Adds a new color gradient
  21621. * @param gradient defines the gradient to use (between 0 and 1)
  21622. * @param color1 defines the color to affect to the specified gradient
  21623. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  21624. * @returns the current particle system
  21625. */
  21626. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  21627. /**
  21628. * Remove a specific color gradient
  21629. * @param gradient defines the gradient to remove
  21630. * @returns the current particle system
  21631. */
  21632. removeColorGradient(gradient: number): IParticleSystem;
  21633. /**
  21634. * Adds a new size gradient
  21635. * @param gradient defines the gradient to use (between 0 and 1)
  21636. * @param factor defines the size factor to affect to the specified gradient
  21637. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21638. * @returns the current particle system
  21639. */
  21640. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21641. /**
  21642. * Remove a specific size gradient
  21643. * @param gradient defines the gradient to remove
  21644. * @returns the current particle system
  21645. */
  21646. removeSizeGradient(gradient: number): IParticleSystem;
  21647. /**
  21648. * Gets the current list of color gradients.
  21649. * You must use addColorGradient and removeColorGradient to udpate this list
  21650. * @returns the list of color gradients
  21651. */
  21652. getColorGradients(): Nullable<Array<ColorGradient>>;
  21653. /**
  21654. * Gets the current list of size gradients.
  21655. * You must use addSizeGradient and removeSizeGradient to udpate this list
  21656. * @returns the list of size gradients
  21657. */
  21658. getSizeGradients(): Nullable<Array<FactorGradient>>;
  21659. /**
  21660. * Gets the current list of angular speed gradients.
  21661. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  21662. * @returns the list of angular speed gradients
  21663. */
  21664. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  21665. /**
  21666. * Adds a new angular speed gradient
  21667. * @param gradient defines the gradient to use (between 0 and 1)
  21668. * @param factor defines the angular speed to affect to the specified gradient
  21669. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21670. * @returns the current particle system
  21671. */
  21672. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21673. /**
  21674. * Remove a specific angular speed gradient
  21675. * @param gradient defines the gradient to remove
  21676. * @returns the current particle system
  21677. */
  21678. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  21679. /**
  21680. * Gets the current list of velocity gradients.
  21681. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  21682. * @returns the list of velocity gradients
  21683. */
  21684. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  21685. /**
  21686. * Adds a new velocity gradient
  21687. * @param gradient defines the gradient to use (between 0 and 1)
  21688. * @param factor defines the velocity to affect to the specified gradient
  21689. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21690. * @returns the current particle system
  21691. */
  21692. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21693. /**
  21694. * Remove a specific velocity gradient
  21695. * @param gradient defines the gradient to remove
  21696. * @returns the current particle system
  21697. */
  21698. removeVelocityGradient(gradient: number): IParticleSystem;
  21699. /**
  21700. * Gets the current list of limit velocity gradients.
  21701. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  21702. * @returns the list of limit velocity gradients
  21703. */
  21704. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  21705. /**
  21706. * Adds a new limit velocity gradient
  21707. * @param gradient defines the gradient to use (between 0 and 1)
  21708. * @param factor defines the limit velocity to affect to the specified gradient
  21709. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21710. * @returns the current particle system
  21711. */
  21712. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21713. /**
  21714. * Remove a specific limit velocity gradient
  21715. * @param gradient defines the gradient to remove
  21716. * @returns the current particle system
  21717. */
  21718. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  21719. /**
  21720. * Adds a new drag gradient
  21721. * @param gradient defines the gradient to use (between 0 and 1)
  21722. * @param factor defines the drag to affect to the specified gradient
  21723. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21724. * @returns the current particle system
  21725. */
  21726. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21727. /**
  21728. * Remove a specific drag gradient
  21729. * @param gradient defines the gradient to remove
  21730. * @returns the current particle system
  21731. */
  21732. removeDragGradient(gradient: number): IParticleSystem;
  21733. /**
  21734. * Gets the current list of drag gradients.
  21735. * You must use addDragGradient and removeDragGradient to udpate this list
  21736. * @returns the list of drag gradients
  21737. */
  21738. getDragGradients(): Nullable<Array<FactorGradient>>;
  21739. /**
  21740. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  21741. * @param gradient defines the gradient to use (between 0 and 1)
  21742. * @param factor defines the emit rate to affect to the specified gradient
  21743. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21744. * @returns the current particle system
  21745. */
  21746. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21747. /**
  21748. * Remove a specific emit rate gradient
  21749. * @param gradient defines the gradient to remove
  21750. * @returns the current particle system
  21751. */
  21752. removeEmitRateGradient(gradient: number): IParticleSystem;
  21753. /**
  21754. * Gets the current list of emit rate gradients.
  21755. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  21756. * @returns the list of emit rate gradients
  21757. */
  21758. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  21759. /**
  21760. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  21761. * @param gradient defines the gradient to use (between 0 and 1)
  21762. * @param factor defines the start size to affect to the specified gradient
  21763. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21764. * @returns the current particle system
  21765. */
  21766. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21767. /**
  21768. * Remove a specific start size gradient
  21769. * @param gradient defines the gradient to remove
  21770. * @returns the current particle system
  21771. */
  21772. removeStartSizeGradient(gradient: number): IParticleSystem;
  21773. /**
  21774. * Gets the current list of start size gradients.
  21775. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  21776. * @returns the list of start size gradients
  21777. */
  21778. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  21779. /**
  21780. * Adds a new life time gradient
  21781. * @param gradient defines the gradient to use (between 0 and 1)
  21782. * @param factor defines the life time factor to affect to the specified gradient
  21783. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21784. * @returns the current particle system
  21785. */
  21786. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21787. /**
  21788. * Remove a specific life time gradient
  21789. * @param gradient defines the gradient to remove
  21790. * @returns the current particle system
  21791. */
  21792. removeLifeTimeGradient(gradient: number): IParticleSystem;
  21793. /**
  21794. * Gets the current list of life time gradients.
  21795. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  21796. * @returns the list of life time gradients
  21797. */
  21798. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  21799. /**
  21800. * Gets the current list of color gradients.
  21801. * You must use addColorGradient and removeColorGradient to udpate this list
  21802. * @returns the list of color gradients
  21803. */
  21804. getColorGradients(): Nullable<Array<ColorGradient>>;
  21805. /**
  21806. * Adds a new ramp gradient used to remap particle colors
  21807. * @param gradient defines the gradient to use (between 0 and 1)
  21808. * @param color defines the color to affect to the specified gradient
  21809. * @returns the current particle system
  21810. */
  21811. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  21812. /**
  21813. * Gets the current list of ramp gradients.
  21814. * You must use addRampGradient and removeRampGradient to udpate this list
  21815. * @returns the list of ramp gradients
  21816. */
  21817. getRampGradients(): Nullable<Array<Color3Gradient>>;
  21818. /** Gets or sets a boolean indicating that ramp gradients must be used
  21819. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  21820. */
  21821. useRampGradients: boolean;
  21822. /**
  21823. * Adds a new color remap gradient
  21824. * @param gradient defines the gradient to use (between 0 and 1)
  21825. * @param min defines the color remap minimal range
  21826. * @param max defines the color remap maximal range
  21827. * @returns the current particle system
  21828. */
  21829. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21830. /**
  21831. * Gets the current list of color remap gradients.
  21832. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  21833. * @returns the list of color remap gradients
  21834. */
  21835. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  21836. /**
  21837. * Adds a new alpha remap gradient
  21838. * @param gradient defines the gradient to use (between 0 and 1)
  21839. * @param min defines the alpha remap minimal range
  21840. * @param max defines the alpha remap maximal range
  21841. * @returns the current particle system
  21842. */
  21843. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21844. /**
  21845. * Gets the current list of alpha remap gradients.
  21846. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  21847. * @returns the list of alpha remap gradients
  21848. */
  21849. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  21850. /**
  21851. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  21852. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21853. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21854. * @returns the emitter
  21855. */
  21856. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  21857. /**
  21858. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  21859. * @param radius The radius of the hemisphere to emit from
  21860. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21861. * @returns the emitter
  21862. */
  21863. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  21864. /**
  21865. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  21866. * @param radius The radius of the sphere to emit from
  21867. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21868. * @returns the emitter
  21869. */
  21870. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  21871. /**
  21872. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  21873. * @param radius The radius of the sphere to emit from
  21874. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  21875. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  21876. * @returns the emitter
  21877. */
  21878. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21879. /**
  21880. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  21881. * @param radius The radius of the emission cylinder
  21882. * @param height The height of the emission cylinder
  21883. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  21884. * @param directionRandomizer How much to randomize the particle direction [0-1]
  21885. * @returns the emitter
  21886. */
  21887. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  21888. /**
  21889. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  21890. * @param radius The radius of the cylinder to emit from
  21891. * @param height The height of the emission cylinder
  21892. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21893. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  21894. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  21895. * @returns the emitter
  21896. */
  21897. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21898. /**
  21899. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  21900. * @param radius The radius of the cone to emit from
  21901. * @param angle The base angle of the cone
  21902. * @returns the emitter
  21903. */
  21904. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  21905. /**
  21906. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  21907. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21908. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21909. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21910. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21911. * @returns the emitter
  21912. */
  21913. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  21914. /**
  21915. * Get hosting scene
  21916. * @returns the scene
  21917. */
  21918. getScene(): Scene;
  21919. }
  21920. }
  21921. declare module "babylonjs/Shaders/line.fragment" {
  21922. /** @hidden */
  21923. export var linePixelShader: {
  21924. name: string;
  21925. shader: string;
  21926. };
  21927. }
  21928. declare module "babylonjs/Shaders/line.vertex" {
  21929. /** @hidden */
  21930. export var lineVertexShader: {
  21931. name: string;
  21932. shader: string;
  21933. };
  21934. }
  21935. declare module "babylonjs/Rendering/edgesRenderer" {
  21936. import { Nullable } from "babylonjs/types";
  21937. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21938. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21939. import { Vector3 } from "babylonjs/Maths/math";
  21940. import { IDisposable } from "babylonjs/scene";
  21941. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  21942. import "babylonjs/Shaders/line.fragment";
  21943. import "babylonjs/Shaders/line.vertex";
  21944. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21945. module "babylonjs/Meshes/abstractMesh" {
  21946. interface AbstractMesh {
  21947. /**
  21948. * Gets the edgesRenderer associated with the mesh
  21949. */
  21950. edgesRenderer: Nullable<EdgesRenderer>;
  21951. }
  21952. }
  21953. module "babylonjs/Meshes/linesMesh" {
  21954. interface LinesMesh {
  21955. /**
  21956. * Enables the edge rendering mode on the mesh.
  21957. * This mode makes the mesh edges visible
  21958. * @param epsilon defines the maximal distance between two angles to detect a face
  21959. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21960. * @returns the currentAbstractMesh
  21961. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21962. */
  21963. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  21964. }
  21965. }
  21966. module "babylonjs/Meshes/linesMesh" {
  21967. interface InstancedLinesMesh {
  21968. /**
  21969. * Enables the edge rendering mode on the mesh.
  21970. * This mode makes the mesh edges visible
  21971. * @param epsilon defines the maximal distance between two angles to detect a face
  21972. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21973. * @returns the current InstancedLinesMesh
  21974. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21975. */
  21976. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  21977. }
  21978. }
  21979. /**
  21980. * Defines the minimum contract an Edges renderer should follow.
  21981. */
  21982. export interface IEdgesRenderer extends IDisposable {
  21983. /**
  21984. * Gets or sets a boolean indicating if the edgesRenderer is active
  21985. */
  21986. isEnabled: boolean;
  21987. /**
  21988. * Renders the edges of the attached mesh,
  21989. */
  21990. render(): void;
  21991. /**
  21992. * Checks wether or not the edges renderer is ready to render.
  21993. * @return true if ready, otherwise false.
  21994. */
  21995. isReady(): boolean;
  21996. }
  21997. /**
  21998. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  21999. */
  22000. export class EdgesRenderer implements IEdgesRenderer {
  22001. /**
  22002. * Define the size of the edges with an orthographic camera
  22003. */
  22004. edgesWidthScalerForOrthographic: number;
  22005. /**
  22006. * Define the size of the edges with a perspective camera
  22007. */
  22008. edgesWidthScalerForPerspective: number;
  22009. protected _source: AbstractMesh;
  22010. protected _linesPositions: number[];
  22011. protected _linesNormals: number[];
  22012. protected _linesIndices: number[];
  22013. protected _epsilon: number;
  22014. protected _indicesCount: number;
  22015. protected _lineShader: ShaderMaterial;
  22016. protected _ib: DataBuffer;
  22017. protected _buffers: {
  22018. [key: string]: Nullable<VertexBuffer>;
  22019. };
  22020. protected _checkVerticesInsteadOfIndices: boolean;
  22021. private _meshRebuildObserver;
  22022. private _meshDisposeObserver;
  22023. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  22024. isEnabled: boolean;
  22025. /**
  22026. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  22027. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  22028. * @param source Mesh used to create edges
  22029. * @param epsilon sum of angles in adjacency to check for edge
  22030. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  22031. * @param generateEdgesLines - should generate Lines or only prepare resources.
  22032. */
  22033. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  22034. protected _prepareRessources(): void;
  22035. /** @hidden */
  22036. _rebuild(): void;
  22037. /**
  22038. * Releases the required resources for the edges renderer
  22039. */
  22040. dispose(): void;
  22041. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  22042. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  22043. /**
  22044. * Checks if the pair of p0 and p1 is en edge
  22045. * @param faceIndex
  22046. * @param edge
  22047. * @param faceNormals
  22048. * @param p0
  22049. * @param p1
  22050. * @private
  22051. */
  22052. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  22053. /**
  22054. * push line into the position, normal and index buffer
  22055. * @protected
  22056. */
  22057. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  22058. /**
  22059. * Generates lines edges from adjacencjes
  22060. * @private
  22061. */
  22062. _generateEdgesLines(): void;
  22063. /**
  22064. * Checks wether or not the edges renderer is ready to render.
  22065. * @return true if ready, otherwise false.
  22066. */
  22067. isReady(): boolean;
  22068. /**
  22069. * Renders the edges of the attached mesh,
  22070. */
  22071. render(): void;
  22072. }
  22073. /**
  22074. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  22075. */
  22076. export class LineEdgesRenderer extends EdgesRenderer {
  22077. /**
  22078. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  22079. * @param source LineMesh used to generate edges
  22080. * @param epsilon not important (specified angle for edge detection)
  22081. * @param checkVerticesInsteadOfIndices not important for LineMesh
  22082. */
  22083. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  22084. /**
  22085. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  22086. */
  22087. _generateEdgesLines(): void;
  22088. }
  22089. }
  22090. declare module "babylonjs/Rendering/renderingGroup" {
  22091. import { SmartArray } from "babylonjs/Misc/smartArray";
  22092. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22094. import { Nullable } from "babylonjs/types";
  22095. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22096. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  22097. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  22098. import { Material } from "babylonjs/Materials/material";
  22099. import { Scene } from "babylonjs/scene";
  22100. /**
  22101. * This represents the object necessary to create a rendering group.
  22102. * This is exclusively used and created by the rendering manager.
  22103. * To modify the behavior, you use the available helpers in your scene or meshes.
  22104. * @hidden
  22105. */
  22106. export class RenderingGroup {
  22107. index: number;
  22108. private static _zeroVector;
  22109. private _scene;
  22110. private _opaqueSubMeshes;
  22111. private _transparentSubMeshes;
  22112. private _alphaTestSubMeshes;
  22113. private _depthOnlySubMeshes;
  22114. private _particleSystems;
  22115. private _spriteManagers;
  22116. private _opaqueSortCompareFn;
  22117. private _alphaTestSortCompareFn;
  22118. private _transparentSortCompareFn;
  22119. private _renderOpaque;
  22120. private _renderAlphaTest;
  22121. private _renderTransparent;
  22122. /** @hidden */
  22123. _edgesRenderers: SmartArray<IEdgesRenderer>;
  22124. onBeforeTransparentRendering: () => void;
  22125. /**
  22126. * Set the opaque sort comparison function.
  22127. * If null the sub meshes will be render in the order they were created
  22128. */
  22129. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22130. /**
  22131. * Set the alpha test sort comparison function.
  22132. * If null the sub meshes will be render in the order they were created
  22133. */
  22134. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22135. /**
  22136. * Set the transparent sort comparison function.
  22137. * If null the sub meshes will be render in the order they were created
  22138. */
  22139. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22140. /**
  22141. * Creates a new rendering group.
  22142. * @param index The rendering group index
  22143. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  22144. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  22145. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  22146. */
  22147. 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>);
  22148. /**
  22149. * Render all the sub meshes contained in the group.
  22150. * @param customRenderFunction Used to override the default render behaviour of the group.
  22151. * @returns true if rendered some submeshes.
  22152. */
  22153. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  22154. /**
  22155. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  22156. * @param subMeshes The submeshes to render
  22157. */
  22158. private renderOpaqueSorted;
  22159. /**
  22160. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  22161. * @param subMeshes The submeshes to render
  22162. */
  22163. private renderAlphaTestSorted;
  22164. /**
  22165. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  22166. * @param subMeshes The submeshes to render
  22167. */
  22168. private renderTransparentSorted;
  22169. /**
  22170. * Renders the submeshes in a specified order.
  22171. * @param subMeshes The submeshes to sort before render
  22172. * @param sortCompareFn The comparison function use to sort
  22173. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  22174. * @param transparent Specifies to activate blending if true
  22175. */
  22176. private static renderSorted;
  22177. /**
  22178. * Renders the submeshes in the order they were dispatched (no sort applied).
  22179. * @param subMeshes The submeshes to render
  22180. */
  22181. private static renderUnsorted;
  22182. /**
  22183. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22184. * are rendered back to front if in the same alpha index.
  22185. *
  22186. * @param a The first submesh
  22187. * @param b The second submesh
  22188. * @returns The result of the comparison
  22189. */
  22190. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  22191. /**
  22192. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22193. * are rendered back to front.
  22194. *
  22195. * @param a The first submesh
  22196. * @param b The second submesh
  22197. * @returns The result of the comparison
  22198. */
  22199. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  22200. /**
  22201. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22202. * are rendered front to back (prevent overdraw).
  22203. *
  22204. * @param a The first submesh
  22205. * @param b The second submesh
  22206. * @returns The result of the comparison
  22207. */
  22208. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  22209. /**
  22210. * Resets the different lists of submeshes to prepare a new frame.
  22211. */
  22212. prepare(): void;
  22213. dispose(): void;
  22214. /**
  22215. * Inserts the submesh in its correct queue depending on its material.
  22216. * @param subMesh The submesh to dispatch
  22217. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  22218. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  22219. */
  22220. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  22221. dispatchSprites(spriteManager: ISpriteManager): void;
  22222. dispatchParticles(particleSystem: IParticleSystem): void;
  22223. private _renderParticles;
  22224. private _renderSprites;
  22225. }
  22226. }
  22227. declare module "babylonjs/Rendering/renderingManager" {
  22228. import { Nullable } from "babylonjs/types";
  22229. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22230. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22231. import { SmartArray } from "babylonjs/Misc/smartArray";
  22232. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  22233. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22234. import { Material } from "babylonjs/Materials/material";
  22235. import { Scene } from "babylonjs/scene";
  22236. import { Camera } from "babylonjs/Cameras/camera";
  22237. /**
  22238. * Interface describing the different options available in the rendering manager
  22239. * regarding Auto Clear between groups.
  22240. */
  22241. export interface IRenderingManagerAutoClearSetup {
  22242. /**
  22243. * Defines whether or not autoclear is enable.
  22244. */
  22245. autoClear: boolean;
  22246. /**
  22247. * Defines whether or not to autoclear the depth buffer.
  22248. */
  22249. depth: boolean;
  22250. /**
  22251. * Defines whether or not to autoclear the stencil buffer.
  22252. */
  22253. stencil: boolean;
  22254. }
  22255. /**
  22256. * This class is used by the onRenderingGroupObservable
  22257. */
  22258. export class RenderingGroupInfo {
  22259. /**
  22260. * The Scene that being rendered
  22261. */
  22262. scene: Scene;
  22263. /**
  22264. * The camera currently used for the rendering pass
  22265. */
  22266. camera: Nullable<Camera>;
  22267. /**
  22268. * The ID of the renderingGroup being processed
  22269. */
  22270. renderingGroupId: number;
  22271. }
  22272. /**
  22273. * This is the manager responsible of all the rendering for meshes sprites and particles.
  22274. * It is enable to manage the different groups as well as the different necessary sort functions.
  22275. * This should not be used directly aside of the few static configurations
  22276. */
  22277. export class RenderingManager {
  22278. /**
  22279. * The max id used for rendering groups (not included)
  22280. */
  22281. static MAX_RENDERINGGROUPS: number;
  22282. /**
  22283. * The min id used for rendering groups (included)
  22284. */
  22285. static MIN_RENDERINGGROUPS: number;
  22286. /**
  22287. * Used to globally prevent autoclearing scenes.
  22288. */
  22289. static AUTOCLEAR: boolean;
  22290. /**
  22291. * @hidden
  22292. */
  22293. _useSceneAutoClearSetup: boolean;
  22294. private _scene;
  22295. private _renderingGroups;
  22296. private _depthStencilBufferAlreadyCleaned;
  22297. private _autoClearDepthStencil;
  22298. private _customOpaqueSortCompareFn;
  22299. private _customAlphaTestSortCompareFn;
  22300. private _customTransparentSortCompareFn;
  22301. private _renderingGroupInfo;
  22302. /**
  22303. * Instantiates a new rendering group for a particular scene
  22304. * @param scene Defines the scene the groups belongs to
  22305. */
  22306. constructor(scene: Scene);
  22307. private _clearDepthStencilBuffer;
  22308. /**
  22309. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  22310. * @hidden
  22311. */
  22312. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  22313. /**
  22314. * Resets the different information of the group to prepare a new frame
  22315. * @hidden
  22316. */
  22317. reset(): void;
  22318. /**
  22319. * Dispose and release the group and its associated resources.
  22320. * @hidden
  22321. */
  22322. dispose(): void;
  22323. /**
  22324. * Clear the info related to rendering groups preventing retention points during dispose.
  22325. */
  22326. freeRenderingGroups(): void;
  22327. private _prepareRenderingGroup;
  22328. /**
  22329. * Add a sprite manager to the rendering manager in order to render it this frame.
  22330. * @param spriteManager Define the sprite manager to render
  22331. */
  22332. dispatchSprites(spriteManager: ISpriteManager): void;
  22333. /**
  22334. * Add a particle system to the rendering manager in order to render it this frame.
  22335. * @param particleSystem Define the particle system to render
  22336. */
  22337. dispatchParticles(particleSystem: IParticleSystem): void;
  22338. /**
  22339. * Add a submesh to the manager in order to render it this frame
  22340. * @param subMesh The submesh to dispatch
  22341. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  22342. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  22343. */
  22344. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  22345. /**
  22346. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  22347. * This allowed control for front to back rendering or reversly depending of the special needs.
  22348. *
  22349. * @param renderingGroupId The rendering group id corresponding to its index
  22350. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  22351. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  22352. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  22353. */
  22354. 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;
  22355. /**
  22356. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  22357. *
  22358. * @param renderingGroupId The rendering group id corresponding to its index
  22359. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  22360. * @param depth Automatically clears depth between groups if true and autoClear is true.
  22361. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  22362. */
  22363. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  22364. /**
  22365. * Gets the current auto clear configuration for one rendering group of the rendering
  22366. * manager.
  22367. * @param index the rendering group index to get the information for
  22368. * @returns The auto clear setup for the requested rendering group
  22369. */
  22370. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  22371. }
  22372. }
  22373. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  22374. import { Observable } from "babylonjs/Misc/observable";
  22375. import { SmartArray } from "babylonjs/Misc/smartArray";
  22376. import { Nullable } from "babylonjs/types";
  22377. import { Camera } from "babylonjs/Cameras/camera";
  22378. import { Scene } from "babylonjs/scene";
  22379. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  22380. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  22381. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22382. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22383. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  22384. import { Texture } from "babylonjs/Materials/Textures/texture";
  22385. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  22386. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  22387. import "babylonjs/Engines/Extensions/engine.renderTarget";
  22388. import { Engine } from "babylonjs/Engines/engine";
  22389. /**
  22390. * This Helps creating a texture that will be created from a camera in your scene.
  22391. * It is basically a dynamic texture that could be used to create special effects for instance.
  22392. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  22393. */
  22394. export class RenderTargetTexture extends Texture {
  22395. isCube: boolean;
  22396. /**
  22397. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  22398. */
  22399. static readonly REFRESHRATE_RENDER_ONCE: number;
  22400. /**
  22401. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  22402. */
  22403. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  22404. /**
  22405. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  22406. * the central point of your effect and can save a lot of performances.
  22407. */
  22408. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  22409. /**
  22410. * Use this predicate to dynamically define the list of mesh you want to render.
  22411. * If set, the renderList property will be overwritten.
  22412. */
  22413. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  22414. private _renderList;
  22415. /**
  22416. * Use this list to define the list of mesh you want to render.
  22417. */
  22418. renderList: Nullable<Array<AbstractMesh>>;
  22419. private _hookArray;
  22420. /**
  22421. * Define if particles should be rendered in your texture.
  22422. */
  22423. renderParticles: boolean;
  22424. /**
  22425. * Define if sprites should be rendered in your texture.
  22426. */
  22427. renderSprites: boolean;
  22428. /**
  22429. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  22430. */
  22431. coordinatesMode: number;
  22432. /**
  22433. * Define the camera used to render the texture.
  22434. */
  22435. activeCamera: Nullable<Camera>;
  22436. /**
  22437. * Override the render function of the texture with your own one.
  22438. */
  22439. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  22440. /**
  22441. * Define if camera post processes should be use while rendering the texture.
  22442. */
  22443. useCameraPostProcesses: boolean;
  22444. /**
  22445. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  22446. */
  22447. ignoreCameraViewport: boolean;
  22448. private _postProcessManager;
  22449. private _postProcesses;
  22450. private _resizeObserver;
  22451. /**
  22452. * An event triggered when the texture is unbind.
  22453. */
  22454. onBeforeBindObservable: Observable<RenderTargetTexture>;
  22455. /**
  22456. * An event triggered when the texture is unbind.
  22457. */
  22458. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  22459. private _onAfterUnbindObserver;
  22460. /**
  22461. * Set a after unbind callback in the texture.
  22462. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  22463. */
  22464. onAfterUnbind: () => void;
  22465. /**
  22466. * An event triggered before rendering the texture
  22467. */
  22468. onBeforeRenderObservable: Observable<number>;
  22469. private _onBeforeRenderObserver;
  22470. /**
  22471. * Set a before render callback in the texture.
  22472. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  22473. */
  22474. onBeforeRender: (faceIndex: number) => void;
  22475. /**
  22476. * An event triggered after rendering the texture
  22477. */
  22478. onAfterRenderObservable: Observable<number>;
  22479. private _onAfterRenderObserver;
  22480. /**
  22481. * Set a after render callback in the texture.
  22482. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  22483. */
  22484. onAfterRender: (faceIndex: number) => void;
  22485. /**
  22486. * An event triggered after the texture clear
  22487. */
  22488. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  22489. private _onClearObserver;
  22490. /**
  22491. * Set a clear callback in the texture.
  22492. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  22493. */
  22494. onClear: (Engine: Engine) => void;
  22495. /**
  22496. * Define the clear color of the Render Target if it should be different from the scene.
  22497. */
  22498. clearColor: Color4;
  22499. protected _size: number | {
  22500. width: number;
  22501. height: number;
  22502. };
  22503. protected _initialSizeParameter: number | {
  22504. width: number;
  22505. height: number;
  22506. } | {
  22507. ratio: number;
  22508. };
  22509. protected _sizeRatio: Nullable<number>;
  22510. /** @hidden */
  22511. _generateMipMaps: boolean;
  22512. protected _renderingManager: RenderingManager;
  22513. /** @hidden */
  22514. _waitingRenderList: string[];
  22515. protected _doNotChangeAspectRatio: boolean;
  22516. protected _currentRefreshId: number;
  22517. protected _refreshRate: number;
  22518. protected _textureMatrix: Matrix;
  22519. protected _samples: number;
  22520. protected _renderTargetOptions: RenderTargetCreationOptions;
  22521. /**
  22522. * Gets render target creation options that were used.
  22523. */
  22524. readonly renderTargetOptions: RenderTargetCreationOptions;
  22525. protected _engine: Engine;
  22526. protected _onRatioRescale(): void;
  22527. /**
  22528. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  22529. * It must define where the camera used to render the texture is set
  22530. */
  22531. boundingBoxPosition: Vector3;
  22532. private _boundingBoxSize;
  22533. /**
  22534. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  22535. * When defined, the cubemap will switch to local mode
  22536. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  22537. * @example https://www.babylonjs-playground.com/#RNASML
  22538. */
  22539. boundingBoxSize: Vector3;
  22540. /**
  22541. * In case the RTT has been created with a depth texture, get the associated
  22542. * depth texture.
  22543. * Otherwise, return null.
  22544. */
  22545. depthStencilTexture: Nullable<InternalTexture>;
  22546. /**
  22547. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  22548. * or used a shadow, depth texture...
  22549. * @param name The friendly name of the texture
  22550. * @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)
  22551. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  22552. * @param generateMipMaps True if mip maps need to be generated after render.
  22553. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  22554. * @param type The type of the buffer in the RTT (int, half float, float...)
  22555. * @param isCube True if a cube texture needs to be created
  22556. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  22557. * @param generateDepthBuffer True to generate a depth buffer
  22558. * @param generateStencilBuffer True to generate a stencil buffer
  22559. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  22560. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  22561. * @param delayAllocation if the texture allocation should be delayed (default: false)
  22562. */
  22563. constructor(name: string, size: number | {
  22564. width: number;
  22565. height: number;
  22566. } | {
  22567. ratio: number;
  22568. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  22569. /**
  22570. * Creates a depth stencil texture.
  22571. * This is only available in WebGL 2 or with the depth texture extension available.
  22572. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  22573. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  22574. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  22575. */
  22576. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  22577. private _processSizeParameter;
  22578. /**
  22579. * Define the number of samples to use in case of MSAA.
  22580. * It defaults to one meaning no MSAA has been enabled.
  22581. */
  22582. samples: number;
  22583. /**
  22584. * Resets the refresh counter of the texture and start bak from scratch.
  22585. * Could be useful to regenerate the texture if it is setup to render only once.
  22586. */
  22587. resetRefreshCounter(): void;
  22588. /**
  22589. * Define the refresh rate of the texture or the rendering frequency.
  22590. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  22591. */
  22592. refreshRate: number;
  22593. /**
  22594. * Adds a post process to the render target rendering passes.
  22595. * @param postProcess define the post process to add
  22596. */
  22597. addPostProcess(postProcess: PostProcess): void;
  22598. /**
  22599. * Clear all the post processes attached to the render target
  22600. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  22601. */
  22602. clearPostProcesses(dispose?: boolean): void;
  22603. /**
  22604. * Remove one of the post process from the list of attached post processes to the texture
  22605. * @param postProcess define the post process to remove from the list
  22606. */
  22607. removePostProcess(postProcess: PostProcess): void;
  22608. /** @hidden */
  22609. _shouldRender(): boolean;
  22610. /**
  22611. * Gets the actual render size of the texture.
  22612. * @returns the width of the render size
  22613. */
  22614. getRenderSize(): number;
  22615. /**
  22616. * Gets the actual render width of the texture.
  22617. * @returns the width of the render size
  22618. */
  22619. getRenderWidth(): number;
  22620. /**
  22621. * Gets the actual render height of the texture.
  22622. * @returns the height of the render size
  22623. */
  22624. getRenderHeight(): number;
  22625. /**
  22626. * Get if the texture can be rescaled or not.
  22627. */
  22628. readonly canRescale: boolean;
  22629. /**
  22630. * Resize the texture using a ratio.
  22631. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  22632. */
  22633. scale(ratio: number): void;
  22634. /**
  22635. * Get the texture reflection matrix used to rotate/transform the reflection.
  22636. * @returns the reflection matrix
  22637. */
  22638. getReflectionTextureMatrix(): Matrix;
  22639. /**
  22640. * Resize the texture to a new desired size.
  22641. * Be carrefull as it will recreate all the data in the new texture.
  22642. * @param size Define the new size. It can be:
  22643. * - a number for squared texture,
  22644. * - an object containing { width: number, height: number }
  22645. * - or an object containing a ratio { ratio: number }
  22646. */
  22647. resize(size: number | {
  22648. width: number;
  22649. height: number;
  22650. } | {
  22651. ratio: number;
  22652. }): void;
  22653. /**
  22654. * Renders all the objects from the render list into the texture.
  22655. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  22656. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  22657. */
  22658. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  22659. private _bestReflectionRenderTargetDimension;
  22660. /**
  22661. * @hidden
  22662. * @param faceIndex face index to bind to if this is a cubetexture
  22663. */
  22664. _bindFrameBuffer(faceIndex?: number): void;
  22665. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  22666. private renderToTarget;
  22667. /**
  22668. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  22669. * This allowed control for front to back rendering or reversly depending of the special needs.
  22670. *
  22671. * @param renderingGroupId The rendering group id corresponding to its index
  22672. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  22673. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  22674. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  22675. */
  22676. 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;
  22677. /**
  22678. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  22679. *
  22680. * @param renderingGroupId The rendering group id corresponding to its index
  22681. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  22682. */
  22683. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  22684. /**
  22685. * Clones the texture.
  22686. * @returns the cloned texture
  22687. */
  22688. clone(): RenderTargetTexture;
  22689. /**
  22690. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  22691. * @returns The JSON representation of the texture
  22692. */
  22693. serialize(): any;
  22694. /**
  22695. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  22696. */
  22697. disposeFramebufferObjects(): void;
  22698. /**
  22699. * Dispose the texture and release its associated resources.
  22700. */
  22701. dispose(): void;
  22702. /** @hidden */
  22703. _rebuild(): void;
  22704. /**
  22705. * Clear the info related to rendering groups preventing retention point in material dispose.
  22706. */
  22707. freeRenderingGroups(): void;
  22708. /**
  22709. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  22710. * @returns the view count
  22711. */
  22712. getViewCount(): number;
  22713. }
  22714. }
  22715. declare module "babylonjs/Materials/material" {
  22716. import { IAnimatable } from "babylonjs/Misc/tools";
  22717. import { SmartArray } from "babylonjs/Misc/smartArray";
  22718. import { Observable } from "babylonjs/Misc/observable";
  22719. import { Nullable } from "babylonjs/types";
  22720. import { Scene } from "babylonjs/scene";
  22721. import { Matrix } from "babylonjs/Maths/math";
  22722. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22723. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22724. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22725. import { Effect } from "babylonjs/Materials/effect";
  22726. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22727. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22728. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22729. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22730. import { Mesh } from "babylonjs/Meshes/mesh";
  22731. import { Animation } from "babylonjs/Animations/animation";
  22732. /**
  22733. * Base class for the main features of a material in Babylon.js
  22734. */
  22735. export class Material implements IAnimatable {
  22736. /**
  22737. * Returns the triangle fill mode
  22738. */
  22739. static readonly TriangleFillMode: number;
  22740. /**
  22741. * Returns the wireframe mode
  22742. */
  22743. static readonly WireFrameFillMode: number;
  22744. /**
  22745. * Returns the point fill mode
  22746. */
  22747. static readonly PointFillMode: number;
  22748. /**
  22749. * Returns the point list draw mode
  22750. */
  22751. static readonly PointListDrawMode: number;
  22752. /**
  22753. * Returns the line list draw mode
  22754. */
  22755. static readonly LineListDrawMode: number;
  22756. /**
  22757. * Returns the line loop draw mode
  22758. */
  22759. static readonly LineLoopDrawMode: number;
  22760. /**
  22761. * Returns the line strip draw mode
  22762. */
  22763. static readonly LineStripDrawMode: number;
  22764. /**
  22765. * Returns the triangle strip draw mode
  22766. */
  22767. static readonly TriangleStripDrawMode: number;
  22768. /**
  22769. * Returns the triangle fan draw mode
  22770. */
  22771. static readonly TriangleFanDrawMode: number;
  22772. /**
  22773. * Stores the clock-wise side orientation
  22774. */
  22775. static readonly ClockWiseSideOrientation: number;
  22776. /**
  22777. * Stores the counter clock-wise side orientation
  22778. */
  22779. static readonly CounterClockWiseSideOrientation: number;
  22780. /**
  22781. * The dirty texture flag value
  22782. */
  22783. static readonly TextureDirtyFlag: number;
  22784. /**
  22785. * The dirty light flag value
  22786. */
  22787. static readonly LightDirtyFlag: number;
  22788. /**
  22789. * The dirty fresnel flag value
  22790. */
  22791. static readonly FresnelDirtyFlag: number;
  22792. /**
  22793. * The dirty attribute flag value
  22794. */
  22795. static readonly AttributesDirtyFlag: number;
  22796. /**
  22797. * The dirty misc flag value
  22798. */
  22799. static readonly MiscDirtyFlag: number;
  22800. /**
  22801. * The all dirty flag value
  22802. */
  22803. static readonly AllDirtyFlag: number;
  22804. /**
  22805. * The ID of the material
  22806. */
  22807. id: string;
  22808. /**
  22809. * Gets or sets the unique id of the material
  22810. */
  22811. uniqueId: number;
  22812. /**
  22813. * The name of the material
  22814. */
  22815. name: string;
  22816. /**
  22817. * Gets or sets user defined metadata
  22818. */
  22819. metadata: any;
  22820. /**
  22821. * For internal use only. Please do not use.
  22822. */
  22823. reservedDataStore: any;
  22824. /**
  22825. * Specifies if the ready state should be checked on each call
  22826. */
  22827. checkReadyOnEveryCall: boolean;
  22828. /**
  22829. * Specifies if the ready state should be checked once
  22830. */
  22831. checkReadyOnlyOnce: boolean;
  22832. /**
  22833. * The state of the material
  22834. */
  22835. state: string;
  22836. /**
  22837. * The alpha value of the material
  22838. */
  22839. protected _alpha: number;
  22840. /**
  22841. * List of inspectable custom properties (used by the Inspector)
  22842. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22843. */
  22844. inspectableCustomProperties: IInspectable[];
  22845. /**
  22846. * Sets the alpha value of the material
  22847. */
  22848. /**
  22849. * Gets the alpha value of the material
  22850. */
  22851. alpha: number;
  22852. /**
  22853. * Specifies if back face culling is enabled
  22854. */
  22855. protected _backFaceCulling: boolean;
  22856. /**
  22857. * Sets the back-face culling state
  22858. */
  22859. /**
  22860. * Gets the back-face culling state
  22861. */
  22862. backFaceCulling: boolean;
  22863. /**
  22864. * Stores the value for side orientation
  22865. */
  22866. sideOrientation: number;
  22867. /**
  22868. * Callback triggered when the material is compiled
  22869. */
  22870. onCompiled: Nullable<(effect: Effect) => void>;
  22871. /**
  22872. * Callback triggered when an error occurs
  22873. */
  22874. onError: Nullable<(effect: Effect, errors: string) => void>;
  22875. /**
  22876. * Callback triggered to get the render target textures
  22877. */
  22878. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22879. /**
  22880. * Gets a boolean indicating that current material needs to register RTT
  22881. */
  22882. readonly hasRenderTargetTextures: boolean;
  22883. /**
  22884. * Specifies if the material should be serialized
  22885. */
  22886. doNotSerialize: boolean;
  22887. /**
  22888. * @hidden
  22889. */
  22890. _storeEffectOnSubMeshes: boolean;
  22891. /**
  22892. * Stores the animations for the material
  22893. */
  22894. animations: Nullable<Array<Animation>>;
  22895. /**
  22896. * An event triggered when the material is disposed
  22897. */
  22898. onDisposeObservable: Observable<Material>;
  22899. /**
  22900. * An observer which watches for dispose events
  22901. */
  22902. private _onDisposeObserver;
  22903. private _onUnBindObservable;
  22904. /**
  22905. * Called during a dispose event
  22906. */
  22907. onDispose: () => void;
  22908. private _onBindObservable;
  22909. /**
  22910. * An event triggered when the material is bound
  22911. */
  22912. readonly onBindObservable: Observable<AbstractMesh>;
  22913. /**
  22914. * An observer which watches for bind events
  22915. */
  22916. private _onBindObserver;
  22917. /**
  22918. * Called during a bind event
  22919. */
  22920. onBind: (Mesh: AbstractMesh) => void;
  22921. /**
  22922. * An event triggered when the material is unbound
  22923. */
  22924. readonly onUnBindObservable: Observable<Material>;
  22925. /**
  22926. * Stores the value of the alpha mode
  22927. */
  22928. private _alphaMode;
  22929. /**
  22930. * Sets the value of the alpha mode.
  22931. *
  22932. * | Value | Type | Description |
  22933. * | --- | --- | --- |
  22934. * | 0 | ALPHA_DISABLE | |
  22935. * | 1 | ALPHA_ADD | |
  22936. * | 2 | ALPHA_COMBINE | |
  22937. * | 3 | ALPHA_SUBTRACT | |
  22938. * | 4 | ALPHA_MULTIPLY | |
  22939. * | 5 | ALPHA_MAXIMIZED | |
  22940. * | 6 | ALPHA_ONEONE | |
  22941. * | 7 | ALPHA_PREMULTIPLIED | |
  22942. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22943. * | 9 | ALPHA_INTERPOLATE | |
  22944. * | 10 | ALPHA_SCREENMODE | |
  22945. *
  22946. */
  22947. /**
  22948. * Gets the value of the alpha mode
  22949. */
  22950. alphaMode: number;
  22951. /**
  22952. * Stores the state of the need depth pre-pass value
  22953. */
  22954. private _needDepthPrePass;
  22955. /**
  22956. * Sets the need depth pre-pass value
  22957. */
  22958. /**
  22959. * Gets the depth pre-pass value
  22960. */
  22961. needDepthPrePass: boolean;
  22962. /**
  22963. * Specifies if depth writing should be disabled
  22964. */
  22965. disableDepthWrite: boolean;
  22966. /**
  22967. * Specifies if depth writing should be forced
  22968. */
  22969. forceDepthWrite: boolean;
  22970. /**
  22971. * Specifies if there should be a separate pass for culling
  22972. */
  22973. separateCullingPass: boolean;
  22974. /**
  22975. * Stores the state specifing if fog should be enabled
  22976. */
  22977. private _fogEnabled;
  22978. /**
  22979. * Sets the state for enabling fog
  22980. */
  22981. /**
  22982. * Gets the value of the fog enabled state
  22983. */
  22984. fogEnabled: boolean;
  22985. /**
  22986. * Stores the size of points
  22987. */
  22988. pointSize: number;
  22989. /**
  22990. * Stores the z offset value
  22991. */
  22992. zOffset: number;
  22993. /**
  22994. * Gets a value specifying if wireframe mode is enabled
  22995. */
  22996. /**
  22997. * Sets the state of wireframe mode
  22998. */
  22999. wireframe: boolean;
  23000. /**
  23001. * Gets the value specifying if point clouds are enabled
  23002. */
  23003. /**
  23004. * Sets the state of point cloud mode
  23005. */
  23006. pointsCloud: boolean;
  23007. /**
  23008. * Gets the material fill mode
  23009. */
  23010. /**
  23011. * Sets the material fill mode
  23012. */
  23013. fillMode: number;
  23014. /**
  23015. * @hidden
  23016. * Stores the effects for the material
  23017. */
  23018. _effect: Nullable<Effect>;
  23019. /**
  23020. * @hidden
  23021. * Specifies if the material was previously ready
  23022. */
  23023. _wasPreviouslyReady: boolean;
  23024. /**
  23025. * Specifies if uniform buffers should be used
  23026. */
  23027. private _useUBO;
  23028. /**
  23029. * Stores a reference to the scene
  23030. */
  23031. private _scene;
  23032. /**
  23033. * Stores the fill mode state
  23034. */
  23035. private _fillMode;
  23036. /**
  23037. * Specifies if the depth write state should be cached
  23038. */
  23039. private _cachedDepthWriteState;
  23040. /**
  23041. * Stores the uniform buffer
  23042. */
  23043. protected _uniformBuffer: UniformBuffer;
  23044. /** @hidden */
  23045. _indexInSceneMaterialArray: number;
  23046. /** @hidden */
  23047. meshMap: Nullable<{
  23048. [id: string]: AbstractMesh | undefined;
  23049. }>;
  23050. /**
  23051. * Creates a material instance
  23052. * @param name defines the name of the material
  23053. * @param scene defines the scene to reference
  23054. * @param doNotAdd specifies if the material should be added to the scene
  23055. */
  23056. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  23057. /**
  23058. * Returns a string representation of the current material
  23059. * @param fullDetails defines a boolean indicating which levels of logging is desired
  23060. * @returns a string with material information
  23061. */
  23062. toString(fullDetails?: boolean): string;
  23063. /**
  23064. * Gets the class name of the material
  23065. * @returns a string with the class name of the material
  23066. */
  23067. getClassName(): string;
  23068. /**
  23069. * Specifies if updates for the material been locked
  23070. */
  23071. readonly isFrozen: boolean;
  23072. /**
  23073. * Locks updates for the material
  23074. */
  23075. freeze(): void;
  23076. /**
  23077. * Unlocks updates for the material
  23078. */
  23079. unfreeze(): void;
  23080. /**
  23081. * Specifies if the material is ready to be used
  23082. * @param mesh defines the mesh to check
  23083. * @param useInstances specifies if instances should be used
  23084. * @returns a boolean indicating if the material is ready to be used
  23085. */
  23086. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  23087. /**
  23088. * Specifies that the submesh is ready to be used
  23089. * @param mesh defines the mesh to check
  23090. * @param subMesh defines which submesh to check
  23091. * @param useInstances specifies that instances should be used
  23092. * @returns a boolean indicating that the submesh is ready or not
  23093. */
  23094. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  23095. /**
  23096. * Returns the material effect
  23097. * @returns the effect associated with the material
  23098. */
  23099. getEffect(): Nullable<Effect>;
  23100. /**
  23101. * Returns the current scene
  23102. * @returns a Scene
  23103. */
  23104. getScene(): Scene;
  23105. /**
  23106. * Specifies if the material will require alpha blending
  23107. * @returns a boolean specifying if alpha blending is needed
  23108. */
  23109. needAlphaBlending(): boolean;
  23110. /**
  23111. * Specifies if the mesh will require alpha blending
  23112. * @param mesh defines the mesh to check
  23113. * @returns a boolean specifying if alpha blending is needed for the mesh
  23114. */
  23115. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  23116. /**
  23117. * Specifies if this material should be rendered in alpha test mode
  23118. * @returns a boolean specifying if an alpha test is needed.
  23119. */
  23120. needAlphaTesting(): boolean;
  23121. /**
  23122. * Gets the texture used for the alpha test
  23123. * @returns the texture to use for alpha testing
  23124. */
  23125. getAlphaTestTexture(): Nullable<BaseTexture>;
  23126. /**
  23127. * Marks the material to indicate that it needs to be re-calculated
  23128. */
  23129. markDirty(): void;
  23130. /** @hidden */
  23131. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  23132. /**
  23133. * Binds the material to the mesh
  23134. * @param world defines the world transformation matrix
  23135. * @param mesh defines the mesh to bind the material to
  23136. */
  23137. bind(world: Matrix, mesh?: Mesh): void;
  23138. /**
  23139. * Binds the submesh to the material
  23140. * @param world defines the world transformation matrix
  23141. * @param mesh defines the mesh containing the submesh
  23142. * @param subMesh defines the submesh to bind the material to
  23143. */
  23144. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23145. /**
  23146. * Binds the world matrix to the material
  23147. * @param world defines the world transformation matrix
  23148. */
  23149. bindOnlyWorldMatrix(world: Matrix): void;
  23150. /**
  23151. * Binds the scene's uniform buffer to the effect.
  23152. * @param effect defines the effect to bind to the scene uniform buffer
  23153. * @param sceneUbo defines the uniform buffer storing scene data
  23154. */
  23155. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  23156. /**
  23157. * Binds the view matrix to the effect
  23158. * @param effect defines the effect to bind the view matrix to
  23159. */
  23160. bindView(effect: Effect): void;
  23161. /**
  23162. * Binds the view projection matrix to the effect
  23163. * @param effect defines the effect to bind the view projection matrix to
  23164. */
  23165. bindViewProjection(effect: Effect): void;
  23166. /**
  23167. * Specifies if material alpha testing should be turned on for the mesh
  23168. * @param mesh defines the mesh to check
  23169. */
  23170. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  23171. /**
  23172. * Processes to execute after binding the material to a mesh
  23173. * @param mesh defines the rendered mesh
  23174. */
  23175. protected _afterBind(mesh?: Mesh): void;
  23176. /**
  23177. * Unbinds the material from the mesh
  23178. */
  23179. unbind(): void;
  23180. /**
  23181. * Gets the active textures from the material
  23182. * @returns an array of textures
  23183. */
  23184. getActiveTextures(): BaseTexture[];
  23185. /**
  23186. * Specifies if the material uses a texture
  23187. * @param texture defines the texture to check against the material
  23188. * @returns a boolean specifying if the material uses the texture
  23189. */
  23190. hasTexture(texture: BaseTexture): boolean;
  23191. /**
  23192. * Makes a duplicate of the material, and gives it a new name
  23193. * @param name defines the new name for the duplicated material
  23194. * @returns the cloned material
  23195. */
  23196. clone(name: string): Nullable<Material>;
  23197. /**
  23198. * Gets the meshes bound to the material
  23199. * @returns an array of meshes bound to the material
  23200. */
  23201. getBindedMeshes(): AbstractMesh[];
  23202. /**
  23203. * Force shader compilation
  23204. * @param mesh defines the mesh associated with this material
  23205. * @param onCompiled defines a function to execute once the material is compiled
  23206. * @param options defines the options to configure the compilation
  23207. */
  23208. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  23209. clipPlane: boolean;
  23210. }>): void;
  23211. /**
  23212. * Force shader compilation
  23213. * @param mesh defines the mesh that will use this material
  23214. * @param options defines additional options for compiling the shaders
  23215. * @returns a promise that resolves when the compilation completes
  23216. */
  23217. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  23218. clipPlane: boolean;
  23219. }>): Promise<void>;
  23220. private static readonly _AllDirtyCallBack;
  23221. private static readonly _ImageProcessingDirtyCallBack;
  23222. private static readonly _TextureDirtyCallBack;
  23223. private static readonly _FresnelDirtyCallBack;
  23224. private static readonly _MiscDirtyCallBack;
  23225. private static readonly _LightsDirtyCallBack;
  23226. private static readonly _AttributeDirtyCallBack;
  23227. private static _FresnelAndMiscDirtyCallBack;
  23228. private static _TextureAndMiscDirtyCallBack;
  23229. private static readonly _DirtyCallbackArray;
  23230. private static readonly _RunDirtyCallBacks;
  23231. /**
  23232. * Marks a define in the material to indicate that it needs to be re-computed
  23233. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  23234. */
  23235. markAsDirty(flag: number): void;
  23236. /**
  23237. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  23238. * @param func defines a function which checks material defines against the submeshes
  23239. */
  23240. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  23241. /**
  23242. * Indicates that we need to re-calculated for all submeshes
  23243. */
  23244. protected _markAllSubMeshesAsAllDirty(): void;
  23245. /**
  23246. * Indicates that image processing needs to be re-calculated for all submeshes
  23247. */
  23248. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  23249. /**
  23250. * Indicates that textures need to be re-calculated for all submeshes
  23251. */
  23252. protected _markAllSubMeshesAsTexturesDirty(): void;
  23253. /**
  23254. * Indicates that fresnel needs to be re-calculated for all submeshes
  23255. */
  23256. protected _markAllSubMeshesAsFresnelDirty(): void;
  23257. /**
  23258. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  23259. */
  23260. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  23261. /**
  23262. * Indicates that lights need to be re-calculated for all submeshes
  23263. */
  23264. protected _markAllSubMeshesAsLightsDirty(): void;
  23265. /**
  23266. * Indicates that attributes need to be re-calculated for all submeshes
  23267. */
  23268. protected _markAllSubMeshesAsAttributesDirty(): void;
  23269. /**
  23270. * Indicates that misc needs to be re-calculated for all submeshes
  23271. */
  23272. protected _markAllSubMeshesAsMiscDirty(): void;
  23273. /**
  23274. * Indicates that textures and misc need to be re-calculated for all submeshes
  23275. */
  23276. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  23277. /**
  23278. * Disposes the material
  23279. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23280. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23281. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23282. */
  23283. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23284. /** @hidden */
  23285. private releaseVertexArrayObject;
  23286. /**
  23287. * Serializes this material
  23288. * @returns the serialized material object
  23289. */
  23290. serialize(): any;
  23291. /**
  23292. * Creates a material from parsed material data
  23293. * @param parsedMaterial defines parsed material data
  23294. * @param scene defines the hosting scene
  23295. * @param rootUrl defines the root URL to use to load textures
  23296. * @returns a new material
  23297. */
  23298. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  23299. }
  23300. }
  23301. declare module "babylonjs/Meshes/subMesh" {
  23302. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  23303. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  23304. import { Engine } from "babylonjs/Engines/engine";
  23305. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  23306. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23307. import { Effect } from "babylonjs/Materials/effect";
  23308. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23309. import { Collider } from "babylonjs/Collisions/collider";
  23310. import { Material } from "babylonjs/Materials/material";
  23311. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23313. import { Mesh } from "babylonjs/Meshes/mesh";
  23314. import { Ray } from "babylonjs/Culling/ray";
  23315. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23316. /**
  23317. * Base class for submeshes
  23318. */
  23319. export class BaseSubMesh {
  23320. /** @hidden */
  23321. _materialDefines: Nullable<MaterialDefines>;
  23322. /** @hidden */
  23323. _materialEffect: Nullable<Effect>;
  23324. /**
  23325. * Gets associated effect
  23326. */
  23327. readonly effect: Nullable<Effect>;
  23328. /**
  23329. * Sets associated effect (effect used to render this submesh)
  23330. * @param effect defines the effect to associate with
  23331. * @param defines defines the set of defines used to compile this effect
  23332. */
  23333. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23334. }
  23335. /**
  23336. * Defines a subdivision inside a mesh
  23337. */
  23338. export class SubMesh extends BaseSubMesh implements ICullable {
  23339. /** the material index to use */
  23340. materialIndex: number;
  23341. /** vertex index start */
  23342. verticesStart: number;
  23343. /** vertices count */
  23344. verticesCount: number;
  23345. /** index start */
  23346. indexStart: number;
  23347. /** indices count */
  23348. indexCount: number;
  23349. /** @hidden */
  23350. _linesIndexCount: number;
  23351. private _mesh;
  23352. private _renderingMesh;
  23353. private _boundingInfo;
  23354. private _linesIndexBuffer;
  23355. /** @hidden */
  23356. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23357. /** @hidden */
  23358. _trianglePlanes: Plane[];
  23359. /** @hidden */
  23360. _lastColliderTransformMatrix: Nullable<Matrix>;
  23361. /** @hidden */
  23362. _renderId: number;
  23363. /** @hidden */
  23364. _alphaIndex: number;
  23365. /** @hidden */
  23366. _distanceToCamera: number;
  23367. /** @hidden */
  23368. _id: number;
  23369. private _currentMaterial;
  23370. /**
  23371. * Add a new submesh to a mesh
  23372. * @param materialIndex defines the material index to use
  23373. * @param verticesStart defines vertex index start
  23374. * @param verticesCount defines vertices count
  23375. * @param indexStart defines index start
  23376. * @param indexCount defines indices count
  23377. * @param mesh defines the parent mesh
  23378. * @param renderingMesh defines an optional rendering mesh
  23379. * @param createBoundingBox defines if bounding box should be created for this submesh
  23380. * @returns the new submesh
  23381. */
  23382. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23383. /**
  23384. * Creates a new submesh
  23385. * @param materialIndex defines the material index to use
  23386. * @param verticesStart defines vertex index start
  23387. * @param verticesCount defines vertices count
  23388. * @param indexStart defines index start
  23389. * @param indexCount defines indices count
  23390. * @param mesh defines the parent mesh
  23391. * @param renderingMesh defines an optional rendering mesh
  23392. * @param createBoundingBox defines if bounding box should be created for this submesh
  23393. */
  23394. constructor(
  23395. /** the material index to use */
  23396. materialIndex: number,
  23397. /** vertex index start */
  23398. verticesStart: number,
  23399. /** vertices count */
  23400. verticesCount: number,
  23401. /** index start */
  23402. indexStart: number,
  23403. /** indices count */
  23404. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23405. /**
  23406. * Returns true if this submesh covers the entire parent mesh
  23407. * @ignorenaming
  23408. */
  23409. readonly IsGlobal: boolean;
  23410. /**
  23411. * Returns the submesh BoudingInfo object
  23412. * @returns current bounding info (or mesh's one if the submesh is global)
  23413. */
  23414. getBoundingInfo(): BoundingInfo;
  23415. /**
  23416. * Sets the submesh BoundingInfo
  23417. * @param boundingInfo defines the new bounding info to use
  23418. * @returns the SubMesh
  23419. */
  23420. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23421. /**
  23422. * Returns the mesh of the current submesh
  23423. * @return the parent mesh
  23424. */
  23425. getMesh(): AbstractMesh;
  23426. /**
  23427. * Returns the rendering mesh of the submesh
  23428. * @returns the rendering mesh (could be different from parent mesh)
  23429. */
  23430. getRenderingMesh(): Mesh;
  23431. /**
  23432. * Returns the submesh material
  23433. * @returns null or the current material
  23434. */
  23435. getMaterial(): Nullable<Material>;
  23436. /**
  23437. * Sets a new updated BoundingInfo object to the submesh
  23438. * @param data defines an optional position array to use to determine the bounding info
  23439. * @returns the SubMesh
  23440. */
  23441. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  23442. /** @hidden */
  23443. _checkCollision(collider: Collider): boolean;
  23444. /**
  23445. * Updates the submesh BoundingInfo
  23446. * @param world defines the world matrix to use to update the bounding info
  23447. * @returns the submesh
  23448. */
  23449. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  23450. /**
  23451. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23452. * @param frustumPlanes defines the frustum planes
  23453. * @returns true if the submesh is intersecting with the frustum
  23454. */
  23455. isInFrustum(frustumPlanes: Plane[]): boolean;
  23456. /**
  23457. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  23458. * @param frustumPlanes defines the frustum planes
  23459. * @returns true if the submesh is inside the frustum
  23460. */
  23461. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23462. /**
  23463. * Renders the submesh
  23464. * @param enableAlphaMode defines if alpha needs to be used
  23465. * @returns the submesh
  23466. */
  23467. render(enableAlphaMode: boolean): SubMesh;
  23468. /**
  23469. * @hidden
  23470. */
  23471. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  23472. /**
  23473. * Checks if the submesh intersects with a ray
  23474. * @param ray defines the ray to test
  23475. * @returns true is the passed ray intersects the submesh bounding box
  23476. */
  23477. canIntersects(ray: Ray): boolean;
  23478. /**
  23479. * Intersects current submesh with a ray
  23480. * @param ray defines the ray to test
  23481. * @param positions defines mesh's positions array
  23482. * @param indices defines mesh's indices array
  23483. * @param fastCheck defines if only bounding info should be used
  23484. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  23485. * @returns intersection info or null if no intersection
  23486. */
  23487. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  23488. /** @hidden */
  23489. private _intersectLines;
  23490. /** @hidden */
  23491. private _intersectUnIndexedLines;
  23492. /** @hidden */
  23493. private _intersectTriangles;
  23494. /** @hidden */
  23495. private _intersectUnIndexedTriangles;
  23496. /** @hidden */
  23497. _rebuild(): void;
  23498. /**
  23499. * Creates a new submesh from the passed mesh
  23500. * @param newMesh defines the new hosting mesh
  23501. * @param newRenderingMesh defines an optional rendering mesh
  23502. * @returns the new submesh
  23503. */
  23504. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23505. /**
  23506. * Release associated resources
  23507. */
  23508. dispose(): void;
  23509. /**
  23510. * Gets the class name
  23511. * @returns the string "SubMesh".
  23512. */
  23513. getClassName(): string;
  23514. /**
  23515. * Creates a new submesh from indices data
  23516. * @param materialIndex the index of the main mesh material
  23517. * @param startIndex the index where to start the copy in the mesh indices array
  23518. * @param indexCount the number of indices to copy then from the startIndex
  23519. * @param mesh the main mesh to create the submesh from
  23520. * @param renderingMesh the optional rendering mesh
  23521. * @returns a new submesh
  23522. */
  23523. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23524. }
  23525. }
  23526. declare module "babylonjs/Meshes/geometry" {
  23527. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  23528. import { Scene } from "babylonjs/scene";
  23529. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  23530. import { Engine } from "babylonjs/Engines/engine";
  23531. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  23532. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23533. import { Effect } from "babylonjs/Materials/effect";
  23534. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23535. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23536. import { Mesh } from "babylonjs/Meshes/mesh";
  23537. /**
  23538. * Class used to store geometry data (vertex buffers + index buffer)
  23539. */
  23540. export class Geometry implements IGetSetVerticesData {
  23541. /**
  23542. * Gets or sets the ID of the geometry
  23543. */
  23544. id: string;
  23545. /**
  23546. * Gets or sets the unique ID of the geometry
  23547. */
  23548. uniqueId: number;
  23549. /**
  23550. * Gets the delay loading state of the geometry (none by default which means not delayed)
  23551. */
  23552. delayLoadState: number;
  23553. /**
  23554. * Gets the file containing the data to load when running in delay load state
  23555. */
  23556. delayLoadingFile: Nullable<string>;
  23557. /**
  23558. * Callback called when the geometry is updated
  23559. */
  23560. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  23561. private _scene;
  23562. private _engine;
  23563. private _meshes;
  23564. private _totalVertices;
  23565. /** @hidden */
  23566. _indices: IndicesArray;
  23567. /** @hidden */
  23568. _vertexBuffers: {
  23569. [key: string]: VertexBuffer;
  23570. };
  23571. private _isDisposed;
  23572. private _extend;
  23573. private _boundingBias;
  23574. /** @hidden */
  23575. _delayInfo: Array<string>;
  23576. private _indexBuffer;
  23577. private _indexBufferIsUpdatable;
  23578. /** @hidden */
  23579. _boundingInfo: Nullable<BoundingInfo>;
  23580. /** @hidden */
  23581. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  23582. /** @hidden */
  23583. _softwareSkinningFrameId: number;
  23584. private _vertexArrayObjects;
  23585. private _updatable;
  23586. /** @hidden */
  23587. _positions: Nullable<Vector3[]>;
  23588. /**
  23589. * 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
  23590. */
  23591. /**
  23592. * 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
  23593. */
  23594. boundingBias: Vector2;
  23595. /**
  23596. * Static function used to attach a new empty geometry to a mesh
  23597. * @param mesh defines the mesh to attach the geometry to
  23598. * @returns the new Geometry
  23599. */
  23600. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  23601. /**
  23602. * Creates a new geometry
  23603. * @param id defines the unique ID
  23604. * @param scene defines the hosting scene
  23605. * @param vertexData defines the VertexData used to get geometry data
  23606. * @param updatable defines if geometry must be updatable (false by default)
  23607. * @param mesh defines the mesh that will be associated with the geometry
  23608. */
  23609. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  23610. /**
  23611. * Gets the current extend of the geometry
  23612. */
  23613. readonly extend: {
  23614. minimum: Vector3;
  23615. maximum: Vector3;
  23616. };
  23617. /**
  23618. * Gets the hosting scene
  23619. * @returns the hosting Scene
  23620. */
  23621. getScene(): Scene;
  23622. /**
  23623. * Gets the hosting engine
  23624. * @returns the hosting Engine
  23625. */
  23626. getEngine(): Engine;
  23627. /**
  23628. * Defines if the geometry is ready to use
  23629. * @returns true if the geometry is ready to be used
  23630. */
  23631. isReady(): boolean;
  23632. /**
  23633. * Gets a value indicating that the geometry should not be serialized
  23634. */
  23635. readonly doNotSerialize: boolean;
  23636. /** @hidden */
  23637. _rebuild(): void;
  23638. /**
  23639. * Affects all geometry data in one call
  23640. * @param vertexData defines the geometry data
  23641. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23642. */
  23643. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23644. /**
  23645. * Set specific vertex data
  23646. * @param kind defines the data kind (Position, normal, etc...)
  23647. * @param data defines the vertex data to use
  23648. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23649. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23650. */
  23651. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23652. /**
  23653. * Removes a specific vertex data
  23654. * @param kind defines the data kind (Position, normal, etc...)
  23655. */
  23656. removeVerticesData(kind: string): void;
  23657. /**
  23658. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23659. * @param buffer defines the vertex buffer to use
  23660. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23661. */
  23662. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23663. /**
  23664. * Update a specific vertex buffer
  23665. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23666. * It will do nothing if the buffer is not updatable
  23667. * @param kind defines the data kind (Position, normal, etc...)
  23668. * @param data defines the data to use
  23669. * @param offset defines the offset in the target buffer where to store the data
  23670. * @param useBytes set to true if the offset is in bytes
  23671. */
  23672. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23673. /**
  23674. * Update a specific vertex buffer
  23675. * This function will create a new buffer if the current one is not updatable
  23676. * @param kind defines the data kind (Position, normal, etc...)
  23677. * @param data defines the data to use
  23678. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23679. */
  23680. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23681. private _updateBoundingInfo;
  23682. /** @hidden */
  23683. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23684. /**
  23685. * Gets total number of vertices
  23686. * @returns the total number of vertices
  23687. */
  23688. getTotalVertices(): number;
  23689. /**
  23690. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23691. * @param kind defines the data kind (Position, normal, etc...)
  23692. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23693. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23694. * @returns a float array containing vertex data
  23695. */
  23696. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23697. /**
  23698. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23699. * @param kind defines the data kind (Position, normal, etc...)
  23700. * @returns true if the vertex buffer with the specified kind is updatable
  23701. */
  23702. isVertexBufferUpdatable(kind: string): boolean;
  23703. /**
  23704. * Gets a specific vertex buffer
  23705. * @param kind defines the data kind (Position, normal, etc...)
  23706. * @returns a VertexBuffer
  23707. */
  23708. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23709. /**
  23710. * Returns all vertex buffers
  23711. * @return an object holding all vertex buffers indexed by kind
  23712. */
  23713. getVertexBuffers(): Nullable<{
  23714. [key: string]: VertexBuffer;
  23715. }>;
  23716. /**
  23717. * Gets a boolean indicating if specific vertex buffer is present
  23718. * @param kind defines the data kind (Position, normal, etc...)
  23719. * @returns true if data is present
  23720. */
  23721. isVerticesDataPresent(kind: string): boolean;
  23722. /**
  23723. * Gets a list of all attached data kinds (Position, normal, etc...)
  23724. * @returns a list of string containing all kinds
  23725. */
  23726. getVerticesDataKinds(): string[];
  23727. /**
  23728. * Update index buffer
  23729. * @param indices defines the indices to store in the index buffer
  23730. * @param offset defines the offset in the target buffer where to store the data
  23731. * @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)
  23732. */
  23733. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23734. /**
  23735. * Creates a new index buffer
  23736. * @param indices defines the indices to store in the index buffer
  23737. * @param totalVertices defines the total number of vertices (could be null)
  23738. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23739. */
  23740. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23741. /**
  23742. * Return the total number of indices
  23743. * @returns the total number of indices
  23744. */
  23745. getTotalIndices(): number;
  23746. /**
  23747. * Gets the index buffer array
  23748. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23749. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23750. * @returns the index buffer array
  23751. */
  23752. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23753. /**
  23754. * Gets the index buffer
  23755. * @return the index buffer
  23756. */
  23757. getIndexBuffer(): Nullable<DataBuffer>;
  23758. /** @hidden */
  23759. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23760. /**
  23761. * Release the associated resources for a specific mesh
  23762. * @param mesh defines the source mesh
  23763. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23764. */
  23765. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23766. /**
  23767. * Apply current geometry to a given mesh
  23768. * @param mesh defines the mesh to apply geometry to
  23769. */
  23770. applyToMesh(mesh: Mesh): void;
  23771. private _updateExtend;
  23772. private _applyToMesh;
  23773. private notifyUpdate;
  23774. /**
  23775. * Load the geometry if it was flagged as delay loaded
  23776. * @param scene defines the hosting scene
  23777. * @param onLoaded defines a callback called when the geometry is loaded
  23778. */
  23779. load(scene: Scene, onLoaded?: () => void): void;
  23780. private _queueLoad;
  23781. /**
  23782. * Invert the geometry to move from a right handed system to a left handed one.
  23783. */
  23784. toLeftHanded(): void;
  23785. /** @hidden */
  23786. _resetPointsArrayCache(): void;
  23787. /** @hidden */
  23788. _generatePointsArray(): boolean;
  23789. /**
  23790. * Gets a value indicating if the geometry is disposed
  23791. * @returns true if the geometry was disposed
  23792. */
  23793. isDisposed(): boolean;
  23794. private _disposeVertexArrayObjects;
  23795. /**
  23796. * Free all associated resources
  23797. */
  23798. dispose(): void;
  23799. /**
  23800. * Clone the current geometry into a new geometry
  23801. * @param id defines the unique ID of the new geometry
  23802. * @returns a new geometry object
  23803. */
  23804. copy(id: string): Geometry;
  23805. /**
  23806. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23807. * @return a JSON representation of the current geometry data (without the vertices data)
  23808. */
  23809. serialize(): any;
  23810. private toNumberArray;
  23811. /**
  23812. * Serialize all vertices data into a JSON oject
  23813. * @returns a JSON representation of the current geometry data
  23814. */
  23815. serializeVerticeData(): any;
  23816. /**
  23817. * Extracts a clone of a mesh geometry
  23818. * @param mesh defines the source mesh
  23819. * @param id defines the unique ID of the new geometry object
  23820. * @returns the new geometry object
  23821. */
  23822. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23823. /**
  23824. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23825. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23826. * Be aware Math.random() could cause collisions, but:
  23827. * "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"
  23828. * @returns a string containing a new GUID
  23829. */
  23830. static RandomId(): string;
  23831. /** @hidden */
  23832. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23833. private static _CleanMatricesWeights;
  23834. /**
  23835. * Create a new geometry from persisted data (Using .babylon file format)
  23836. * @param parsedVertexData defines the persisted data
  23837. * @param scene defines the hosting scene
  23838. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23839. * @returns the new geometry object
  23840. */
  23841. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23842. }
  23843. }
  23844. declare module "babylonjs/Meshes/mesh.vertexData" {
  23845. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23846. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23847. import { Geometry } from "babylonjs/Meshes/geometry";
  23848. import { Mesh } from "babylonjs/Meshes/mesh";
  23849. /**
  23850. * Define an interface for all classes that will get and set the data on vertices
  23851. */
  23852. export interface IGetSetVerticesData {
  23853. /**
  23854. * Gets a boolean indicating if specific vertex data is present
  23855. * @param kind defines the vertex data kind to use
  23856. * @returns true is data kind is present
  23857. */
  23858. isVerticesDataPresent(kind: string): boolean;
  23859. /**
  23860. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23861. * @param kind defines the data kind (Position, normal, etc...)
  23862. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23863. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23864. * @returns a float array containing vertex data
  23865. */
  23866. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23867. /**
  23868. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23869. * @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.
  23870. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23871. * @returns the indices array or an empty array if the mesh has no geometry
  23872. */
  23873. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23874. /**
  23875. * Set specific vertex data
  23876. * @param kind defines the data kind (Position, normal, etc...)
  23877. * @param data defines the vertex data to use
  23878. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23879. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23880. */
  23881. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23882. /**
  23883. * Update a specific associated vertex buffer
  23884. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23885. * - VertexBuffer.PositionKind
  23886. * - VertexBuffer.UVKind
  23887. * - VertexBuffer.UV2Kind
  23888. * - VertexBuffer.UV3Kind
  23889. * - VertexBuffer.UV4Kind
  23890. * - VertexBuffer.UV5Kind
  23891. * - VertexBuffer.UV6Kind
  23892. * - VertexBuffer.ColorKind
  23893. * - VertexBuffer.MatricesIndicesKind
  23894. * - VertexBuffer.MatricesIndicesExtraKind
  23895. * - VertexBuffer.MatricesWeightsKind
  23896. * - VertexBuffer.MatricesWeightsExtraKind
  23897. * @param data defines the data source
  23898. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23899. * @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)
  23900. */
  23901. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23902. /**
  23903. * Creates a new index buffer
  23904. * @param indices defines the indices to store in the index buffer
  23905. * @param totalVertices defines the total number of vertices (could be null)
  23906. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23907. */
  23908. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23909. }
  23910. /**
  23911. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23912. */
  23913. export class VertexData {
  23914. /**
  23915. * Mesh side orientation : usually the external or front surface
  23916. */
  23917. static readonly FRONTSIDE: number;
  23918. /**
  23919. * Mesh side orientation : usually the internal or back surface
  23920. */
  23921. static readonly BACKSIDE: number;
  23922. /**
  23923. * Mesh side orientation : both internal and external or front and back surfaces
  23924. */
  23925. static readonly DOUBLESIDE: number;
  23926. /**
  23927. * Mesh side orientation : by default, `FRONTSIDE`
  23928. */
  23929. static readonly DEFAULTSIDE: number;
  23930. /**
  23931. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23932. */
  23933. positions: Nullable<FloatArray>;
  23934. /**
  23935. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23936. */
  23937. normals: Nullable<FloatArray>;
  23938. /**
  23939. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23940. */
  23941. tangents: Nullable<FloatArray>;
  23942. /**
  23943. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23944. */
  23945. uvs: Nullable<FloatArray>;
  23946. /**
  23947. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23948. */
  23949. uvs2: Nullable<FloatArray>;
  23950. /**
  23951. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23952. */
  23953. uvs3: Nullable<FloatArray>;
  23954. /**
  23955. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23956. */
  23957. uvs4: Nullable<FloatArray>;
  23958. /**
  23959. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23960. */
  23961. uvs5: Nullable<FloatArray>;
  23962. /**
  23963. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23964. */
  23965. uvs6: Nullable<FloatArray>;
  23966. /**
  23967. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23968. */
  23969. colors: Nullable<FloatArray>;
  23970. /**
  23971. * 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).
  23972. */
  23973. matricesIndices: Nullable<FloatArray>;
  23974. /**
  23975. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23976. */
  23977. matricesWeights: Nullable<FloatArray>;
  23978. /**
  23979. * An array extending the number of possible indices
  23980. */
  23981. matricesIndicesExtra: Nullable<FloatArray>;
  23982. /**
  23983. * An array extending the number of possible weights when the number of indices is extended
  23984. */
  23985. matricesWeightsExtra: Nullable<FloatArray>;
  23986. /**
  23987. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23988. */
  23989. indices: Nullable<IndicesArray>;
  23990. /**
  23991. * Uses the passed data array to set the set the values for the specified kind of data
  23992. * @param data a linear array of floating numbers
  23993. * @param kind the type of data that is being set, eg positions, colors etc
  23994. */
  23995. set(data: FloatArray, kind: string): void;
  23996. /**
  23997. * Associates the vertexData to the passed Mesh.
  23998. * Sets it as updatable or not (default `false`)
  23999. * @param mesh the mesh the vertexData is applied to
  24000. * @param updatable when used and having the value true allows new data to update the vertexData
  24001. * @returns the VertexData
  24002. */
  24003. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  24004. /**
  24005. * Associates the vertexData to the passed Geometry.
  24006. * Sets it as updatable or not (default `false`)
  24007. * @param geometry the geometry the vertexData is applied to
  24008. * @param updatable when used and having the value true allows new data to update the vertexData
  24009. * @returns VertexData
  24010. */
  24011. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  24012. /**
  24013. * Updates the associated mesh
  24014. * @param mesh the mesh to be updated
  24015. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  24016. * @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
  24017. * @returns VertexData
  24018. */
  24019. updateMesh(mesh: Mesh): VertexData;
  24020. /**
  24021. * Updates the associated geometry
  24022. * @param geometry the geometry to be updated
  24023. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  24024. * @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
  24025. * @returns VertexData.
  24026. */
  24027. updateGeometry(geometry: Geometry): VertexData;
  24028. private _applyTo;
  24029. private _update;
  24030. /**
  24031. * Transforms each position and each normal of the vertexData according to the passed Matrix
  24032. * @param matrix the transforming matrix
  24033. * @returns the VertexData
  24034. */
  24035. transform(matrix: Matrix): VertexData;
  24036. /**
  24037. * Merges the passed VertexData into the current one
  24038. * @param other the VertexData to be merged into the current one
  24039. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  24040. * @returns the modified VertexData
  24041. */
  24042. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  24043. private _mergeElement;
  24044. private _validate;
  24045. /**
  24046. * Serializes the VertexData
  24047. * @returns a serialized object
  24048. */
  24049. serialize(): any;
  24050. /**
  24051. * Extracts the vertexData from a mesh
  24052. * @param mesh the mesh from which to extract the VertexData
  24053. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  24054. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  24055. * @returns the object VertexData associated to the passed mesh
  24056. */
  24057. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  24058. /**
  24059. * Extracts the vertexData from the geometry
  24060. * @param geometry the geometry from which to extract the VertexData
  24061. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  24062. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  24063. * @returns the object VertexData associated to the passed mesh
  24064. */
  24065. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  24066. private static _ExtractFrom;
  24067. /**
  24068. * Creates the VertexData for a Ribbon
  24069. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  24070. * * pathArray array of paths, each of which an array of successive Vector3
  24071. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  24072. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  24073. * * 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
  24074. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24075. * * 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)
  24076. * * 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)
  24077. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  24078. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  24079. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  24080. * @returns the VertexData of the ribbon
  24081. */
  24082. static CreateRibbon(options: {
  24083. pathArray: Vector3[][];
  24084. closeArray?: boolean;
  24085. closePath?: boolean;
  24086. offset?: number;
  24087. sideOrientation?: number;
  24088. frontUVs?: Vector4;
  24089. backUVs?: Vector4;
  24090. invertUV?: boolean;
  24091. uvs?: Vector2[];
  24092. colors?: Color4[];
  24093. }): VertexData;
  24094. /**
  24095. * Creates the VertexData for a box
  24096. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24097. * * size sets the width, height and depth of the box to the value of size, optional default 1
  24098. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  24099. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  24100. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  24101. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  24102. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  24103. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24104. * * 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)
  24105. * * 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)
  24106. * @returns the VertexData of the box
  24107. */
  24108. static CreateBox(options: {
  24109. size?: number;
  24110. width?: number;
  24111. height?: number;
  24112. depth?: number;
  24113. faceUV?: Vector4[];
  24114. faceColors?: Color4[];
  24115. sideOrientation?: number;
  24116. frontUVs?: Vector4;
  24117. backUVs?: Vector4;
  24118. }): VertexData;
  24119. /**
  24120. * Creates the VertexData for a tiled box
  24121. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24122. * * faceTiles sets the pattern, tile size and number of tiles for a face
  24123. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  24124. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  24125. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24126. * @returns the VertexData of the box
  24127. */
  24128. static CreateTiledBox(options: {
  24129. pattern?: number;
  24130. width?: number;
  24131. height?: number;
  24132. depth?: number;
  24133. tileSize?: number;
  24134. tileWidth?: number;
  24135. tileHeight?: number;
  24136. alignHorizontal?: number;
  24137. alignVertical?: number;
  24138. faceUV?: Vector4[];
  24139. faceColors?: Color4[];
  24140. sideOrientation?: number;
  24141. }): VertexData;
  24142. /**
  24143. * Creates the VertexData for a tiled plane
  24144. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24145. * * pattern a limited pattern arrangement depending on the number
  24146. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  24147. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  24148. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  24149. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24150. * * 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)
  24151. * * 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)
  24152. * @returns the VertexData of the tiled plane
  24153. */
  24154. static CreateTiledPlane(options: {
  24155. pattern?: number;
  24156. tileSize?: number;
  24157. tileWidth?: number;
  24158. tileHeight?: number;
  24159. size?: number;
  24160. width?: number;
  24161. height?: number;
  24162. alignHorizontal?: number;
  24163. alignVertical?: number;
  24164. sideOrientation?: number;
  24165. frontUVs?: Vector4;
  24166. backUVs?: Vector4;
  24167. }): VertexData;
  24168. /**
  24169. * Creates the VertexData for an ellipsoid, defaults to a sphere
  24170. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24171. * * segments sets the number of horizontal strips optional, default 32
  24172. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  24173. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  24174. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  24175. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  24176. * * 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
  24177. * * 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
  24178. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24179. * * 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)
  24180. * * 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)
  24181. * @returns the VertexData of the ellipsoid
  24182. */
  24183. static CreateSphere(options: {
  24184. segments?: number;
  24185. diameter?: number;
  24186. diameterX?: number;
  24187. diameterY?: number;
  24188. diameterZ?: number;
  24189. arc?: number;
  24190. slice?: number;
  24191. sideOrientation?: number;
  24192. frontUVs?: Vector4;
  24193. backUVs?: Vector4;
  24194. }): VertexData;
  24195. /**
  24196. * Creates the VertexData for a cylinder, cone or prism
  24197. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24198. * * height sets the height (y direction) of the cylinder, optional, default 2
  24199. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  24200. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  24201. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  24202. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24203. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  24204. * * 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
  24205. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24206. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24207. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  24208. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  24209. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24210. * * 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)
  24211. * * 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)
  24212. * @returns the VertexData of the cylinder, cone or prism
  24213. */
  24214. static CreateCylinder(options: {
  24215. height?: number;
  24216. diameterTop?: number;
  24217. diameterBottom?: number;
  24218. diameter?: number;
  24219. tessellation?: number;
  24220. subdivisions?: number;
  24221. arc?: number;
  24222. faceColors?: Color4[];
  24223. faceUV?: Vector4[];
  24224. hasRings?: boolean;
  24225. enclose?: boolean;
  24226. sideOrientation?: number;
  24227. frontUVs?: Vector4;
  24228. backUVs?: Vector4;
  24229. }): VertexData;
  24230. /**
  24231. * Creates the VertexData for a torus
  24232. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24233. * * diameter the diameter of the torus, optional default 1
  24234. * * thickness the diameter of the tube forming the torus, optional default 0.5
  24235. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24236. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24237. * * 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)
  24238. * * 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)
  24239. * @returns the VertexData of the torus
  24240. */
  24241. static CreateTorus(options: {
  24242. diameter?: number;
  24243. thickness?: number;
  24244. tessellation?: number;
  24245. sideOrientation?: number;
  24246. frontUVs?: Vector4;
  24247. backUVs?: Vector4;
  24248. }): VertexData;
  24249. /**
  24250. * Creates the VertexData of the LineSystem
  24251. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  24252. * - lines an array of lines, each line being an array of successive Vector3
  24253. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  24254. * @returns the VertexData of the LineSystem
  24255. */
  24256. static CreateLineSystem(options: {
  24257. lines: Vector3[][];
  24258. colors?: Nullable<Color4[][]>;
  24259. }): VertexData;
  24260. /**
  24261. * Create the VertexData for a DashedLines
  24262. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  24263. * - points an array successive Vector3
  24264. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  24265. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  24266. * - dashNb the intended total number of dashes, optional, default 200
  24267. * @returns the VertexData for the DashedLines
  24268. */
  24269. static CreateDashedLines(options: {
  24270. points: Vector3[];
  24271. dashSize?: number;
  24272. gapSize?: number;
  24273. dashNb?: number;
  24274. }): VertexData;
  24275. /**
  24276. * Creates the VertexData for a Ground
  24277. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24278. * - width the width (x direction) of the ground, optional, default 1
  24279. * - height the height (z direction) of the ground, optional, default 1
  24280. * - subdivisions the number of subdivisions per side, optional, default 1
  24281. * @returns the VertexData of the Ground
  24282. */
  24283. static CreateGround(options: {
  24284. width?: number;
  24285. height?: number;
  24286. subdivisions?: number;
  24287. subdivisionsX?: number;
  24288. subdivisionsY?: number;
  24289. }): VertexData;
  24290. /**
  24291. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  24292. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24293. * * xmin the ground minimum X coordinate, optional, default -1
  24294. * * zmin the ground minimum Z coordinate, optional, default -1
  24295. * * xmax the ground maximum X coordinate, optional, default 1
  24296. * * zmax the ground maximum Z coordinate, optional, default 1
  24297. * * 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}
  24298. * * 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}
  24299. * @returns the VertexData of the TiledGround
  24300. */
  24301. static CreateTiledGround(options: {
  24302. xmin: number;
  24303. zmin: number;
  24304. xmax: number;
  24305. zmax: number;
  24306. subdivisions?: {
  24307. w: number;
  24308. h: number;
  24309. };
  24310. precision?: {
  24311. w: number;
  24312. h: number;
  24313. };
  24314. }): VertexData;
  24315. /**
  24316. * Creates the VertexData of the Ground designed from a heightmap
  24317. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  24318. * * width the width (x direction) of the ground
  24319. * * height the height (z direction) of the ground
  24320. * * subdivisions the number of subdivisions per side
  24321. * * minHeight the minimum altitude on the ground, optional, default 0
  24322. * * maxHeight the maximum altitude on the ground, optional default 1
  24323. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  24324. * * buffer the array holding the image color data
  24325. * * bufferWidth the width of image
  24326. * * bufferHeight the height of image
  24327. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  24328. * @returns the VertexData of the Ground designed from a heightmap
  24329. */
  24330. static CreateGroundFromHeightMap(options: {
  24331. width: number;
  24332. height: number;
  24333. subdivisions: number;
  24334. minHeight: number;
  24335. maxHeight: number;
  24336. colorFilter: Color3;
  24337. buffer: Uint8Array;
  24338. bufferWidth: number;
  24339. bufferHeight: number;
  24340. alphaFilter: number;
  24341. }): VertexData;
  24342. /**
  24343. * Creates the VertexData for a Plane
  24344. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  24345. * * size sets the width and height of the plane to the value of size, optional default 1
  24346. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  24347. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  24348. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24349. * * 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)
  24350. * * 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)
  24351. * @returns the VertexData of the box
  24352. */
  24353. static CreatePlane(options: {
  24354. size?: number;
  24355. width?: number;
  24356. height?: number;
  24357. sideOrientation?: number;
  24358. frontUVs?: Vector4;
  24359. backUVs?: Vector4;
  24360. }): VertexData;
  24361. /**
  24362. * Creates the VertexData of the Disc or regular Polygon
  24363. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  24364. * * radius the radius of the disc, optional default 0.5
  24365. * * tessellation the number of polygon sides, optional, default 64
  24366. * * 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
  24367. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24368. * * 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)
  24369. * * 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)
  24370. * @returns the VertexData of the box
  24371. */
  24372. static CreateDisc(options: {
  24373. radius?: number;
  24374. tessellation?: number;
  24375. arc?: number;
  24376. sideOrientation?: number;
  24377. frontUVs?: Vector4;
  24378. backUVs?: Vector4;
  24379. }): VertexData;
  24380. /**
  24381. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  24382. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  24383. * @param polygon a mesh built from polygonTriangulation.build()
  24384. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24385. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24386. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24387. * @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)
  24388. * @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)
  24389. * @returns the VertexData of the Polygon
  24390. */
  24391. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  24392. /**
  24393. * Creates the VertexData of the IcoSphere
  24394. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  24395. * * radius the radius of the IcoSphere, optional default 1
  24396. * * radiusX allows stretching in the x direction, optional, default radius
  24397. * * radiusY allows stretching in the y direction, optional, default radius
  24398. * * radiusZ allows stretching in the z direction, optional, default radius
  24399. * * flat when true creates a flat shaded mesh, optional, default true
  24400. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24401. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24402. * * 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)
  24403. * * 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)
  24404. * @returns the VertexData of the IcoSphere
  24405. */
  24406. static CreateIcoSphere(options: {
  24407. radius?: number;
  24408. radiusX?: number;
  24409. radiusY?: number;
  24410. radiusZ?: number;
  24411. flat?: boolean;
  24412. subdivisions?: number;
  24413. sideOrientation?: number;
  24414. frontUVs?: Vector4;
  24415. backUVs?: Vector4;
  24416. }): VertexData;
  24417. /**
  24418. * Creates the VertexData for a Polyhedron
  24419. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  24420. * * type provided types are:
  24421. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  24422. * * 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)
  24423. * * size the size of the IcoSphere, optional default 1
  24424. * * sizeX allows stretching in the x direction, optional, default size
  24425. * * sizeY allows stretching in the y direction, optional, default size
  24426. * * sizeZ allows stretching in the z direction, optional, default size
  24427. * * 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
  24428. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24429. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24430. * * flat when true creates a flat shaded mesh, optional, default true
  24431. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24432. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24433. * * 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)
  24434. * * 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)
  24435. * @returns the VertexData of the Polyhedron
  24436. */
  24437. static CreatePolyhedron(options: {
  24438. type?: number;
  24439. size?: number;
  24440. sizeX?: number;
  24441. sizeY?: number;
  24442. sizeZ?: number;
  24443. custom?: any;
  24444. faceUV?: Vector4[];
  24445. faceColors?: Color4[];
  24446. flat?: boolean;
  24447. sideOrientation?: number;
  24448. frontUVs?: Vector4;
  24449. backUVs?: Vector4;
  24450. }): VertexData;
  24451. /**
  24452. * Creates the VertexData for a TorusKnot
  24453. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  24454. * * radius the radius of the torus knot, optional, default 2
  24455. * * tube the thickness of the tube, optional, default 0.5
  24456. * * radialSegments the number of sides on each tube segments, optional, default 32
  24457. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  24458. * * p the number of windings around the z axis, optional, default 2
  24459. * * q the number of windings around the x axis, optional, default 3
  24460. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24461. * * 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)
  24462. * * 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)
  24463. * @returns the VertexData of the Torus Knot
  24464. */
  24465. static CreateTorusKnot(options: {
  24466. radius?: number;
  24467. tube?: number;
  24468. radialSegments?: number;
  24469. tubularSegments?: number;
  24470. p?: number;
  24471. q?: number;
  24472. sideOrientation?: number;
  24473. frontUVs?: Vector4;
  24474. backUVs?: Vector4;
  24475. }): VertexData;
  24476. /**
  24477. * Compute normals for given positions and indices
  24478. * @param positions an array of vertex positions, [...., x, y, z, ......]
  24479. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  24480. * @param normals an array of vertex normals, [...., x, y, z, ......]
  24481. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  24482. * * facetNormals : optional array of facet normals (vector3)
  24483. * * facetPositions : optional array of facet positions (vector3)
  24484. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  24485. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  24486. * * bInfo : optional bounding info, required for facetPartitioning computation
  24487. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  24488. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  24489. * * useRightHandedSystem: optional boolean to for right handed system computation
  24490. * * depthSort : optional boolean to enable the facet depth sort computation
  24491. * * distanceTo : optional Vector3 to compute the facet depth from this location
  24492. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  24493. */
  24494. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  24495. facetNormals?: any;
  24496. facetPositions?: any;
  24497. facetPartitioning?: any;
  24498. ratio?: number;
  24499. bInfo?: any;
  24500. bbSize?: Vector3;
  24501. subDiv?: any;
  24502. useRightHandedSystem?: boolean;
  24503. depthSort?: boolean;
  24504. distanceTo?: Vector3;
  24505. depthSortedFacets?: any;
  24506. }): void;
  24507. /** @hidden */
  24508. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  24509. /**
  24510. * Applies VertexData created from the imported parameters to the geometry
  24511. * @param parsedVertexData the parsed data from an imported file
  24512. * @param geometry the geometry to apply the VertexData to
  24513. */
  24514. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  24515. }
  24516. }
  24517. declare module "babylonjs/Meshes/Builders/discBuilder" {
  24518. import { Nullable } from "babylonjs/types";
  24519. import { Scene } from "babylonjs/scene";
  24520. import { Vector4 } from "babylonjs/Maths/math";
  24521. import { Mesh } from "babylonjs/Meshes/mesh";
  24522. /**
  24523. * Class containing static functions to help procedurally build meshes
  24524. */
  24525. export class DiscBuilder {
  24526. /**
  24527. * Creates a plane polygonal mesh. By default, this is a disc
  24528. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24529. * * 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
  24530. * * 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
  24531. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24532. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24533. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24534. * @param name defines the name of the mesh
  24535. * @param options defines the options used to create the mesh
  24536. * @param scene defines the hosting scene
  24537. * @returns the plane polygonal mesh
  24538. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24539. */
  24540. static CreateDisc(name: string, options: {
  24541. radius?: number;
  24542. tessellation?: number;
  24543. arc?: number;
  24544. updatable?: boolean;
  24545. sideOrientation?: number;
  24546. frontUVs?: Vector4;
  24547. backUVs?: Vector4;
  24548. }, scene?: Nullable<Scene>): Mesh;
  24549. }
  24550. }
  24551. declare module "babylonjs/Particles/solidParticleSystem" {
  24552. import { Vector3 } from "babylonjs/Maths/math";
  24553. import { Mesh } from "babylonjs/Meshes/mesh";
  24554. import { Scene, IDisposable } from "babylonjs/scene";
  24555. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  24556. /**
  24557. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24558. *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.
  24559. * The SPS is also a particle system. It provides some methods to manage the particles.
  24560. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24561. *
  24562. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24563. */
  24564. export class SolidParticleSystem implements IDisposable {
  24565. /**
  24566. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24567. * Example : var p = SPS.particles[i];
  24568. */
  24569. particles: SolidParticle[];
  24570. /**
  24571. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24572. */
  24573. nbParticles: number;
  24574. /**
  24575. * If the particles must ever face the camera (default false). Useful for planar particles.
  24576. */
  24577. billboard: boolean;
  24578. /**
  24579. * Recompute normals when adding a shape
  24580. */
  24581. recomputeNormals: boolean;
  24582. /**
  24583. * This a counter ofr your own usage. It's not set by any SPS functions.
  24584. */
  24585. counter: number;
  24586. /**
  24587. * The SPS name. This name is also given to the underlying mesh.
  24588. */
  24589. name: string;
  24590. /**
  24591. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24592. */
  24593. mesh: Mesh;
  24594. /**
  24595. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24596. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24597. */
  24598. vars: any;
  24599. /**
  24600. * This array is populated when the SPS is set as 'pickable'.
  24601. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24602. * Each element of this array is an object `{idx: int, faceId: int}`.
  24603. * `idx` is the picked particle index in the `SPS.particles` array
  24604. * `faceId` is the picked face index counted within this particle.
  24605. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24606. */
  24607. pickedParticles: {
  24608. idx: number;
  24609. faceId: number;
  24610. }[];
  24611. /**
  24612. * This array is populated when `enableDepthSort` is set to true.
  24613. * Each element of this array is an instance of the class DepthSortedParticle.
  24614. */
  24615. depthSortedParticles: DepthSortedParticle[];
  24616. /**
  24617. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24618. * @hidden
  24619. */
  24620. _bSphereOnly: boolean;
  24621. /**
  24622. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24623. * @hidden
  24624. */
  24625. _bSphereRadiusFactor: number;
  24626. private _scene;
  24627. private _positions;
  24628. private _indices;
  24629. private _normals;
  24630. private _colors;
  24631. private _uvs;
  24632. private _indices32;
  24633. private _positions32;
  24634. private _normals32;
  24635. private _fixedNormal32;
  24636. private _colors32;
  24637. private _uvs32;
  24638. private _index;
  24639. private _updatable;
  24640. private _pickable;
  24641. private _isVisibilityBoxLocked;
  24642. private _alwaysVisible;
  24643. private _depthSort;
  24644. private _shapeCounter;
  24645. private _copy;
  24646. private _color;
  24647. private _computeParticleColor;
  24648. private _computeParticleTexture;
  24649. private _computeParticleRotation;
  24650. private _computeParticleVertex;
  24651. private _computeBoundingBox;
  24652. private _depthSortParticles;
  24653. private _camera;
  24654. private _mustUnrotateFixedNormals;
  24655. private _particlesIntersect;
  24656. private _needs32Bits;
  24657. /**
  24658. * Creates a SPS (Solid Particle System) object.
  24659. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24660. * @param scene (Scene) is the scene in which the SPS is added.
  24661. * @param options defines the options of the sps e.g.
  24662. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24663. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24664. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24665. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24666. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24667. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24668. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24669. */
  24670. constructor(name: string, scene: Scene, options?: {
  24671. updatable?: boolean;
  24672. isPickable?: boolean;
  24673. enableDepthSort?: boolean;
  24674. particleIntersection?: boolean;
  24675. boundingSphereOnly?: boolean;
  24676. bSphereRadiusFactor?: number;
  24677. });
  24678. /**
  24679. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24680. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24681. * @returns the created mesh
  24682. */
  24683. buildMesh(): Mesh;
  24684. /**
  24685. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24686. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24687. * Thus the particles generated from `digest()` have their property `position` set yet.
  24688. * @param mesh ( Mesh ) is the mesh to be digested
  24689. * @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
  24690. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24691. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24692. * @returns the current SPS
  24693. */
  24694. digest(mesh: Mesh, options?: {
  24695. facetNb?: number;
  24696. number?: number;
  24697. delta?: number;
  24698. }): SolidParticleSystem;
  24699. private _unrotateFixedNormals;
  24700. private _resetCopy;
  24701. private _meshBuilder;
  24702. private _posToShape;
  24703. private _uvsToShapeUV;
  24704. private _addParticle;
  24705. /**
  24706. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24707. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24708. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24709. * @param nb (positive integer) the number of particles to be created from this model
  24710. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24711. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24712. * @returns the number of shapes in the system
  24713. */
  24714. addShape(mesh: Mesh, nb: number, options?: {
  24715. positionFunction?: any;
  24716. vertexFunction?: any;
  24717. }): number;
  24718. private _rebuildParticle;
  24719. /**
  24720. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24721. * @returns the SPS.
  24722. */
  24723. rebuildMesh(): SolidParticleSystem;
  24724. /**
  24725. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24726. * This method calls `updateParticle()` for each particle of the SPS.
  24727. * For an animated SPS, it is usually called within the render loop.
  24728. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24729. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24730. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24731. * @returns the SPS.
  24732. */
  24733. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24734. /**
  24735. * Disposes the SPS.
  24736. */
  24737. dispose(): void;
  24738. /**
  24739. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24740. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24741. * @returns the SPS.
  24742. */
  24743. refreshVisibleSize(): SolidParticleSystem;
  24744. /**
  24745. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24746. * @param size the size (float) of the visibility box
  24747. * note : this doesn't lock the SPS mesh bounding box.
  24748. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24749. */
  24750. setVisibilityBox(size: number): void;
  24751. /**
  24752. * Gets whether the SPS as always visible or not
  24753. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24754. */
  24755. /**
  24756. * Sets the SPS as always visible or not
  24757. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24758. */
  24759. isAlwaysVisible: boolean;
  24760. /**
  24761. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24762. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24763. */
  24764. /**
  24765. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24766. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24767. */
  24768. isVisibilityBoxLocked: boolean;
  24769. /**
  24770. * Tells to `setParticles()` to compute the particle rotations or not.
  24771. * Default value : true. The SPS is faster when it's set to false.
  24772. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24773. */
  24774. /**
  24775. * Gets if `setParticles()` computes the particle rotations or not.
  24776. * Default value : true. The SPS is faster when it's set to false.
  24777. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24778. */
  24779. computeParticleRotation: boolean;
  24780. /**
  24781. * Tells to `setParticles()` to compute the particle colors or not.
  24782. * Default value : true. The SPS is faster when it's set to false.
  24783. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24784. */
  24785. /**
  24786. * Gets if `setParticles()` computes the particle colors or not.
  24787. * Default value : true. The SPS is faster when it's set to false.
  24788. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24789. */
  24790. computeParticleColor: boolean;
  24791. /**
  24792. * Gets if `setParticles()` computes the particle textures or not.
  24793. * Default value : true. The SPS is faster when it's set to false.
  24794. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24795. */
  24796. computeParticleTexture: boolean;
  24797. /**
  24798. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24799. * Default value : false. The SPS is faster when it's set to false.
  24800. * Note : the particle custom vertex positions aren't stored values.
  24801. */
  24802. /**
  24803. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24804. * Default value : false. The SPS is faster when it's set to false.
  24805. * Note : the particle custom vertex positions aren't stored values.
  24806. */
  24807. computeParticleVertex: boolean;
  24808. /**
  24809. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24810. */
  24811. /**
  24812. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24813. */
  24814. computeBoundingBox: boolean;
  24815. /**
  24816. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24817. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24818. * Default : `true`
  24819. */
  24820. /**
  24821. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24822. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24823. * Default : `true`
  24824. */
  24825. depthSortParticles: boolean;
  24826. /**
  24827. * This function does nothing. It may be overwritten to set all the particle first values.
  24828. * The SPS doesn't call this function, you may have to call it by your own.
  24829. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24830. */
  24831. initParticles(): void;
  24832. /**
  24833. * This function does nothing. It may be overwritten to recycle a particle.
  24834. * The SPS doesn't call this function, you may have to call it by your own.
  24835. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24836. * @param particle The particle to recycle
  24837. * @returns the recycled particle
  24838. */
  24839. recycleParticle(particle: SolidParticle): SolidParticle;
  24840. /**
  24841. * Updates a particle : this function should be overwritten by the user.
  24842. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24843. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24844. * @example : just set a particle position or velocity and recycle conditions
  24845. * @param particle The particle to update
  24846. * @returns the updated particle
  24847. */
  24848. updateParticle(particle: SolidParticle): SolidParticle;
  24849. /**
  24850. * Updates a vertex of a particle : it can be overwritten by the user.
  24851. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24852. * @param particle the current particle
  24853. * @param vertex the current index of the current particle
  24854. * @param pt the index of the current vertex in the particle shape
  24855. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24856. * @example : just set a vertex particle position
  24857. * @returns the updated vertex
  24858. */
  24859. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24860. /**
  24861. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24862. * This does nothing and may be overwritten by the user.
  24863. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24864. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24865. * @param update the boolean update value actually passed to setParticles()
  24866. */
  24867. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24868. /**
  24869. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24870. * This will be passed three parameters.
  24871. * This does nothing and may be overwritten by the user.
  24872. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24873. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24874. * @param update the boolean update value actually passed to setParticles()
  24875. */
  24876. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24877. }
  24878. }
  24879. declare module "babylonjs/Particles/solidParticle" {
  24880. import { Nullable } from "babylonjs/types";
  24881. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24882. import { Mesh } from "babylonjs/Meshes/mesh";
  24883. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24884. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24885. /**
  24886. * Represents one particle of a solid particle system.
  24887. */
  24888. export class SolidParticle {
  24889. /**
  24890. * particle global index
  24891. */
  24892. idx: number;
  24893. /**
  24894. * The color of the particle
  24895. */
  24896. color: Nullable<Color4>;
  24897. /**
  24898. * The world space position of the particle.
  24899. */
  24900. position: Vector3;
  24901. /**
  24902. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24903. */
  24904. rotation: Vector3;
  24905. /**
  24906. * The world space rotation quaternion of the particle.
  24907. */
  24908. rotationQuaternion: Nullable<Quaternion>;
  24909. /**
  24910. * The scaling of the particle.
  24911. */
  24912. scaling: Vector3;
  24913. /**
  24914. * The uvs of the particle.
  24915. */
  24916. uvs: Vector4;
  24917. /**
  24918. * The current speed of the particle.
  24919. */
  24920. velocity: Vector3;
  24921. /**
  24922. * The pivot point in the particle local space.
  24923. */
  24924. pivot: Vector3;
  24925. /**
  24926. * Must the particle be translated from its pivot point in its local space ?
  24927. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24928. * Default : false
  24929. */
  24930. translateFromPivot: boolean;
  24931. /**
  24932. * Is the particle active or not ?
  24933. */
  24934. alive: boolean;
  24935. /**
  24936. * Is the particle visible or not ?
  24937. */
  24938. isVisible: boolean;
  24939. /**
  24940. * Index of this particle in the global "positions" array (Internal use)
  24941. * @hidden
  24942. */
  24943. _pos: number;
  24944. /**
  24945. * @hidden Index of this particle in the global "indices" array (Internal use)
  24946. */
  24947. _ind: number;
  24948. /**
  24949. * @hidden ModelShape of this particle (Internal use)
  24950. */
  24951. _model: ModelShape;
  24952. /**
  24953. * ModelShape id of this particle
  24954. */
  24955. shapeId: number;
  24956. /**
  24957. * Index of the particle in its shape id (Internal use)
  24958. */
  24959. idxInShape: number;
  24960. /**
  24961. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24962. */
  24963. _modelBoundingInfo: BoundingInfo;
  24964. /**
  24965. * @hidden Particle BoundingInfo object (Internal use)
  24966. */
  24967. _boundingInfo: BoundingInfo;
  24968. /**
  24969. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24970. */
  24971. _sps: SolidParticleSystem;
  24972. /**
  24973. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24974. */
  24975. _stillInvisible: boolean;
  24976. /**
  24977. * @hidden Last computed particle rotation matrix
  24978. */
  24979. _rotationMatrix: number[];
  24980. /**
  24981. * Parent particle Id, if any.
  24982. * Default null.
  24983. */
  24984. parentId: Nullable<number>;
  24985. /**
  24986. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24987. * The possible values are :
  24988. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24989. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24990. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24991. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24992. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24993. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24994. * */
  24995. cullingStrategy: number;
  24996. /**
  24997. * @hidden Internal global position in the SPS.
  24998. */
  24999. _globalPosition: Vector3;
  25000. /**
  25001. * Creates a Solid Particle object.
  25002. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25003. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25004. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25005. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25006. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25007. * @param shapeId (integer) is the model shape identifier in the SPS.
  25008. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25009. * @param sps defines the sps it is associated to
  25010. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25011. */
  25012. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25013. /**
  25014. * Legacy support, changed scale to scaling
  25015. */
  25016. /**
  25017. * Legacy support, changed scale to scaling
  25018. */
  25019. scale: Vector3;
  25020. /**
  25021. * Legacy support, changed quaternion to rotationQuaternion
  25022. */
  25023. /**
  25024. * Legacy support, changed quaternion to rotationQuaternion
  25025. */
  25026. quaternion: Nullable<Quaternion>;
  25027. /**
  25028. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25029. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25030. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25031. * @returns true if it intersects
  25032. */
  25033. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25034. /**
  25035. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25036. * A particle is in the frustum if its bounding box intersects the frustum
  25037. * @param frustumPlanes defines the frustum to test
  25038. * @returns true if the particle is in the frustum planes
  25039. */
  25040. isInFrustum(frustumPlanes: Plane[]): boolean;
  25041. /**
  25042. * get the rotation matrix of the particle
  25043. * @hidden
  25044. */
  25045. getRotationMatrix(m: Matrix): void;
  25046. }
  25047. /**
  25048. * Represents the shape of the model used by one particle of a solid particle system.
  25049. * SPS internal tool, don't use it manually.
  25050. */
  25051. export class ModelShape {
  25052. /**
  25053. * The shape id
  25054. * @hidden
  25055. */
  25056. shapeID: number;
  25057. /**
  25058. * flat array of model positions (internal use)
  25059. * @hidden
  25060. */
  25061. _shape: Vector3[];
  25062. /**
  25063. * flat array of model UVs (internal use)
  25064. * @hidden
  25065. */
  25066. _shapeUV: number[];
  25067. /**
  25068. * length of the shape in the model indices array (internal use)
  25069. * @hidden
  25070. */
  25071. _indicesLength: number;
  25072. /**
  25073. * Custom position function (internal use)
  25074. * @hidden
  25075. */
  25076. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25077. /**
  25078. * Custom vertex function (internal use)
  25079. * @hidden
  25080. */
  25081. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25082. /**
  25083. * 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.
  25084. * SPS internal tool, don't use it manually.
  25085. * @hidden
  25086. */
  25087. 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>);
  25088. }
  25089. /**
  25090. * Represents a Depth Sorted Particle in the solid particle system.
  25091. */
  25092. export class DepthSortedParticle {
  25093. /**
  25094. * Index of the particle in the "indices" array
  25095. */
  25096. ind: number;
  25097. /**
  25098. * Length of the particle shape in the "indices" array
  25099. */
  25100. indicesLength: number;
  25101. /**
  25102. * Squared distance from the particle to the camera
  25103. */
  25104. sqDistance: number;
  25105. }
  25106. }
  25107. declare module "babylonjs/Collisions/meshCollisionData" {
  25108. import { Collider } from "babylonjs/Collisions/collider";
  25109. import { Vector3 } from "babylonjs/Maths/math";
  25110. import { Nullable } from "babylonjs/types";
  25111. import { Observer } from "babylonjs/Misc/observable";
  25112. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25113. /**
  25114. * @hidden
  25115. */
  25116. export class _MeshCollisionData {
  25117. _checkCollisions: boolean;
  25118. _collisionMask: number;
  25119. _collisionGroup: number;
  25120. _collider: Nullable<Collider>;
  25121. _oldPositionForCollisions: Vector3;
  25122. _diffPositionForCollisions: Vector3;
  25123. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25124. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25125. }
  25126. }
  25127. declare module "babylonjs/Meshes/abstractMesh" {
  25128. import { Observable } from "babylonjs/Misc/observable";
  25129. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  25130. import { Camera } from "babylonjs/Cameras/camera";
  25131. import { Scene, IDisposable } from "babylonjs/scene";
  25132. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  25133. import { Node } from "babylonjs/node";
  25134. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  25135. import { TransformNode } from "babylonjs/Meshes/transformNode";
  25136. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25137. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  25138. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25139. import { Material } from "babylonjs/Materials/material";
  25140. import { Light } from "babylonjs/Lights/light";
  25141. import { Skeleton } from "babylonjs/Bones/skeleton";
  25142. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  25143. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  25144. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25145. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  25146. import { Ray } from "babylonjs/Culling/ray";
  25147. import { Collider } from "babylonjs/Collisions/collider";
  25148. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  25149. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  25150. /** @hidden */
  25151. class _FacetDataStorage {
  25152. facetPositions: Vector3[];
  25153. facetNormals: Vector3[];
  25154. facetPartitioning: number[][];
  25155. facetNb: number;
  25156. partitioningSubdivisions: number;
  25157. partitioningBBoxRatio: number;
  25158. facetDataEnabled: boolean;
  25159. facetParameters: any;
  25160. bbSize: Vector3;
  25161. subDiv: {
  25162. max: number;
  25163. X: number;
  25164. Y: number;
  25165. Z: number;
  25166. };
  25167. facetDepthSort: boolean;
  25168. facetDepthSortEnabled: boolean;
  25169. depthSortedIndices: IndicesArray;
  25170. depthSortedFacets: {
  25171. ind: number;
  25172. sqDistance: number;
  25173. }[];
  25174. facetDepthSortFunction: (f1: {
  25175. ind: number;
  25176. sqDistance: number;
  25177. }, f2: {
  25178. ind: number;
  25179. sqDistance: number;
  25180. }) => number;
  25181. facetDepthSortFrom: Vector3;
  25182. facetDepthSortOrigin: Vector3;
  25183. invertedMatrix: Matrix;
  25184. }
  25185. /**
  25186. * @hidden
  25187. **/
  25188. class _InternalAbstractMeshDataInfo {
  25189. _hasVertexAlpha: boolean;
  25190. _useVertexColors: boolean;
  25191. _numBoneInfluencers: number;
  25192. _applyFog: boolean;
  25193. _receiveShadows: boolean;
  25194. _facetData: _FacetDataStorage;
  25195. _visibility: number;
  25196. _skeleton: Nullable<Skeleton>;
  25197. _layerMask: number;
  25198. _computeBonesUsingShaders: boolean;
  25199. _isActive: boolean;
  25200. _onlyForInstances: boolean;
  25201. _isActiveIntermediate: boolean;
  25202. _onlyForInstancesIntermediate: boolean;
  25203. }
  25204. /**
  25205. * Class used to store all common mesh properties
  25206. */
  25207. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25208. /** No occlusion */
  25209. static OCCLUSION_TYPE_NONE: number;
  25210. /** Occlusion set to optimisitic */
  25211. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25212. /** Occlusion set to strict */
  25213. static OCCLUSION_TYPE_STRICT: number;
  25214. /** Use an accurante occlusion algorithm */
  25215. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25216. /** Use a conservative occlusion algorithm */
  25217. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25218. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25219. * Test order :
  25220. * Is the bounding sphere outside the frustum ?
  25221. * If not, are the bounding box vertices outside the frustum ?
  25222. * It not, then the cullable object is in the frustum.
  25223. */
  25224. static readonly CULLINGSTRATEGY_STANDARD: number;
  25225. /** Culling strategy : Bounding Sphere Only.
  25226. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25227. * It's also less accurate than the standard because some not visible objects can still be selected.
  25228. * Test : is the bounding sphere outside the frustum ?
  25229. * If not, then the cullable object is in the frustum.
  25230. */
  25231. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25232. /** Culling strategy : Optimistic Inclusion.
  25233. * This in an inclusion test first, then the standard exclusion test.
  25234. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25235. * 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.
  25236. * Anyway, it's as accurate as the standard strategy.
  25237. * Test :
  25238. * Is the cullable object bounding sphere center in the frustum ?
  25239. * If not, apply the default culling strategy.
  25240. */
  25241. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25242. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25243. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25244. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25245. * 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.
  25246. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25247. * Test :
  25248. * Is the cullable object bounding sphere center in the frustum ?
  25249. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25250. */
  25251. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25252. /**
  25253. * No billboard
  25254. */
  25255. static readonly BILLBOARDMODE_NONE: number;
  25256. /** Billboard on X axis */
  25257. static readonly BILLBOARDMODE_X: number;
  25258. /** Billboard on Y axis */
  25259. static readonly BILLBOARDMODE_Y: number;
  25260. /** Billboard on Z axis */
  25261. static readonly BILLBOARDMODE_Z: number;
  25262. /** Billboard on all axes */
  25263. static readonly BILLBOARDMODE_ALL: number;
  25264. /** @hidden */
  25265. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25266. /**
  25267. * The culling strategy to use to check whether the mesh must be rendered or not.
  25268. * This value can be changed at any time and will be used on the next render mesh selection.
  25269. * The possible values are :
  25270. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25271. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25272. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25273. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25274. * Please read each static variable documentation to get details about the culling process.
  25275. * */
  25276. cullingStrategy: number;
  25277. /**
  25278. * Gets the number of facets in the mesh
  25279. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25280. */
  25281. readonly facetNb: number;
  25282. /**
  25283. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25284. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25285. */
  25286. partitioningSubdivisions: number;
  25287. /**
  25288. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25289. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25290. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25291. */
  25292. partitioningBBoxRatio: number;
  25293. /**
  25294. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25295. * Works only for updatable meshes.
  25296. * Doesn't work with multi-materials
  25297. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25298. */
  25299. mustDepthSortFacets: boolean;
  25300. /**
  25301. * The location (Vector3) where the facet depth sort must be computed from.
  25302. * By default, the active camera position.
  25303. * Used only when facet depth sort is enabled
  25304. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25305. */
  25306. facetDepthSortFrom: Vector3;
  25307. /**
  25308. * gets a boolean indicating if facetData is enabled
  25309. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25310. */
  25311. readonly isFacetDataEnabled: boolean;
  25312. /** @hidden */
  25313. _updateNonUniformScalingState(value: boolean): boolean;
  25314. /**
  25315. * An event triggered when this mesh collides with another one
  25316. */
  25317. onCollideObservable: Observable<AbstractMesh>;
  25318. /** Set a function to call when this mesh collides with another one */
  25319. onCollide: () => void;
  25320. /**
  25321. * An event triggered when the collision's position changes
  25322. */
  25323. onCollisionPositionChangeObservable: Observable<Vector3>;
  25324. /** Set a function to call when the collision's position changes */
  25325. onCollisionPositionChange: () => void;
  25326. /**
  25327. * An event triggered when material is changed
  25328. */
  25329. onMaterialChangedObservable: Observable<AbstractMesh>;
  25330. /**
  25331. * Gets or sets the orientation for POV movement & rotation
  25332. */
  25333. definedFacingForward: boolean;
  25334. /** @hidden */
  25335. _occlusionQuery: Nullable<WebGLQuery>;
  25336. /** @hidden */
  25337. _renderingGroup: Nullable<RenderingGroup>;
  25338. /**
  25339. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25340. */
  25341. /**
  25342. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25343. */
  25344. visibility: number;
  25345. /** Gets or sets the alpha index used to sort transparent meshes
  25346. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25347. */
  25348. alphaIndex: number;
  25349. /**
  25350. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25351. */
  25352. isVisible: boolean;
  25353. /**
  25354. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25355. */
  25356. isPickable: boolean;
  25357. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25358. showSubMeshesBoundingBox: boolean;
  25359. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25360. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25361. */
  25362. isBlocker: boolean;
  25363. /**
  25364. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25365. */
  25366. enablePointerMoveEvents: boolean;
  25367. /**
  25368. * Specifies the rendering group id for this mesh (0 by default)
  25369. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25370. */
  25371. renderingGroupId: number;
  25372. private _material;
  25373. /** Gets or sets current material */
  25374. material: Nullable<Material>;
  25375. /**
  25376. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25377. * @see http://doc.babylonjs.com/babylon101/shadows
  25378. */
  25379. receiveShadows: boolean;
  25380. /** Defines color to use when rendering outline */
  25381. outlineColor: Color3;
  25382. /** Define width to use when rendering outline */
  25383. outlineWidth: number;
  25384. /** Defines color to use when rendering overlay */
  25385. overlayColor: Color3;
  25386. /** Defines alpha to use when rendering overlay */
  25387. overlayAlpha: number;
  25388. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25389. hasVertexAlpha: boolean;
  25390. /** 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) */
  25391. useVertexColors: boolean;
  25392. /**
  25393. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25394. */
  25395. computeBonesUsingShaders: boolean;
  25396. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25397. numBoneInfluencers: number;
  25398. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25399. applyFog: boolean;
  25400. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25401. useOctreeForRenderingSelection: boolean;
  25402. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25403. useOctreeForPicking: boolean;
  25404. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25405. useOctreeForCollisions: boolean;
  25406. /**
  25407. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25408. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25409. */
  25410. layerMask: number;
  25411. /**
  25412. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25413. */
  25414. alwaysSelectAsActiveMesh: boolean;
  25415. /**
  25416. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25417. */
  25418. doNotSyncBoundingInfo: boolean;
  25419. /**
  25420. * Gets or sets the current action manager
  25421. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25422. */
  25423. actionManager: Nullable<AbstractActionManager>;
  25424. private _meshCollisionData;
  25425. /**
  25426. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25427. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25428. */
  25429. ellipsoid: Vector3;
  25430. /**
  25431. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25432. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25433. */
  25434. ellipsoidOffset: Vector3;
  25435. /**
  25436. * Gets or sets a collision mask used to mask collisions (default is -1).
  25437. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25438. */
  25439. collisionMask: number;
  25440. /**
  25441. * Gets or sets the current collision group mask (-1 by default).
  25442. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25443. */
  25444. collisionGroup: number;
  25445. /**
  25446. * Defines edge width used when edgesRenderer is enabled
  25447. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25448. */
  25449. edgesWidth: number;
  25450. /**
  25451. * Defines edge color used when edgesRenderer is enabled
  25452. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25453. */
  25454. edgesColor: Color4;
  25455. /** @hidden */
  25456. _edgesRenderer: Nullable<IEdgesRenderer>;
  25457. /** @hidden */
  25458. _masterMesh: Nullable<AbstractMesh>;
  25459. /** @hidden */
  25460. _boundingInfo: Nullable<BoundingInfo>;
  25461. /** @hidden */
  25462. _renderId: number;
  25463. /**
  25464. * Gets or sets the list of subMeshes
  25465. * @see http://doc.babylonjs.com/how_to/multi_materials
  25466. */
  25467. subMeshes: SubMesh[];
  25468. /** @hidden */
  25469. _intersectionsInProgress: AbstractMesh[];
  25470. /** @hidden */
  25471. _unIndexed: boolean;
  25472. /** @hidden */
  25473. _lightSources: Light[];
  25474. /** Gets the list of lights affecting that mesh */
  25475. readonly lightSources: Light[];
  25476. /** @hidden */
  25477. readonly _positions: Nullable<Vector3[]>;
  25478. /** @hidden */
  25479. _waitingData: {
  25480. lods: Nullable<any>;
  25481. actions: Nullable<any>;
  25482. freezeWorldMatrix: Nullable<boolean>;
  25483. };
  25484. /** @hidden */
  25485. _bonesTransformMatrices: Nullable<Float32Array>;
  25486. /** @hidden */
  25487. _transformMatrixTexture: Nullable<RawTexture>;
  25488. /**
  25489. * Gets or sets a skeleton to apply skining transformations
  25490. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25491. */
  25492. skeleton: Nullable<Skeleton>;
  25493. /**
  25494. * An event triggered when the mesh is rebuilt.
  25495. */
  25496. onRebuildObservable: Observable<AbstractMesh>;
  25497. /**
  25498. * Creates a new AbstractMesh
  25499. * @param name defines the name of the mesh
  25500. * @param scene defines the hosting scene
  25501. */
  25502. constructor(name: string, scene?: Nullable<Scene>);
  25503. /**
  25504. * Returns the string "AbstractMesh"
  25505. * @returns "AbstractMesh"
  25506. */
  25507. getClassName(): string;
  25508. /**
  25509. * Gets a string representation of the current mesh
  25510. * @param fullDetails defines a boolean indicating if full details must be included
  25511. * @returns a string representation of the current mesh
  25512. */
  25513. toString(fullDetails?: boolean): string;
  25514. /**
  25515. * @hidden
  25516. */
  25517. protected _getEffectiveParent(): Nullable<Node>;
  25518. /** @hidden */
  25519. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25520. /** @hidden */
  25521. _rebuild(): void;
  25522. /** @hidden */
  25523. _resyncLightSources(): void;
  25524. /** @hidden */
  25525. _resyncLighSource(light: Light): void;
  25526. /** @hidden */
  25527. _unBindEffect(): void;
  25528. /** @hidden */
  25529. _removeLightSource(light: Light): void;
  25530. private _markSubMeshesAsDirty;
  25531. /** @hidden */
  25532. _markSubMeshesAsLightDirty(): void;
  25533. /** @hidden */
  25534. _markSubMeshesAsAttributesDirty(): void;
  25535. /** @hidden */
  25536. _markSubMeshesAsMiscDirty(): void;
  25537. /**
  25538. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25539. */
  25540. scaling: Vector3;
  25541. /**
  25542. * Returns true if the mesh is blocked. Implemented by child classes
  25543. */
  25544. readonly isBlocked: boolean;
  25545. /**
  25546. * Returns the mesh itself by default. Implemented by child classes
  25547. * @param camera defines the camera to use to pick the right LOD level
  25548. * @returns the currentAbstractMesh
  25549. */
  25550. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25551. /**
  25552. * Returns 0 by default. Implemented by child classes
  25553. * @returns an integer
  25554. */
  25555. getTotalVertices(): number;
  25556. /**
  25557. * Returns a positive integer : the total number of indices in this mesh geometry.
  25558. * @returns the numner of indices or zero if the mesh has no geometry.
  25559. */
  25560. getTotalIndices(): number;
  25561. /**
  25562. * Returns null by default. Implemented by child classes
  25563. * @returns null
  25564. */
  25565. getIndices(): Nullable<IndicesArray>;
  25566. /**
  25567. * Returns the array of the requested vertex data kind. Implemented by child classes
  25568. * @param kind defines the vertex data kind to use
  25569. * @returns null
  25570. */
  25571. getVerticesData(kind: string): Nullable<FloatArray>;
  25572. /**
  25573. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25574. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25575. * Note that a new underlying VertexBuffer object is created each call.
  25576. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25577. * @param kind defines vertex data kind:
  25578. * * VertexBuffer.PositionKind
  25579. * * VertexBuffer.UVKind
  25580. * * VertexBuffer.UV2Kind
  25581. * * VertexBuffer.UV3Kind
  25582. * * VertexBuffer.UV4Kind
  25583. * * VertexBuffer.UV5Kind
  25584. * * VertexBuffer.UV6Kind
  25585. * * VertexBuffer.ColorKind
  25586. * * VertexBuffer.MatricesIndicesKind
  25587. * * VertexBuffer.MatricesIndicesExtraKind
  25588. * * VertexBuffer.MatricesWeightsKind
  25589. * * VertexBuffer.MatricesWeightsExtraKind
  25590. * @param data defines the data source
  25591. * @param updatable defines if the data must be flagged as updatable (or static)
  25592. * @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
  25593. * @returns the current mesh
  25594. */
  25595. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25596. /**
  25597. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25598. * If the mesh has no geometry, it is simply returned as it is.
  25599. * @param kind defines vertex data kind:
  25600. * * VertexBuffer.PositionKind
  25601. * * VertexBuffer.UVKind
  25602. * * VertexBuffer.UV2Kind
  25603. * * VertexBuffer.UV3Kind
  25604. * * VertexBuffer.UV4Kind
  25605. * * VertexBuffer.UV5Kind
  25606. * * VertexBuffer.UV6Kind
  25607. * * VertexBuffer.ColorKind
  25608. * * VertexBuffer.MatricesIndicesKind
  25609. * * VertexBuffer.MatricesIndicesExtraKind
  25610. * * VertexBuffer.MatricesWeightsKind
  25611. * * VertexBuffer.MatricesWeightsExtraKind
  25612. * @param data defines the data source
  25613. * @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
  25614. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25615. * @returns the current mesh
  25616. */
  25617. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25618. /**
  25619. * Sets the mesh indices,
  25620. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25621. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25622. * @param totalVertices Defines the total number of vertices
  25623. * @returns the current mesh
  25624. */
  25625. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25626. /**
  25627. * Gets a boolean indicating if specific vertex data is present
  25628. * @param kind defines the vertex data kind to use
  25629. * @returns true is data kind is present
  25630. */
  25631. isVerticesDataPresent(kind: string): boolean;
  25632. /**
  25633. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  25634. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  25635. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  25636. * @returns a BoundingInfo
  25637. */
  25638. getBoundingInfo(): BoundingInfo;
  25639. /**
  25640. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25641. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25642. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25643. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  25644. * @returns the current mesh
  25645. */
  25646. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  25647. /**
  25648. * Overwrite the current bounding info
  25649. * @param boundingInfo defines the new bounding info
  25650. * @returns the current mesh
  25651. */
  25652. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25653. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25654. readonly useBones: boolean;
  25655. /** @hidden */
  25656. _preActivate(): void;
  25657. /** @hidden */
  25658. _preActivateForIntermediateRendering(renderId: number): void;
  25659. /** @hidden */
  25660. _activate(renderId: number, intermediateRendering: boolean): boolean;
  25661. /** @hidden */
  25662. _postActivate(): void;
  25663. /** @hidden */
  25664. _freeze(): void;
  25665. /** @hidden */
  25666. _unFreeze(): void;
  25667. /**
  25668. * Gets the current world matrix
  25669. * @returns a Matrix
  25670. */
  25671. getWorldMatrix(): Matrix;
  25672. /** @hidden */
  25673. _getWorldMatrixDeterminant(): number;
  25674. /**
  25675. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25676. */
  25677. readonly isAnInstance: boolean;
  25678. /**
  25679. * Perform relative position change from the point of view of behind the front of the mesh.
  25680. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25681. * Supports definition of mesh facing forward or backward
  25682. * @param amountRight defines the distance on the right axis
  25683. * @param amountUp defines the distance on the up axis
  25684. * @param amountForward defines the distance on the forward axis
  25685. * @returns the current mesh
  25686. */
  25687. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25688. /**
  25689. * Calculate relative position change from the point of view of behind the front of the mesh.
  25690. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25691. * Supports definition of mesh facing forward or backward
  25692. * @param amountRight defines the distance on the right axis
  25693. * @param amountUp defines the distance on the up axis
  25694. * @param amountForward defines the distance on the forward axis
  25695. * @returns the new displacement vector
  25696. */
  25697. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25698. /**
  25699. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25700. * Supports definition of mesh facing forward or backward
  25701. * @param flipBack defines the flip
  25702. * @param twirlClockwise defines the twirl
  25703. * @param tiltRight defines the tilt
  25704. * @returns the current mesh
  25705. */
  25706. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25707. /**
  25708. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25709. * Supports definition of mesh facing forward or backward.
  25710. * @param flipBack defines the flip
  25711. * @param twirlClockwise defines the twirl
  25712. * @param tiltRight defines the tilt
  25713. * @returns the new rotation vector
  25714. */
  25715. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25716. /**
  25717. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25718. * This means the mesh underlying bounding box and sphere are recomputed.
  25719. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25720. * @returns the current mesh
  25721. */
  25722. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25723. /** @hidden */
  25724. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25725. /** @hidden */
  25726. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25727. /** @hidden */
  25728. _updateBoundingInfo(): AbstractMesh;
  25729. /** @hidden */
  25730. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25731. /** @hidden */
  25732. protected _afterComputeWorldMatrix(): void;
  25733. /** @hidden */
  25734. readonly _effectiveMesh: AbstractMesh;
  25735. /**
  25736. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25737. * A mesh is in the frustum if its bounding box intersects the frustum
  25738. * @param frustumPlanes defines the frustum to test
  25739. * @returns true if the mesh is in the frustum planes
  25740. */
  25741. isInFrustum(frustumPlanes: Plane[]): boolean;
  25742. /**
  25743. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25744. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25745. * @param frustumPlanes defines the frustum to test
  25746. * @returns true if the mesh is completely in the frustum planes
  25747. */
  25748. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25749. /**
  25750. * True if the mesh intersects another mesh or a SolidParticle object
  25751. * @param mesh defines a target mesh or SolidParticle to test
  25752. * @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)
  25753. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25754. * @returns true if there is an intersection
  25755. */
  25756. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25757. /**
  25758. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25759. * @param point defines the point to test
  25760. * @returns true if there is an intersection
  25761. */
  25762. intersectsPoint(point: Vector3): boolean;
  25763. /**
  25764. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25765. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25766. */
  25767. checkCollisions: boolean;
  25768. /**
  25769. * Gets Collider object used to compute collisions (not physics)
  25770. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25771. */
  25772. readonly collider: Nullable<Collider>;
  25773. /**
  25774. * Move the mesh using collision engine
  25775. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25776. * @param displacement defines the requested displacement vector
  25777. * @returns the current mesh
  25778. */
  25779. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25780. private _onCollisionPositionChange;
  25781. /** @hidden */
  25782. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25783. /** @hidden */
  25784. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25785. /** @hidden */
  25786. _checkCollision(collider: Collider): AbstractMesh;
  25787. /** @hidden */
  25788. _generatePointsArray(): boolean;
  25789. /**
  25790. * Checks if the passed Ray intersects with the mesh
  25791. * @param ray defines the ray to use
  25792. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25793. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25794. * @returns the picking info
  25795. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25796. */
  25797. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25798. /**
  25799. * Clones the current mesh
  25800. * @param name defines the mesh name
  25801. * @param newParent defines the new mesh parent
  25802. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25803. * @returns the new mesh
  25804. */
  25805. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25806. /**
  25807. * Disposes all the submeshes of the current meshnp
  25808. * @returns the current mesh
  25809. */
  25810. releaseSubMeshes(): AbstractMesh;
  25811. /**
  25812. * Releases resources associated with this abstract mesh.
  25813. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25814. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25815. */
  25816. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25817. /**
  25818. * Adds the passed mesh as a child to the current mesh
  25819. * @param mesh defines the child mesh
  25820. * @returns the current mesh
  25821. */
  25822. addChild(mesh: AbstractMesh): AbstractMesh;
  25823. /**
  25824. * Removes the passed mesh from the current mesh children list
  25825. * @param mesh defines the child mesh
  25826. * @returns the current mesh
  25827. */
  25828. removeChild(mesh: AbstractMesh): AbstractMesh;
  25829. /** @hidden */
  25830. private _initFacetData;
  25831. /**
  25832. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25833. * This method can be called within the render loop.
  25834. * 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
  25835. * @returns the current mesh
  25836. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25837. */
  25838. updateFacetData(): AbstractMesh;
  25839. /**
  25840. * Returns the facetLocalNormals array.
  25841. * The normals are expressed in the mesh local spac
  25842. * @returns an array of Vector3
  25843. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25844. */
  25845. getFacetLocalNormals(): Vector3[];
  25846. /**
  25847. * Returns the facetLocalPositions array.
  25848. * The facet positions are expressed in the mesh local space
  25849. * @returns an array of Vector3
  25850. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25851. */
  25852. getFacetLocalPositions(): Vector3[];
  25853. /**
  25854. * Returns the facetLocalPartioning array
  25855. * @returns an array of array of numbers
  25856. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25857. */
  25858. getFacetLocalPartitioning(): number[][];
  25859. /**
  25860. * Returns the i-th facet position in the world system.
  25861. * This method allocates a new Vector3 per call
  25862. * @param i defines the facet index
  25863. * @returns a new Vector3
  25864. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25865. */
  25866. getFacetPosition(i: number): Vector3;
  25867. /**
  25868. * Sets the reference Vector3 with the i-th facet position in the world system
  25869. * @param i defines the facet index
  25870. * @param ref defines the target vector
  25871. * @returns the current mesh
  25872. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25873. */
  25874. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25875. /**
  25876. * Returns the i-th facet normal in the world system.
  25877. * This method allocates a new Vector3 per call
  25878. * @param i defines the facet index
  25879. * @returns a new Vector3
  25880. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25881. */
  25882. getFacetNormal(i: number): Vector3;
  25883. /**
  25884. * Sets the reference Vector3 with the i-th facet normal in the world system
  25885. * @param i defines the facet index
  25886. * @param ref defines the target vector
  25887. * @returns the current mesh
  25888. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25889. */
  25890. getFacetNormalToRef(i: number, ref: Vector3): this;
  25891. /**
  25892. * 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)
  25893. * @param x defines x coordinate
  25894. * @param y defines y coordinate
  25895. * @param z defines z coordinate
  25896. * @returns the array of facet indexes
  25897. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25898. */
  25899. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25900. /**
  25901. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25902. * @param projected sets as the (x,y,z) world projection on the facet
  25903. * @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
  25904. * @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
  25905. * @param x defines x coordinate
  25906. * @param y defines y coordinate
  25907. * @param z defines z coordinate
  25908. * @returns the face index if found (or null instead)
  25909. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25910. */
  25911. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25912. /**
  25913. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25914. * @param projected sets as the (x,y,z) local projection on the facet
  25915. * @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
  25916. * @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
  25917. * @param x defines x coordinate
  25918. * @param y defines y coordinate
  25919. * @param z defines z coordinate
  25920. * @returns the face index if found (or null instead)
  25921. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25922. */
  25923. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25924. /**
  25925. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25926. * @returns the parameters
  25927. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25928. */
  25929. getFacetDataParameters(): any;
  25930. /**
  25931. * Disables the feature FacetData and frees the related memory
  25932. * @returns the current mesh
  25933. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25934. */
  25935. disableFacetData(): AbstractMesh;
  25936. /**
  25937. * Updates the AbstractMesh indices array
  25938. * @param indices defines the data source
  25939. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25940. * @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)
  25941. * @returns the current mesh
  25942. */
  25943. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25944. /**
  25945. * Creates new normals data for the mesh
  25946. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25947. * @returns the current mesh
  25948. */
  25949. createNormals(updatable: boolean): AbstractMesh;
  25950. /**
  25951. * Align the mesh with a normal
  25952. * @param normal defines the normal to use
  25953. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25954. * @returns the current mesh
  25955. */
  25956. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25957. /** @hidden */
  25958. _checkOcclusionQuery(): boolean;
  25959. /**
  25960. * Disables the mesh edge rendering mode
  25961. * @returns the currentAbstractMesh
  25962. */
  25963. disableEdgesRendering(): AbstractMesh;
  25964. /**
  25965. * Enables the edge rendering mode on the mesh.
  25966. * This mode makes the mesh edges visible
  25967. * @param epsilon defines the maximal distance between two angles to detect a face
  25968. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25969. * @returns the currentAbstractMesh
  25970. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25971. */
  25972. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25973. }
  25974. }
  25975. declare module "babylonjs/Actions/actionEvent" {
  25976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25977. import { Nullable } from "babylonjs/types";
  25978. import { Sprite } from "babylonjs/Sprites/sprite";
  25979. import { Scene } from "babylonjs/scene";
  25980. import { Vector2 } from "babylonjs/Maths/math";
  25981. /**
  25982. * Interface used to define ActionEvent
  25983. */
  25984. export interface IActionEvent {
  25985. /** The mesh or sprite that triggered the action */
  25986. source: any;
  25987. /** The X mouse cursor position at the time of the event */
  25988. pointerX: number;
  25989. /** The Y mouse cursor position at the time of the event */
  25990. pointerY: number;
  25991. /** The mesh that is currently pointed at (can be null) */
  25992. meshUnderPointer: Nullable<AbstractMesh>;
  25993. /** the original (browser) event that triggered the ActionEvent */
  25994. sourceEvent?: any;
  25995. /** additional data for the event */
  25996. additionalData?: any;
  25997. }
  25998. /**
  25999. * ActionEvent is the event being sent when an action is triggered.
  26000. */
  26001. export class ActionEvent implements IActionEvent {
  26002. /** The mesh or sprite that triggered the action */
  26003. source: any;
  26004. /** The X mouse cursor position at the time of the event */
  26005. pointerX: number;
  26006. /** The Y mouse cursor position at the time of the event */
  26007. pointerY: number;
  26008. /** The mesh that is currently pointed at (can be null) */
  26009. meshUnderPointer: Nullable<AbstractMesh>;
  26010. /** the original (browser) event that triggered the ActionEvent */
  26011. sourceEvent?: any;
  26012. /** additional data for the event */
  26013. additionalData?: any;
  26014. /**
  26015. * Creates a new ActionEvent
  26016. * @param source The mesh or sprite that triggered the action
  26017. * @param pointerX The X mouse cursor position at the time of the event
  26018. * @param pointerY The Y mouse cursor position at the time of the event
  26019. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26020. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26021. * @param additionalData additional data for the event
  26022. */
  26023. constructor(
  26024. /** The mesh or sprite that triggered the action */
  26025. source: any,
  26026. /** The X mouse cursor position at the time of the event */
  26027. pointerX: number,
  26028. /** The Y mouse cursor position at the time of the event */
  26029. pointerY: number,
  26030. /** The mesh that is currently pointed at (can be null) */
  26031. meshUnderPointer: Nullable<AbstractMesh>,
  26032. /** the original (browser) event that triggered the ActionEvent */
  26033. sourceEvent?: any,
  26034. /** additional data for the event */
  26035. additionalData?: any);
  26036. /**
  26037. * Helper function to auto-create an ActionEvent from a source mesh.
  26038. * @param source The source mesh that triggered the event
  26039. * @param evt The original (browser) event
  26040. * @param additionalData additional data for the event
  26041. * @returns the new ActionEvent
  26042. */
  26043. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26044. /**
  26045. * Helper function to auto-create an ActionEvent from a source sprite
  26046. * @param source The source sprite that triggered the event
  26047. * @param scene Scene associated with the sprite
  26048. * @param evt The original (browser) event
  26049. * @param additionalData additional data for the event
  26050. * @returns the new ActionEvent
  26051. */
  26052. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26053. /**
  26054. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26055. * @param scene the scene where the event occurred
  26056. * @param evt The original (browser) event
  26057. * @returns the new ActionEvent
  26058. */
  26059. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26060. /**
  26061. * Helper function to auto-create an ActionEvent from a primitive
  26062. * @param prim defines the target primitive
  26063. * @param pointerPos defines the pointer position
  26064. * @param evt The original (browser) event
  26065. * @param additionalData additional data for the event
  26066. * @returns the new ActionEvent
  26067. */
  26068. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26069. }
  26070. }
  26071. declare module "babylonjs/Actions/abstractActionManager" {
  26072. import { IDisposable } from "babylonjs/scene";
  26073. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  26074. import { IAction } from "babylonjs/Actions/action";
  26075. import { Nullable } from "babylonjs/types";
  26076. /**
  26077. * Abstract class used to decouple action Manager from scene and meshes.
  26078. * Do not instantiate.
  26079. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26080. */
  26081. export abstract class AbstractActionManager implements IDisposable {
  26082. /** Gets the list of active triggers */
  26083. static Triggers: {
  26084. [key: string]: number;
  26085. };
  26086. /** Gets the cursor to use when hovering items */
  26087. hoverCursor: string;
  26088. /** Gets the list of actions */
  26089. actions: IAction[];
  26090. /**
  26091. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26092. */
  26093. isRecursive: boolean;
  26094. /**
  26095. * Releases all associated resources
  26096. */
  26097. abstract dispose(): void;
  26098. /**
  26099. * Does this action manager has pointer triggers
  26100. */
  26101. abstract readonly hasPointerTriggers: boolean;
  26102. /**
  26103. * Does this action manager has pick triggers
  26104. */
  26105. abstract readonly hasPickTriggers: boolean;
  26106. /**
  26107. * Process a specific trigger
  26108. * @param trigger defines the trigger to process
  26109. * @param evt defines the event details to be processed
  26110. */
  26111. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26112. /**
  26113. * Does this action manager handles actions of any of the given triggers
  26114. * @param triggers defines the triggers to be tested
  26115. * @return a boolean indicating whether one (or more) of the triggers is handled
  26116. */
  26117. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26118. /**
  26119. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26120. * speed.
  26121. * @param triggerA defines the trigger to be tested
  26122. * @param triggerB defines the trigger to be tested
  26123. * @return a boolean indicating whether one (or more) of the triggers is handled
  26124. */
  26125. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26126. /**
  26127. * Does this action manager handles actions of a given trigger
  26128. * @param trigger defines the trigger to be tested
  26129. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26130. * @return whether the trigger is handled
  26131. */
  26132. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26133. /**
  26134. * Serialize this manager to a JSON object
  26135. * @param name defines the property name to store this manager
  26136. * @returns a JSON representation of this manager
  26137. */
  26138. abstract serialize(name: string): any;
  26139. /**
  26140. * Registers an action to this action manager
  26141. * @param action defines the action to be registered
  26142. * @return the action amended (prepared) after registration
  26143. */
  26144. abstract registerAction(action: IAction): Nullable<IAction>;
  26145. /**
  26146. * Unregisters an action to this action manager
  26147. * @param action defines the action to be unregistered
  26148. * @return a boolean indicating whether the action has been unregistered
  26149. */
  26150. abstract unregisterAction(action: IAction): Boolean;
  26151. /**
  26152. * Does exist one action manager with at least one trigger
  26153. **/
  26154. static readonly HasTriggers: boolean;
  26155. /**
  26156. * Does exist one action manager with at least one pick trigger
  26157. **/
  26158. static readonly HasPickTriggers: boolean;
  26159. /**
  26160. * Does exist one action manager that handles actions of a given trigger
  26161. * @param trigger defines the trigger to be tested
  26162. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26163. **/
  26164. static HasSpecificTrigger(trigger: number): boolean;
  26165. }
  26166. }
  26167. declare module "babylonjs/node" {
  26168. import { Scene } from "babylonjs/scene";
  26169. import { Nullable } from "babylonjs/types";
  26170. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  26171. import { Engine } from "babylonjs/Engines/engine";
  26172. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  26173. import { Observable } from "babylonjs/Misc/observable";
  26174. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26175. import { IInspectable } from "babylonjs/Misc/iInspectable";
  26176. import { Animatable } from "babylonjs/Animations/animatable";
  26177. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26178. import { Animation } from "babylonjs/Animations/animation";
  26179. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26180. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26181. /**
  26182. * Defines how a node can be built from a string name.
  26183. */
  26184. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26185. /**
  26186. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26187. */
  26188. export class Node implements IBehaviorAware<Node> {
  26189. /** @hidden */
  26190. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  26191. private static _NodeConstructors;
  26192. /**
  26193. * Add a new node constructor
  26194. * @param type defines the type name of the node to construct
  26195. * @param constructorFunc defines the constructor function
  26196. */
  26197. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26198. /**
  26199. * Returns a node constructor based on type name
  26200. * @param type defines the type name
  26201. * @param name defines the new node name
  26202. * @param scene defines the hosting scene
  26203. * @param options defines optional options to transmit to constructors
  26204. * @returns the new constructor or null
  26205. */
  26206. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26207. /**
  26208. * Gets or sets the name of the node
  26209. */
  26210. name: string;
  26211. /**
  26212. * Gets or sets the id of the node
  26213. */
  26214. id: string;
  26215. /**
  26216. * Gets or sets the unique id of the node
  26217. */
  26218. uniqueId: number;
  26219. /**
  26220. * Gets or sets a string used to store user defined state for the node
  26221. */
  26222. state: string;
  26223. /**
  26224. * Gets or sets an object used to store user defined information for the node
  26225. */
  26226. metadata: any;
  26227. /**
  26228. * For internal use only. Please do not use.
  26229. */
  26230. reservedDataStore: any;
  26231. /**
  26232. * List of inspectable custom properties (used by the Inspector)
  26233. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26234. */
  26235. inspectableCustomProperties: IInspectable[];
  26236. /**
  26237. * Gets or sets a boolean used to define if the node must be serialized
  26238. */
  26239. doNotSerialize: boolean;
  26240. /** @hidden */
  26241. _isDisposed: boolean;
  26242. /**
  26243. * Gets a list of Animations associated with the node
  26244. */
  26245. animations: import("babylonjs/Animations/animation").Animation[];
  26246. protected _ranges: {
  26247. [name: string]: Nullable<AnimationRange>;
  26248. };
  26249. /**
  26250. * Callback raised when the node is ready to be used
  26251. */
  26252. onReady: Nullable<(node: Node) => void>;
  26253. private _isEnabled;
  26254. private _isParentEnabled;
  26255. private _isReady;
  26256. /** @hidden */
  26257. _currentRenderId: number;
  26258. private _parentUpdateId;
  26259. /** @hidden */
  26260. _childUpdateId: number;
  26261. /** @hidden */
  26262. _waitingParentId: Nullable<string>;
  26263. /** @hidden */
  26264. _scene: Scene;
  26265. /** @hidden */
  26266. _cache: any;
  26267. private _parentNode;
  26268. private _children;
  26269. /** @hidden */
  26270. _worldMatrix: Matrix;
  26271. /** @hidden */
  26272. _worldMatrixDeterminant: number;
  26273. /** @hidden */
  26274. _worldMatrixDeterminantIsDirty: boolean;
  26275. /** @hidden */
  26276. private _sceneRootNodesIndex;
  26277. /**
  26278. * Gets a boolean indicating if the node has been disposed
  26279. * @returns true if the node was disposed
  26280. */
  26281. isDisposed(): boolean;
  26282. /**
  26283. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26284. * @see https://doc.babylonjs.com/how_to/parenting
  26285. */
  26286. parent: Nullable<Node>;
  26287. private addToSceneRootNodes;
  26288. private removeFromSceneRootNodes;
  26289. private _animationPropertiesOverride;
  26290. /**
  26291. * Gets or sets the animation properties override
  26292. */
  26293. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26294. /**
  26295. * Gets a string idenfifying the name of the class
  26296. * @returns "Node" string
  26297. */
  26298. getClassName(): string;
  26299. /** @hidden */
  26300. readonly _isNode: boolean;
  26301. /**
  26302. * An event triggered when the mesh is disposed
  26303. */
  26304. onDisposeObservable: Observable<Node>;
  26305. private _onDisposeObserver;
  26306. /**
  26307. * Sets a callback that will be raised when the node will be disposed
  26308. */
  26309. onDispose: () => void;
  26310. /**
  26311. * Creates a new Node
  26312. * @param name the name and id to be given to this node
  26313. * @param scene the scene this node will be added to
  26314. * @param addToRootNodes the node will be added to scene.rootNodes
  26315. */
  26316. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26317. /**
  26318. * Gets the scene of the node
  26319. * @returns a scene
  26320. */
  26321. getScene(): Scene;
  26322. /**
  26323. * Gets the engine of the node
  26324. * @returns a Engine
  26325. */
  26326. getEngine(): Engine;
  26327. private _behaviors;
  26328. /**
  26329. * Attach a behavior to the node
  26330. * @see http://doc.babylonjs.com/features/behaviour
  26331. * @param behavior defines the behavior to attach
  26332. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26333. * @returns the current Node
  26334. */
  26335. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26336. /**
  26337. * Remove an attached behavior
  26338. * @see http://doc.babylonjs.com/features/behaviour
  26339. * @param behavior defines the behavior to attach
  26340. * @returns the current Node
  26341. */
  26342. removeBehavior(behavior: Behavior<Node>): Node;
  26343. /**
  26344. * Gets the list of attached behaviors
  26345. * @see http://doc.babylonjs.com/features/behaviour
  26346. */
  26347. readonly behaviors: Behavior<Node>[];
  26348. /**
  26349. * Gets an attached behavior by name
  26350. * @param name defines the name of the behavior to look for
  26351. * @see http://doc.babylonjs.com/features/behaviour
  26352. * @returns null if behavior was not found else the requested behavior
  26353. */
  26354. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26355. /**
  26356. * Returns the latest update of the World matrix
  26357. * @returns a Matrix
  26358. */
  26359. getWorldMatrix(): Matrix;
  26360. /** @hidden */
  26361. _getWorldMatrixDeterminant(): number;
  26362. /**
  26363. * Returns directly the latest state of the mesh World matrix.
  26364. * A Matrix is returned.
  26365. */
  26366. readonly worldMatrixFromCache: Matrix;
  26367. /** @hidden */
  26368. _initCache(): void;
  26369. /** @hidden */
  26370. updateCache(force?: boolean): void;
  26371. /** @hidden */
  26372. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26373. /** @hidden */
  26374. _updateCache(ignoreParentClass?: boolean): void;
  26375. /** @hidden */
  26376. _isSynchronized(): boolean;
  26377. /** @hidden */
  26378. _markSyncedWithParent(): void;
  26379. /** @hidden */
  26380. isSynchronizedWithParent(): boolean;
  26381. /** @hidden */
  26382. isSynchronized(): boolean;
  26383. /**
  26384. * Is this node ready to be used/rendered
  26385. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26386. * @return true if the node is ready
  26387. */
  26388. isReady(completeCheck?: boolean): boolean;
  26389. /**
  26390. * Is this node enabled?
  26391. * 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
  26392. * @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
  26393. * @return whether this node (and its parent) is enabled
  26394. */
  26395. isEnabled(checkAncestors?: boolean): boolean;
  26396. /** @hidden */
  26397. protected _syncParentEnabledState(): void;
  26398. /**
  26399. * Set the enabled state of this node
  26400. * @param value defines the new enabled state
  26401. */
  26402. setEnabled(value: boolean): void;
  26403. /**
  26404. * Is this node a descendant of the given node?
  26405. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26406. * @param ancestor defines the parent node to inspect
  26407. * @returns a boolean indicating if this node is a descendant of the given node
  26408. */
  26409. isDescendantOf(ancestor: Node): boolean;
  26410. /** @hidden */
  26411. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26412. /**
  26413. * Will return all nodes that have this node as ascendant
  26414. * @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
  26415. * @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
  26416. * @return all children nodes of all types
  26417. */
  26418. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26419. /**
  26420. * Get all child-meshes of this node
  26421. * @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)
  26422. * @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
  26423. * @returns an array of AbstractMesh
  26424. */
  26425. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26426. /**
  26427. * Get all direct children of this node
  26428. * @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
  26429. * @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)
  26430. * @returns an array of Node
  26431. */
  26432. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26433. /** @hidden */
  26434. _setReady(state: boolean): void;
  26435. /**
  26436. * Get an animation by name
  26437. * @param name defines the name of the animation to look for
  26438. * @returns null if not found else the requested animation
  26439. */
  26440. getAnimationByName(name: string): Nullable<Animation>;
  26441. /**
  26442. * Creates an animation range for this node
  26443. * @param name defines the name of the range
  26444. * @param from defines the starting key
  26445. * @param to defines the end key
  26446. */
  26447. createAnimationRange(name: string, from: number, to: number): void;
  26448. /**
  26449. * Delete a specific animation range
  26450. * @param name defines the name of the range to delete
  26451. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26452. */
  26453. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26454. /**
  26455. * Get an animation range by name
  26456. * @param name defines the name of the animation range to look for
  26457. * @returns null if not found else the requested animation range
  26458. */
  26459. getAnimationRange(name: string): Nullable<AnimationRange>;
  26460. /**
  26461. * Gets the list of all animation ranges defined on this node
  26462. * @returns an array
  26463. */
  26464. getAnimationRanges(): Nullable<AnimationRange>[];
  26465. /**
  26466. * Will start the animation sequence
  26467. * @param name defines the range frames for animation sequence
  26468. * @param loop defines if the animation should loop (false by default)
  26469. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26470. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26471. * @returns the object created for this animation. If range does not exist, it will return null
  26472. */
  26473. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26474. /**
  26475. * Serialize animation ranges into a JSON compatible object
  26476. * @returns serialization object
  26477. */
  26478. serializeAnimationRanges(): any;
  26479. /**
  26480. * Computes the world matrix of the node
  26481. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26482. * @returns the world matrix
  26483. */
  26484. computeWorldMatrix(force?: boolean): Matrix;
  26485. /**
  26486. * Releases resources associated with this node.
  26487. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26488. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26489. */
  26490. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26491. /**
  26492. * Parse animation range data from a serialization object and store them into a given node
  26493. * @param node defines where to store the animation ranges
  26494. * @param parsedNode defines the serialization object to read data from
  26495. * @param scene defines the hosting scene
  26496. */
  26497. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26498. /**
  26499. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26500. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26501. * @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
  26502. * @returns the new bounding vectors
  26503. */
  26504. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26505. min: Vector3;
  26506. max: Vector3;
  26507. };
  26508. }
  26509. }
  26510. declare module "babylonjs/Animations/animation" {
  26511. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  26512. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  26513. import { Nullable } from "babylonjs/types";
  26514. import { Scene } from "babylonjs/scene";
  26515. import { IAnimatable } from "babylonjs/Misc/tools";
  26516. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  26517. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26518. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  26519. import { Node } from "babylonjs/node";
  26520. import { Animatable } from "babylonjs/Animations/animatable";
  26521. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26522. /**
  26523. * @hidden
  26524. */
  26525. export class _IAnimationState {
  26526. key: number;
  26527. repeatCount: number;
  26528. workValue?: any;
  26529. loopMode?: number;
  26530. offsetValue?: any;
  26531. highLimitValue?: any;
  26532. }
  26533. /**
  26534. * Class used to store any kind of animation
  26535. */
  26536. export class Animation {
  26537. /**Name of the animation */
  26538. name: string;
  26539. /**Property to animate */
  26540. targetProperty: string;
  26541. /**The frames per second of the animation */
  26542. framePerSecond: number;
  26543. /**The data type of the animation */
  26544. dataType: number;
  26545. /**The loop mode of the animation */
  26546. loopMode?: number | undefined;
  26547. /**Specifies if blending should be enabled */
  26548. enableBlending?: boolean | undefined;
  26549. /**
  26550. * Use matrix interpolation instead of using direct key value when animating matrices
  26551. */
  26552. static AllowMatricesInterpolation: boolean;
  26553. /**
  26554. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26555. */
  26556. static AllowMatrixDecomposeForInterpolation: boolean;
  26557. /**
  26558. * Stores the key frames of the animation
  26559. */
  26560. private _keys;
  26561. /**
  26562. * Stores the easing function of the animation
  26563. */
  26564. private _easingFunction;
  26565. /**
  26566. * @hidden Internal use only
  26567. */
  26568. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  26569. /**
  26570. * The set of event that will be linked to this animation
  26571. */
  26572. private _events;
  26573. /**
  26574. * Stores an array of target property paths
  26575. */
  26576. targetPropertyPath: string[];
  26577. /**
  26578. * Stores the blending speed of the animation
  26579. */
  26580. blendingSpeed: number;
  26581. /**
  26582. * Stores the animation ranges for the animation
  26583. */
  26584. private _ranges;
  26585. /**
  26586. * @hidden Internal use
  26587. */
  26588. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26589. /**
  26590. * Sets up an animation
  26591. * @param property The property to animate
  26592. * @param animationType The animation type to apply
  26593. * @param framePerSecond The frames per second of the animation
  26594. * @param easingFunction The easing function used in the animation
  26595. * @returns The created animation
  26596. */
  26597. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26598. /**
  26599. * Create and start an animation on a node
  26600. * @param name defines the name of the global animation that will be run on all nodes
  26601. * @param node defines the root node where the animation will take place
  26602. * @param targetProperty defines property to animate
  26603. * @param framePerSecond defines the number of frame per second yo use
  26604. * @param totalFrame defines the number of frames in total
  26605. * @param from defines the initial value
  26606. * @param to defines the final value
  26607. * @param loopMode defines which loop mode you want to use (off by default)
  26608. * @param easingFunction defines the easing function to use (linear by default)
  26609. * @param onAnimationEnd defines the callback to call when animation end
  26610. * @returns the animatable created for this animation
  26611. */
  26612. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26613. /**
  26614. * Create and start an animation on a node and its descendants
  26615. * @param name defines the name of the global animation that will be run on all nodes
  26616. * @param node defines the root node where the animation will take place
  26617. * @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
  26618. * @param targetProperty defines property to animate
  26619. * @param framePerSecond defines the number of frame per second to use
  26620. * @param totalFrame defines the number of frames in total
  26621. * @param from defines the initial value
  26622. * @param to defines the final value
  26623. * @param loopMode defines which loop mode you want to use (off by default)
  26624. * @param easingFunction defines the easing function to use (linear by default)
  26625. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26626. * @returns the list of animatables created for all nodes
  26627. * @example https://www.babylonjs-playground.com/#MH0VLI
  26628. */
  26629. 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[]>;
  26630. /**
  26631. * Creates a new animation, merges it with the existing animations and starts it
  26632. * @param name Name of the animation
  26633. * @param node Node which contains the scene that begins the animations
  26634. * @param targetProperty Specifies which property to animate
  26635. * @param framePerSecond The frames per second of the animation
  26636. * @param totalFrame The total number of frames
  26637. * @param from The frame at the beginning of the animation
  26638. * @param to The frame at the end of the animation
  26639. * @param loopMode Specifies the loop mode of the animation
  26640. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26641. * @param onAnimationEnd Callback to run once the animation is complete
  26642. * @returns Nullable animation
  26643. */
  26644. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26645. /**
  26646. * Transition property of an host to the target Value
  26647. * @param property The property to transition
  26648. * @param targetValue The target Value of the property
  26649. * @param host The object where the property to animate belongs
  26650. * @param scene Scene used to run the animation
  26651. * @param frameRate Framerate (in frame/s) to use
  26652. * @param transition The transition type we want to use
  26653. * @param duration The duration of the animation, in milliseconds
  26654. * @param onAnimationEnd Callback trigger at the end of the animation
  26655. * @returns Nullable animation
  26656. */
  26657. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26658. /**
  26659. * Return the array of runtime animations currently using this animation
  26660. */
  26661. readonly runtimeAnimations: RuntimeAnimation[];
  26662. /**
  26663. * Specifies if any of the runtime animations are currently running
  26664. */
  26665. readonly hasRunningRuntimeAnimations: boolean;
  26666. /**
  26667. * Initializes the animation
  26668. * @param name Name of the animation
  26669. * @param targetProperty Property to animate
  26670. * @param framePerSecond The frames per second of the animation
  26671. * @param dataType The data type of the animation
  26672. * @param loopMode The loop mode of the animation
  26673. * @param enableBlending Specifies if blending should be enabled
  26674. */
  26675. constructor(
  26676. /**Name of the animation */
  26677. name: string,
  26678. /**Property to animate */
  26679. targetProperty: string,
  26680. /**The frames per second of the animation */
  26681. framePerSecond: number,
  26682. /**The data type of the animation */
  26683. dataType: number,
  26684. /**The loop mode of the animation */
  26685. loopMode?: number | undefined,
  26686. /**Specifies if blending should be enabled */
  26687. enableBlending?: boolean | undefined);
  26688. /**
  26689. * Converts the animation to a string
  26690. * @param fullDetails support for multiple levels of logging within scene loading
  26691. * @returns String form of the animation
  26692. */
  26693. toString(fullDetails?: boolean): string;
  26694. /**
  26695. * Add an event to this animation
  26696. * @param event Event to add
  26697. */
  26698. addEvent(event: AnimationEvent): void;
  26699. /**
  26700. * Remove all events found at the given frame
  26701. * @param frame The frame to remove events from
  26702. */
  26703. removeEvents(frame: number): void;
  26704. /**
  26705. * Retrieves all the events from the animation
  26706. * @returns Events from the animation
  26707. */
  26708. getEvents(): AnimationEvent[];
  26709. /**
  26710. * Creates an animation range
  26711. * @param name Name of the animation range
  26712. * @param from Starting frame of the animation range
  26713. * @param to Ending frame of the animation
  26714. */
  26715. createRange(name: string, from: number, to: number): void;
  26716. /**
  26717. * Deletes an animation range by name
  26718. * @param name Name of the animation range to delete
  26719. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26720. */
  26721. deleteRange(name: string, deleteFrames?: boolean): void;
  26722. /**
  26723. * Gets the animation range by name, or null if not defined
  26724. * @param name Name of the animation range
  26725. * @returns Nullable animation range
  26726. */
  26727. getRange(name: string): Nullable<AnimationRange>;
  26728. /**
  26729. * Gets the key frames from the animation
  26730. * @returns The key frames of the animation
  26731. */
  26732. getKeys(): Array<IAnimationKey>;
  26733. /**
  26734. * Gets the highest frame rate of the animation
  26735. * @returns Highest frame rate of the animation
  26736. */
  26737. getHighestFrame(): number;
  26738. /**
  26739. * Gets the easing function of the animation
  26740. * @returns Easing function of the animation
  26741. */
  26742. getEasingFunction(): IEasingFunction;
  26743. /**
  26744. * Sets the easing function of the animation
  26745. * @param easingFunction A custom mathematical formula for animation
  26746. */
  26747. setEasingFunction(easingFunction: EasingFunction): void;
  26748. /**
  26749. * Interpolates a scalar linearly
  26750. * @param startValue Start value of the animation curve
  26751. * @param endValue End value of the animation curve
  26752. * @param gradient Scalar amount to interpolate
  26753. * @returns Interpolated scalar value
  26754. */
  26755. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26756. /**
  26757. * Interpolates a scalar cubically
  26758. * @param startValue Start value of the animation curve
  26759. * @param outTangent End tangent of the animation
  26760. * @param endValue End value of the animation curve
  26761. * @param inTangent Start tangent of the animation curve
  26762. * @param gradient Scalar amount to interpolate
  26763. * @returns Interpolated scalar value
  26764. */
  26765. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26766. /**
  26767. * Interpolates a quaternion using a spherical linear interpolation
  26768. * @param startValue Start value of the animation curve
  26769. * @param endValue End value of the animation curve
  26770. * @param gradient Scalar amount to interpolate
  26771. * @returns Interpolated quaternion value
  26772. */
  26773. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26774. /**
  26775. * Interpolates a quaternion cubically
  26776. * @param startValue Start value of the animation curve
  26777. * @param outTangent End tangent of the animation curve
  26778. * @param endValue End value of the animation curve
  26779. * @param inTangent Start tangent of the animation curve
  26780. * @param gradient Scalar amount to interpolate
  26781. * @returns Interpolated quaternion value
  26782. */
  26783. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26784. /**
  26785. * Interpolates a Vector3 linearl
  26786. * @param startValue Start value of the animation curve
  26787. * @param endValue End value of the animation curve
  26788. * @param gradient Scalar amount to interpolate
  26789. * @returns Interpolated scalar value
  26790. */
  26791. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26792. /**
  26793. * Interpolates a Vector3 cubically
  26794. * @param startValue Start value of the animation curve
  26795. * @param outTangent End tangent of the animation
  26796. * @param endValue End value of the animation curve
  26797. * @param inTangent Start tangent of the animation curve
  26798. * @param gradient Scalar amount to interpolate
  26799. * @returns InterpolatedVector3 value
  26800. */
  26801. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26802. /**
  26803. * Interpolates a Vector2 linearly
  26804. * @param startValue Start value of the animation curve
  26805. * @param endValue End value of the animation curve
  26806. * @param gradient Scalar amount to interpolate
  26807. * @returns Interpolated Vector2 value
  26808. */
  26809. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26810. /**
  26811. * Interpolates a Vector2 cubically
  26812. * @param startValue Start value of the animation curve
  26813. * @param outTangent End tangent of the animation
  26814. * @param endValue End value of the animation curve
  26815. * @param inTangent Start tangent of the animation curve
  26816. * @param gradient Scalar amount to interpolate
  26817. * @returns Interpolated Vector2 value
  26818. */
  26819. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26820. /**
  26821. * Interpolates a size linearly
  26822. * @param startValue Start value of the animation curve
  26823. * @param endValue End value of the animation curve
  26824. * @param gradient Scalar amount to interpolate
  26825. * @returns Interpolated Size value
  26826. */
  26827. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26828. /**
  26829. * Interpolates a Color3 linearly
  26830. * @param startValue Start value of the animation curve
  26831. * @param endValue End value of the animation curve
  26832. * @param gradient Scalar amount to interpolate
  26833. * @returns Interpolated Color3 value
  26834. */
  26835. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26836. /**
  26837. * @hidden Internal use only
  26838. */
  26839. _getKeyValue(value: any): any;
  26840. /**
  26841. * @hidden Internal use only
  26842. */
  26843. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26844. /**
  26845. * Defines the function to use to interpolate matrices
  26846. * @param startValue defines the start matrix
  26847. * @param endValue defines the end matrix
  26848. * @param gradient defines the gradient between both matrices
  26849. * @param result defines an optional target matrix where to store the interpolation
  26850. * @returns the interpolated matrix
  26851. */
  26852. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26853. /**
  26854. * Makes a copy of the animation
  26855. * @returns Cloned animation
  26856. */
  26857. clone(): Animation;
  26858. /**
  26859. * Sets the key frames of the animation
  26860. * @param values The animation key frames to set
  26861. */
  26862. setKeys(values: Array<IAnimationKey>): void;
  26863. /**
  26864. * Serializes the animation to an object
  26865. * @returns Serialized object
  26866. */
  26867. serialize(): any;
  26868. /**
  26869. * Float animation type
  26870. */
  26871. private static _ANIMATIONTYPE_FLOAT;
  26872. /**
  26873. * Vector3 animation type
  26874. */
  26875. private static _ANIMATIONTYPE_VECTOR3;
  26876. /**
  26877. * Quaternion animation type
  26878. */
  26879. private static _ANIMATIONTYPE_QUATERNION;
  26880. /**
  26881. * Matrix animation type
  26882. */
  26883. private static _ANIMATIONTYPE_MATRIX;
  26884. /**
  26885. * Color3 animation type
  26886. */
  26887. private static _ANIMATIONTYPE_COLOR3;
  26888. /**
  26889. * Vector2 animation type
  26890. */
  26891. private static _ANIMATIONTYPE_VECTOR2;
  26892. /**
  26893. * Size animation type
  26894. */
  26895. private static _ANIMATIONTYPE_SIZE;
  26896. /**
  26897. * Relative Loop Mode
  26898. */
  26899. private static _ANIMATIONLOOPMODE_RELATIVE;
  26900. /**
  26901. * Cycle Loop Mode
  26902. */
  26903. private static _ANIMATIONLOOPMODE_CYCLE;
  26904. /**
  26905. * Constant Loop Mode
  26906. */
  26907. private static _ANIMATIONLOOPMODE_CONSTANT;
  26908. /**
  26909. * Get the float animation type
  26910. */
  26911. static readonly ANIMATIONTYPE_FLOAT: number;
  26912. /**
  26913. * Get the Vector3 animation type
  26914. */
  26915. static readonly ANIMATIONTYPE_VECTOR3: number;
  26916. /**
  26917. * Get the Vector2 animation type
  26918. */
  26919. static readonly ANIMATIONTYPE_VECTOR2: number;
  26920. /**
  26921. * Get the Size animation type
  26922. */
  26923. static readonly ANIMATIONTYPE_SIZE: number;
  26924. /**
  26925. * Get the Quaternion animation type
  26926. */
  26927. static readonly ANIMATIONTYPE_QUATERNION: number;
  26928. /**
  26929. * Get the Matrix animation type
  26930. */
  26931. static readonly ANIMATIONTYPE_MATRIX: number;
  26932. /**
  26933. * Get the Color3 animation type
  26934. */
  26935. static readonly ANIMATIONTYPE_COLOR3: number;
  26936. /**
  26937. * Get the Relative Loop Mode
  26938. */
  26939. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26940. /**
  26941. * Get the Cycle Loop Mode
  26942. */
  26943. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26944. /**
  26945. * Get the Constant Loop Mode
  26946. */
  26947. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26948. /** @hidden */
  26949. static _UniversalLerp(left: any, right: any, amount: number): any;
  26950. /**
  26951. * Parses an animation object and creates an animation
  26952. * @param parsedAnimation Parsed animation object
  26953. * @returns Animation object
  26954. */
  26955. static Parse(parsedAnimation: any): Animation;
  26956. /**
  26957. * Appends the serialized animations from the source animations
  26958. * @param source Source containing the animations
  26959. * @param destination Target to store the animations
  26960. */
  26961. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26962. }
  26963. }
  26964. declare module "babylonjs/Materials/Textures/baseTexture" {
  26965. import { Observable } from "babylonjs/Misc/observable";
  26966. import { IAnimatable } from "babylonjs/Misc/tools";
  26967. import { Nullable } from "babylonjs/types";
  26968. import { Scene } from "babylonjs/scene";
  26969. import { Matrix, ISize } from "babylonjs/Maths/math";
  26970. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26971. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26972. /**
  26973. * Base class of all the textures in babylon.
  26974. * It groups all the common properties the materials, post process, lights... might need
  26975. * in order to make a correct use of the texture.
  26976. */
  26977. export class BaseTexture implements IAnimatable {
  26978. /**
  26979. * Default anisotropic filtering level for the application.
  26980. * It is set to 4 as a good tradeoff between perf and quality.
  26981. */
  26982. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26983. /**
  26984. * Gets or sets the unique id of the texture
  26985. */
  26986. uniqueId: number;
  26987. /**
  26988. * Define the name of the texture.
  26989. */
  26990. name: string;
  26991. /**
  26992. * Gets or sets an object used to store user defined information.
  26993. */
  26994. metadata: any;
  26995. /**
  26996. * For internal use only. Please do not use.
  26997. */
  26998. reservedDataStore: any;
  26999. private _hasAlpha;
  27000. /**
  27001. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27002. */
  27003. hasAlpha: boolean;
  27004. /**
  27005. * Defines if the alpha value should be determined via the rgb values.
  27006. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27007. */
  27008. getAlphaFromRGB: boolean;
  27009. /**
  27010. * Intensity or strength of the texture.
  27011. * It is commonly used by materials to fine tune the intensity of the texture
  27012. */
  27013. level: number;
  27014. /**
  27015. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27016. * This is part of the texture as textures usually maps to one uv set.
  27017. */
  27018. coordinatesIndex: number;
  27019. private _coordinatesMode;
  27020. /**
  27021. * How a texture is mapped.
  27022. *
  27023. * | Value | Type | Description |
  27024. * | ----- | ----------------------------------- | ----------- |
  27025. * | 0 | EXPLICIT_MODE | |
  27026. * | 1 | SPHERICAL_MODE | |
  27027. * | 2 | PLANAR_MODE | |
  27028. * | 3 | CUBIC_MODE | |
  27029. * | 4 | PROJECTION_MODE | |
  27030. * | 5 | SKYBOX_MODE | |
  27031. * | 6 | INVCUBIC_MODE | |
  27032. * | 7 | EQUIRECTANGULAR_MODE | |
  27033. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27034. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27035. */
  27036. coordinatesMode: number;
  27037. /**
  27038. * | Value | Type | Description |
  27039. * | ----- | ------------------ | ----------- |
  27040. * | 0 | CLAMP_ADDRESSMODE | |
  27041. * | 1 | WRAP_ADDRESSMODE | |
  27042. * | 2 | MIRROR_ADDRESSMODE | |
  27043. */
  27044. wrapU: number;
  27045. /**
  27046. * | Value | Type | Description |
  27047. * | ----- | ------------------ | ----------- |
  27048. * | 0 | CLAMP_ADDRESSMODE | |
  27049. * | 1 | WRAP_ADDRESSMODE | |
  27050. * | 2 | MIRROR_ADDRESSMODE | |
  27051. */
  27052. wrapV: number;
  27053. /**
  27054. * | Value | Type | Description |
  27055. * | ----- | ------------------ | ----------- |
  27056. * | 0 | CLAMP_ADDRESSMODE | |
  27057. * | 1 | WRAP_ADDRESSMODE | |
  27058. * | 2 | MIRROR_ADDRESSMODE | |
  27059. */
  27060. wrapR: number;
  27061. /**
  27062. * With compliant hardware and browser (supporting anisotropic filtering)
  27063. * this defines the level of anisotropic filtering in the texture.
  27064. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27065. */
  27066. anisotropicFilteringLevel: number;
  27067. /**
  27068. * Define if the texture is a cube texture or if false a 2d texture.
  27069. */
  27070. isCube: boolean;
  27071. /**
  27072. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27073. */
  27074. is3D: boolean;
  27075. /**
  27076. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27077. * HDR texture are usually stored in linear space.
  27078. * This only impacts the PBR and Background materials
  27079. */
  27080. gammaSpace: boolean;
  27081. /**
  27082. * Gets whether or not the texture contains RGBD data.
  27083. */
  27084. readonly isRGBD: boolean;
  27085. /**
  27086. * Is Z inverted in the texture (useful in a cube texture).
  27087. */
  27088. invertZ: boolean;
  27089. /**
  27090. * Are mip maps generated for this texture or not.
  27091. */
  27092. readonly noMipmap: boolean;
  27093. /**
  27094. * @hidden
  27095. */
  27096. lodLevelInAlpha: boolean;
  27097. /**
  27098. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27099. */
  27100. lodGenerationOffset: number;
  27101. /**
  27102. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27103. */
  27104. lodGenerationScale: number;
  27105. /**
  27106. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27107. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27108. * average roughness values.
  27109. */
  27110. linearSpecularLOD: boolean;
  27111. /**
  27112. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27113. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27114. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27115. */
  27116. irradianceTexture: Nullable<BaseTexture>;
  27117. /**
  27118. * Define if the texture is a render target.
  27119. */
  27120. isRenderTarget: boolean;
  27121. /**
  27122. * Define the unique id of the texture in the scene.
  27123. */
  27124. readonly uid: string;
  27125. /**
  27126. * Return a string representation of the texture.
  27127. * @returns the texture as a string
  27128. */
  27129. toString(): string;
  27130. /**
  27131. * Get the class name of the texture.
  27132. * @returns "BaseTexture"
  27133. */
  27134. getClassName(): string;
  27135. /**
  27136. * Define the list of animation attached to the texture.
  27137. */
  27138. animations: import("babylonjs/Animations/animation").Animation[];
  27139. /**
  27140. * An event triggered when the texture is disposed.
  27141. */
  27142. onDisposeObservable: Observable<BaseTexture>;
  27143. private _onDisposeObserver;
  27144. /**
  27145. * Callback triggered when the texture has been disposed.
  27146. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27147. */
  27148. onDispose: () => void;
  27149. /**
  27150. * Define the current state of the loading sequence when in delayed load mode.
  27151. */
  27152. delayLoadState: number;
  27153. private _scene;
  27154. /** @hidden */
  27155. _texture: Nullable<InternalTexture>;
  27156. private _uid;
  27157. /**
  27158. * Define if the texture is preventinga material to render or not.
  27159. * If not and the texture is not ready, the engine will use a default black texture instead.
  27160. */
  27161. readonly isBlocking: boolean;
  27162. /**
  27163. * Instantiates a new BaseTexture.
  27164. * Base class of all the textures in babylon.
  27165. * It groups all the common properties the materials, post process, lights... might need
  27166. * in order to make a correct use of the texture.
  27167. * @param scene Define the scene the texture blongs to
  27168. */
  27169. constructor(scene: Nullable<Scene>);
  27170. /**
  27171. * Get the scene the texture belongs to.
  27172. * @returns the scene or null if undefined
  27173. */
  27174. getScene(): Nullable<Scene>;
  27175. /**
  27176. * Get the texture transform matrix used to offset tile the texture for istance.
  27177. * @returns the transformation matrix
  27178. */
  27179. getTextureMatrix(): Matrix;
  27180. /**
  27181. * Get the texture reflection matrix used to rotate/transform the reflection.
  27182. * @returns the reflection matrix
  27183. */
  27184. getReflectionTextureMatrix(): Matrix;
  27185. /**
  27186. * Get the underlying lower level texture from Babylon.
  27187. * @returns the insternal texture
  27188. */
  27189. getInternalTexture(): Nullable<InternalTexture>;
  27190. /**
  27191. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27192. * @returns true if ready or not blocking
  27193. */
  27194. isReadyOrNotBlocking(): boolean;
  27195. /**
  27196. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27197. * @returns true if fully ready
  27198. */
  27199. isReady(): boolean;
  27200. private _cachedSize;
  27201. /**
  27202. * Get the size of the texture.
  27203. * @returns the texture size.
  27204. */
  27205. getSize(): ISize;
  27206. /**
  27207. * Get the base size of the texture.
  27208. * It can be different from the size if the texture has been resized for POT for instance
  27209. * @returns the base size
  27210. */
  27211. getBaseSize(): ISize;
  27212. /**
  27213. * Update the sampling mode of the texture.
  27214. * Default is Trilinear mode.
  27215. *
  27216. * | Value | Type | Description |
  27217. * | ----- | ------------------ | ----------- |
  27218. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27219. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27220. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27221. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27222. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27223. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27224. * | 7 | NEAREST_LINEAR | |
  27225. * | 8 | NEAREST_NEAREST | |
  27226. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27227. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27228. * | 11 | LINEAR_LINEAR | |
  27229. * | 12 | LINEAR_NEAREST | |
  27230. *
  27231. * > _mag_: magnification filter (close to the viewer)
  27232. * > _min_: minification filter (far from the viewer)
  27233. * > _mip_: filter used between mip map levels
  27234. *@param samplingMode Define the new sampling mode of the texture
  27235. */
  27236. updateSamplingMode(samplingMode: number): void;
  27237. /**
  27238. * Scales the texture if is `canRescale()`
  27239. * @param ratio the resize factor we want to use to rescale
  27240. */
  27241. scale(ratio: number): void;
  27242. /**
  27243. * Get if the texture can rescale.
  27244. */
  27245. readonly canRescale: boolean;
  27246. /** @hidden */
  27247. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27248. /** @hidden */
  27249. _rebuild(): void;
  27250. /**
  27251. * Triggers the load sequence in delayed load mode.
  27252. */
  27253. delayLoad(): void;
  27254. /**
  27255. * Clones the texture.
  27256. * @returns the cloned texture
  27257. */
  27258. clone(): Nullable<BaseTexture>;
  27259. /**
  27260. * Get the texture underlying type (INT, FLOAT...)
  27261. */
  27262. readonly textureType: number;
  27263. /**
  27264. * Get the texture underlying format (RGB, RGBA...)
  27265. */
  27266. readonly textureFormat: number;
  27267. /**
  27268. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27269. * This will returns an RGBA array buffer containing either in values (0-255) or
  27270. * float values (0-1) depending of the underlying buffer type.
  27271. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27272. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27273. * @param buffer defines a user defined buffer to fill with data (can be null)
  27274. * @returns The Array buffer containing the pixels data.
  27275. */
  27276. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27277. /**
  27278. * Release and destroy the underlying lower level texture aka internalTexture.
  27279. */
  27280. releaseInternalTexture(): void;
  27281. /**
  27282. * Get the polynomial representation of the texture data.
  27283. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27284. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27285. */
  27286. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27287. /** @hidden */
  27288. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27289. /** @hidden */
  27290. readonly _lodTextureMid: Nullable<BaseTexture>;
  27291. /** @hidden */
  27292. readonly _lodTextureLow: Nullable<BaseTexture>;
  27293. /**
  27294. * Dispose the texture and release its associated resources.
  27295. */
  27296. dispose(): void;
  27297. /**
  27298. * Serialize the texture into a JSON representation that can be parsed later on.
  27299. * @returns the JSON representation of the texture
  27300. */
  27301. serialize(): any;
  27302. /**
  27303. * Helper function to be called back once a list of texture contains only ready textures.
  27304. * @param textures Define the list of textures to wait for
  27305. * @param callback Define the callback triggered once the entire list will be ready
  27306. */
  27307. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27308. }
  27309. }
  27310. declare module "babylonjs/Materials/uniformBuffer" {
  27311. import { Nullable, FloatArray } from "babylonjs/types";
  27312. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  27313. import { Engine } from "babylonjs/Engines/engine";
  27314. import { Effect } from "babylonjs/Materials/effect";
  27315. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27316. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27317. /**
  27318. * Uniform buffer objects.
  27319. *
  27320. * Handles blocks of uniform on the GPU.
  27321. *
  27322. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27323. *
  27324. * For more information, please refer to :
  27325. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27326. */
  27327. export class UniformBuffer {
  27328. private _engine;
  27329. private _buffer;
  27330. private _data;
  27331. private _bufferData;
  27332. private _dynamic?;
  27333. private _uniformLocations;
  27334. private _uniformSizes;
  27335. private _uniformLocationPointer;
  27336. private _needSync;
  27337. private _noUBO;
  27338. private _currentEffect;
  27339. private static _MAX_UNIFORM_SIZE;
  27340. private static _tempBuffer;
  27341. /**
  27342. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  27343. * This is dynamic to allow compat with webgl 1 and 2.
  27344. * You will need to pass the name of the uniform as well as the value.
  27345. */
  27346. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  27347. /**
  27348. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  27349. * This is dynamic to allow compat with webgl 1 and 2.
  27350. * You will need to pass the name of the uniform as well as the value.
  27351. */
  27352. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  27353. /**
  27354. * Lambda to Update a single float in a uniform buffer.
  27355. * This is dynamic to allow compat with webgl 1 and 2.
  27356. * You will need to pass the name of the uniform as well as the value.
  27357. */
  27358. updateFloat: (name: string, x: number) => void;
  27359. /**
  27360. * Lambda to Update a vec2 of float in a uniform buffer.
  27361. * This is dynamic to allow compat with webgl 1 and 2.
  27362. * You will need to pass the name of the uniform as well as the value.
  27363. */
  27364. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  27365. /**
  27366. * Lambda to Update a vec3 of float in a uniform buffer.
  27367. * This is dynamic to allow compat with webgl 1 and 2.
  27368. * You will need to pass the name of the uniform as well as the value.
  27369. */
  27370. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  27371. /**
  27372. * Lambda to Update a vec4 of float in a uniform buffer.
  27373. * This is dynamic to allow compat with webgl 1 and 2.
  27374. * You will need to pass the name of the uniform as well as the value.
  27375. */
  27376. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  27377. /**
  27378. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  27379. * This is dynamic to allow compat with webgl 1 and 2.
  27380. * You will need to pass the name of the uniform as well as the value.
  27381. */
  27382. updateMatrix: (name: string, mat: Matrix) => void;
  27383. /**
  27384. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  27385. * This is dynamic to allow compat with webgl 1 and 2.
  27386. * You will need to pass the name of the uniform as well as the value.
  27387. */
  27388. updateVector3: (name: string, vector: Vector3) => void;
  27389. /**
  27390. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  27391. * This is dynamic to allow compat with webgl 1 and 2.
  27392. * You will need to pass the name of the uniform as well as the value.
  27393. */
  27394. updateVector4: (name: string, vector: Vector4) => void;
  27395. /**
  27396. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  27397. * This is dynamic to allow compat with webgl 1 and 2.
  27398. * You will need to pass the name of the uniform as well as the value.
  27399. */
  27400. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  27401. /**
  27402. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  27403. * This is dynamic to allow compat with webgl 1 and 2.
  27404. * You will need to pass the name of the uniform as well as the value.
  27405. */
  27406. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  27407. /**
  27408. * Instantiates a new Uniform buffer objects.
  27409. *
  27410. * Handles blocks of uniform on the GPU.
  27411. *
  27412. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27413. *
  27414. * For more information, please refer to :
  27415. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27416. * @param engine Define the engine the buffer is associated with
  27417. * @param data Define the data contained in the buffer
  27418. * @param dynamic Define if the buffer is updatable
  27419. */
  27420. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  27421. /**
  27422. * Indicates if the buffer is using the WebGL2 UBO implementation,
  27423. * or just falling back on setUniformXXX calls.
  27424. */
  27425. readonly useUbo: boolean;
  27426. /**
  27427. * Indicates if the WebGL underlying uniform buffer is in sync
  27428. * with the javascript cache data.
  27429. */
  27430. readonly isSync: boolean;
  27431. /**
  27432. * Indicates if the WebGL underlying uniform buffer is dynamic.
  27433. * Also, a dynamic UniformBuffer will disable cache verification and always
  27434. * update the underlying WebGL uniform buffer to the GPU.
  27435. * @returns if Dynamic, otherwise false
  27436. */
  27437. isDynamic(): boolean;
  27438. /**
  27439. * The data cache on JS side.
  27440. * @returns the underlying data as a float array
  27441. */
  27442. getData(): Float32Array;
  27443. /**
  27444. * The underlying WebGL Uniform buffer.
  27445. * @returns the webgl buffer
  27446. */
  27447. getBuffer(): Nullable<DataBuffer>;
  27448. /**
  27449. * std140 layout specifies how to align data within an UBO structure.
  27450. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  27451. * for specs.
  27452. */
  27453. private _fillAlignment;
  27454. /**
  27455. * Adds an uniform in the buffer.
  27456. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  27457. * for the layout to be correct !
  27458. * @param name Name of the uniform, as used in the uniform block in the shader.
  27459. * @param size Data size, or data directly.
  27460. */
  27461. addUniform(name: string, size: number | number[]): void;
  27462. /**
  27463. * Adds a Matrix 4x4 to the uniform buffer.
  27464. * @param name Name of the uniform, as used in the uniform block in the shader.
  27465. * @param mat A 4x4 matrix.
  27466. */
  27467. addMatrix(name: string, mat: Matrix): void;
  27468. /**
  27469. * Adds a vec2 to the uniform buffer.
  27470. * @param name Name of the uniform, as used in the uniform block in the shader.
  27471. * @param x Define the x component value of the vec2
  27472. * @param y Define the y component value of the vec2
  27473. */
  27474. addFloat2(name: string, x: number, y: number): void;
  27475. /**
  27476. * Adds a vec3 to the uniform buffer.
  27477. * @param name Name of the uniform, as used in the uniform block in the shader.
  27478. * @param x Define the x component value of the vec3
  27479. * @param y Define the y component value of the vec3
  27480. * @param z Define the z component value of the vec3
  27481. */
  27482. addFloat3(name: string, x: number, y: number, z: number): void;
  27483. /**
  27484. * Adds a vec3 to the uniform buffer.
  27485. * @param name Name of the uniform, as used in the uniform block in the shader.
  27486. * @param color Define the vec3 from a Color
  27487. */
  27488. addColor3(name: string, color: Color3): void;
  27489. /**
  27490. * Adds a vec4 to the uniform buffer.
  27491. * @param name Name of the uniform, as used in the uniform block in the shader.
  27492. * @param color Define the rgb components from a Color
  27493. * @param alpha Define the a component of the vec4
  27494. */
  27495. addColor4(name: string, color: Color3, alpha: number): void;
  27496. /**
  27497. * Adds a vec3 to the uniform buffer.
  27498. * @param name Name of the uniform, as used in the uniform block in the shader.
  27499. * @param vector Define the vec3 components from a Vector
  27500. */
  27501. addVector3(name: string, vector: Vector3): void;
  27502. /**
  27503. * Adds a Matrix 3x3 to the uniform buffer.
  27504. * @param name Name of the uniform, as used in the uniform block in the shader.
  27505. */
  27506. addMatrix3x3(name: string): void;
  27507. /**
  27508. * Adds a Matrix 2x2 to the uniform buffer.
  27509. * @param name Name of the uniform, as used in the uniform block in the shader.
  27510. */
  27511. addMatrix2x2(name: string): void;
  27512. /**
  27513. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  27514. */
  27515. create(): void;
  27516. /** @hidden */
  27517. _rebuild(): void;
  27518. /**
  27519. * Updates the WebGL Uniform Buffer on the GPU.
  27520. * If the `dynamic` flag is set to true, no cache comparison is done.
  27521. * Otherwise, the buffer will be updated only if the cache differs.
  27522. */
  27523. update(): void;
  27524. /**
  27525. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  27526. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27527. * @param data Define the flattened data
  27528. * @param size Define the size of the data.
  27529. */
  27530. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  27531. private _updateMatrix3x3ForUniform;
  27532. private _updateMatrix3x3ForEffect;
  27533. private _updateMatrix2x2ForEffect;
  27534. private _updateMatrix2x2ForUniform;
  27535. private _updateFloatForEffect;
  27536. private _updateFloatForUniform;
  27537. private _updateFloat2ForEffect;
  27538. private _updateFloat2ForUniform;
  27539. private _updateFloat3ForEffect;
  27540. private _updateFloat3ForUniform;
  27541. private _updateFloat4ForEffect;
  27542. private _updateFloat4ForUniform;
  27543. private _updateMatrixForEffect;
  27544. private _updateMatrixForUniform;
  27545. private _updateVector3ForEffect;
  27546. private _updateVector3ForUniform;
  27547. private _updateVector4ForEffect;
  27548. private _updateVector4ForUniform;
  27549. private _updateColor3ForEffect;
  27550. private _updateColor3ForUniform;
  27551. private _updateColor4ForEffect;
  27552. private _updateColor4ForUniform;
  27553. /**
  27554. * Sets a sampler uniform on the effect.
  27555. * @param name Define the name of the sampler.
  27556. * @param texture Define the texture to set in the sampler
  27557. */
  27558. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  27559. /**
  27560. * Directly updates the value of the uniform in the cache AND on the GPU.
  27561. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27562. * @param data Define the flattened data
  27563. */
  27564. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  27565. /**
  27566. * Binds this uniform buffer to an effect.
  27567. * @param effect Define the effect to bind the buffer to
  27568. * @param name Name of the uniform block in the shader.
  27569. */
  27570. bindToEffect(effect: Effect, name: string): void;
  27571. /**
  27572. * Disposes the uniform buffer.
  27573. */
  27574. dispose(): void;
  27575. }
  27576. }
  27577. declare module "babylonjs/Audio/analyser" {
  27578. import { Scene } from "babylonjs/scene";
  27579. /**
  27580. * Class used to work with sound analyzer using fast fourier transform (FFT)
  27581. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27582. */
  27583. export class Analyser {
  27584. /**
  27585. * Gets or sets the smoothing
  27586. * @ignorenaming
  27587. */
  27588. SMOOTHING: number;
  27589. /**
  27590. * Gets or sets the FFT table size
  27591. * @ignorenaming
  27592. */
  27593. FFT_SIZE: number;
  27594. /**
  27595. * Gets or sets the bar graph amplitude
  27596. * @ignorenaming
  27597. */
  27598. BARGRAPHAMPLITUDE: number;
  27599. /**
  27600. * Gets or sets the position of the debug canvas
  27601. * @ignorenaming
  27602. */
  27603. DEBUGCANVASPOS: {
  27604. x: number;
  27605. y: number;
  27606. };
  27607. /**
  27608. * Gets or sets the debug canvas size
  27609. * @ignorenaming
  27610. */
  27611. DEBUGCANVASSIZE: {
  27612. width: number;
  27613. height: number;
  27614. };
  27615. private _byteFreqs;
  27616. private _byteTime;
  27617. private _floatFreqs;
  27618. private _webAudioAnalyser;
  27619. private _debugCanvas;
  27620. private _debugCanvasContext;
  27621. private _scene;
  27622. private _registerFunc;
  27623. private _audioEngine;
  27624. /**
  27625. * Creates a new analyser
  27626. * @param scene defines hosting scene
  27627. */
  27628. constructor(scene: Scene);
  27629. /**
  27630. * Get the number of data values you will have to play with for the visualization
  27631. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27632. * @returns a number
  27633. */
  27634. getFrequencyBinCount(): number;
  27635. /**
  27636. * Gets the current frequency data as a byte array
  27637. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27638. * @returns a Uint8Array
  27639. */
  27640. getByteFrequencyData(): Uint8Array;
  27641. /**
  27642. * Gets the current waveform as a byte array
  27643. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27644. * @returns a Uint8Array
  27645. */
  27646. getByteTimeDomainData(): Uint8Array;
  27647. /**
  27648. * Gets the current frequency data as a float array
  27649. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27650. * @returns a Float32Array
  27651. */
  27652. getFloatFrequencyData(): Float32Array;
  27653. /**
  27654. * Renders the debug canvas
  27655. */
  27656. drawDebugCanvas(): void;
  27657. /**
  27658. * Stops rendering the debug canvas and removes it
  27659. */
  27660. stopDebugCanvas(): void;
  27661. /**
  27662. * Connects two audio nodes
  27663. * @param inputAudioNode defines first node to connect
  27664. * @param outputAudioNode defines second node to connect
  27665. */
  27666. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27667. /**
  27668. * Releases all associated resources
  27669. */
  27670. dispose(): void;
  27671. }
  27672. }
  27673. declare module "babylonjs/Audio/audioEngine" {
  27674. import { IDisposable } from "babylonjs/scene";
  27675. import { Analyser } from "babylonjs/Audio/analyser";
  27676. import { Nullable } from "babylonjs/types";
  27677. import { Observable } from "babylonjs/Misc/observable";
  27678. /**
  27679. * This represents an audio engine and it is responsible
  27680. * to play, synchronize and analyse sounds throughout the application.
  27681. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27682. */
  27683. export interface IAudioEngine extends IDisposable {
  27684. /**
  27685. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27686. */
  27687. readonly canUseWebAudio: boolean;
  27688. /**
  27689. * Gets the current AudioContext if available.
  27690. */
  27691. readonly audioContext: Nullable<AudioContext>;
  27692. /**
  27693. * The master gain node defines the global audio volume of your audio engine.
  27694. */
  27695. readonly masterGain: GainNode;
  27696. /**
  27697. * Gets whether or not mp3 are supported by your browser.
  27698. */
  27699. readonly isMP3supported: boolean;
  27700. /**
  27701. * Gets whether or not ogg are supported by your browser.
  27702. */
  27703. readonly isOGGsupported: boolean;
  27704. /**
  27705. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27706. * @ignoreNaming
  27707. */
  27708. WarnedWebAudioUnsupported: boolean;
  27709. /**
  27710. * Defines if the audio engine relies on a custom unlocked button.
  27711. * In this case, the embedded button will not be displayed.
  27712. */
  27713. useCustomUnlockedButton: boolean;
  27714. /**
  27715. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27716. */
  27717. readonly unlocked: boolean;
  27718. /**
  27719. * Event raised when audio has been unlocked on the browser.
  27720. */
  27721. onAudioUnlockedObservable: Observable<AudioEngine>;
  27722. /**
  27723. * Event raised when audio has been locked on the browser.
  27724. */
  27725. onAudioLockedObservable: Observable<AudioEngine>;
  27726. /**
  27727. * Flags the audio engine in Locked state.
  27728. * This happens due to new browser policies preventing audio to autoplay.
  27729. */
  27730. lock(): void;
  27731. /**
  27732. * Unlocks the audio engine once a user action has been done on the dom.
  27733. * This is helpful to resume play once browser policies have been satisfied.
  27734. */
  27735. unlock(): void;
  27736. }
  27737. /**
  27738. * This represents the default audio engine used in babylon.
  27739. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27740. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27741. */
  27742. export class AudioEngine implements IAudioEngine {
  27743. private _audioContext;
  27744. private _audioContextInitialized;
  27745. private _muteButton;
  27746. private _hostElement;
  27747. /**
  27748. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27749. */
  27750. canUseWebAudio: boolean;
  27751. /**
  27752. * The master gain node defines the global audio volume of your audio engine.
  27753. */
  27754. masterGain: GainNode;
  27755. /**
  27756. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27757. * @ignoreNaming
  27758. */
  27759. WarnedWebAudioUnsupported: boolean;
  27760. /**
  27761. * Gets whether or not mp3 are supported by your browser.
  27762. */
  27763. isMP3supported: boolean;
  27764. /**
  27765. * Gets whether or not ogg are supported by your browser.
  27766. */
  27767. isOGGsupported: boolean;
  27768. /**
  27769. * Gets whether audio has been unlocked on the device.
  27770. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27771. * a user interaction has happened.
  27772. */
  27773. unlocked: boolean;
  27774. /**
  27775. * Defines if the audio engine relies on a custom unlocked button.
  27776. * In this case, the embedded button will not be displayed.
  27777. */
  27778. useCustomUnlockedButton: boolean;
  27779. /**
  27780. * Event raised when audio has been unlocked on the browser.
  27781. */
  27782. onAudioUnlockedObservable: Observable<AudioEngine>;
  27783. /**
  27784. * Event raised when audio has been locked on the browser.
  27785. */
  27786. onAudioLockedObservable: Observable<AudioEngine>;
  27787. /**
  27788. * Gets the current AudioContext if available.
  27789. */
  27790. readonly audioContext: Nullable<AudioContext>;
  27791. private _connectedAnalyser;
  27792. /**
  27793. * Instantiates a new audio engine.
  27794. *
  27795. * There should be only one per page as some browsers restrict the number
  27796. * of audio contexts you can create.
  27797. * @param hostElement defines the host element where to display the mute icon if necessary
  27798. */
  27799. constructor(hostElement?: Nullable<HTMLElement>);
  27800. /**
  27801. * Flags the audio engine in Locked state.
  27802. * This happens due to new browser policies preventing audio to autoplay.
  27803. */
  27804. lock(): void;
  27805. /**
  27806. * Unlocks the audio engine once a user action has been done on the dom.
  27807. * This is helpful to resume play once browser policies have been satisfied.
  27808. */
  27809. unlock(): void;
  27810. private _resumeAudioContext;
  27811. private _initializeAudioContext;
  27812. private _tryToRun;
  27813. private _triggerRunningState;
  27814. private _triggerSuspendedState;
  27815. private _displayMuteButton;
  27816. private _moveButtonToTopLeft;
  27817. private _onResize;
  27818. private _hideMuteButton;
  27819. /**
  27820. * Destroy and release the resources associated with the audio ccontext.
  27821. */
  27822. dispose(): void;
  27823. /**
  27824. * Gets the global volume sets on the master gain.
  27825. * @returns the global volume if set or -1 otherwise
  27826. */
  27827. getGlobalVolume(): number;
  27828. /**
  27829. * Sets the global volume of your experience (sets on the master gain).
  27830. * @param newVolume Defines the new global volume of the application
  27831. */
  27832. setGlobalVolume(newVolume: number): void;
  27833. /**
  27834. * Connect the audio engine to an audio analyser allowing some amazing
  27835. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27836. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27837. * @param analyser The analyser to connect to the engine
  27838. */
  27839. connectToAnalyser(analyser: Analyser): void;
  27840. }
  27841. }
  27842. declare module "babylonjs/Loading/loadingScreen" {
  27843. /**
  27844. * Interface used to present a loading screen while loading a scene
  27845. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27846. */
  27847. export interface ILoadingScreen {
  27848. /**
  27849. * Function called to display the loading screen
  27850. */
  27851. displayLoadingUI: () => void;
  27852. /**
  27853. * Function called to hide the loading screen
  27854. */
  27855. hideLoadingUI: () => void;
  27856. /**
  27857. * Gets or sets the color to use for the background
  27858. */
  27859. loadingUIBackgroundColor: string;
  27860. /**
  27861. * Gets or sets the text to display while loading
  27862. */
  27863. loadingUIText: string;
  27864. }
  27865. /**
  27866. * Class used for the default loading screen
  27867. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27868. */
  27869. export class DefaultLoadingScreen implements ILoadingScreen {
  27870. private _renderingCanvas;
  27871. private _loadingText;
  27872. private _loadingDivBackgroundColor;
  27873. private _loadingDiv;
  27874. private _loadingTextDiv;
  27875. /** Gets or sets the logo url to use for the default loading screen */
  27876. static DefaultLogoUrl: string;
  27877. /** Gets or sets the spinner url to use for the default loading screen */
  27878. static DefaultSpinnerUrl: string;
  27879. /**
  27880. * Creates a new default loading screen
  27881. * @param _renderingCanvas defines the canvas used to render the scene
  27882. * @param _loadingText defines the default text to display
  27883. * @param _loadingDivBackgroundColor defines the default background color
  27884. */
  27885. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27886. /**
  27887. * Function called to display the loading screen
  27888. */
  27889. displayLoadingUI(): void;
  27890. /**
  27891. * Function called to hide the loading screen
  27892. */
  27893. hideLoadingUI(): void;
  27894. /**
  27895. * Gets or sets the text to display while loading
  27896. */
  27897. loadingUIText: string;
  27898. /**
  27899. * Gets or sets the color to use for the background
  27900. */
  27901. loadingUIBackgroundColor: string;
  27902. private _resizeLoadingUI;
  27903. }
  27904. }
  27905. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  27906. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27907. import { Engine } from "babylonjs/Engines/engine";
  27908. import { Nullable } from "babylonjs/types";
  27909. /** @hidden */
  27910. export class WebGLPipelineContext implements IPipelineContext {
  27911. engine: Engine;
  27912. program: Nullable<WebGLProgram>;
  27913. context?: WebGLRenderingContext;
  27914. vertexShader?: WebGLShader;
  27915. fragmentShader?: WebGLShader;
  27916. isParallelCompiled: boolean;
  27917. onCompiled?: () => void;
  27918. transformFeedback?: WebGLTransformFeedback | null;
  27919. readonly isAsync: boolean;
  27920. readonly isReady: boolean;
  27921. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27922. }
  27923. }
  27924. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  27925. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27926. /** @hidden */
  27927. export class WebGLDataBuffer extends DataBuffer {
  27928. private _buffer;
  27929. constructor(resource: WebGLBuffer);
  27930. readonly underlyingResource: any;
  27931. }
  27932. }
  27933. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  27934. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  27935. /** @hidden */
  27936. export class WebGL2ShaderProcessor implements IShaderProcessor {
  27937. attributeProcessor(attribute: string): string;
  27938. varyingProcessor(varying: string, isFragment: boolean): string;
  27939. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  27940. }
  27941. }
  27942. declare module "babylonjs/Materials/Textures/videoTexture" {
  27943. import { Observable } from "babylonjs/Misc/observable";
  27944. import { Nullable } from "babylonjs/types";
  27945. import { Scene } from "babylonjs/scene";
  27946. import { Texture } from "babylonjs/Materials/Textures/texture";
  27947. /**
  27948. * Settings for finer control over video usage
  27949. */
  27950. export interface VideoTextureSettings {
  27951. /**
  27952. * Applies `autoplay` to video, if specified
  27953. */
  27954. autoPlay?: boolean;
  27955. /**
  27956. * Applies `loop` to video, if specified
  27957. */
  27958. loop?: boolean;
  27959. /**
  27960. * Automatically updates internal texture from video at every frame in the render loop
  27961. */
  27962. autoUpdateTexture: boolean;
  27963. /**
  27964. * Image src displayed during the video loading or until the user interacts with the video.
  27965. */
  27966. poster?: string;
  27967. }
  27968. /**
  27969. * If you want to display a video in your scene, this is the special texture for that.
  27970. * This special texture works similar to other textures, with the exception of a few parameters.
  27971. * @see https://doc.babylonjs.com/how_to/video_texture
  27972. */
  27973. export class VideoTexture extends Texture {
  27974. /**
  27975. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27976. */
  27977. readonly autoUpdateTexture: boolean;
  27978. /**
  27979. * The video instance used by the texture internally
  27980. */
  27981. readonly video: HTMLVideoElement;
  27982. private _onUserActionRequestedObservable;
  27983. /**
  27984. * Event triggerd when a dom action is required by the user to play the video.
  27985. * This happens due to recent changes in browser policies preventing video to auto start.
  27986. */
  27987. readonly onUserActionRequestedObservable: Observable<Texture>;
  27988. private _generateMipMaps;
  27989. private _engine;
  27990. private _stillImageCaptured;
  27991. private _displayingPosterTexture;
  27992. private _settings;
  27993. private _createInternalTextureOnEvent;
  27994. /**
  27995. * Creates a video texture.
  27996. * If you want to display a video in your scene, this is the special texture for that.
  27997. * This special texture works similar to other textures, with the exception of a few parameters.
  27998. * @see https://doc.babylonjs.com/how_to/video_texture
  27999. * @param name optional name, will detect from video source, if not defined
  28000. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  28001. * @param scene is obviously the current scene.
  28002. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  28003. * @param invertY is false by default but can be used to invert video on Y axis
  28004. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  28005. * @param settings allows finer control over video usage
  28006. */
  28007. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  28008. private _getName;
  28009. private _getVideo;
  28010. private _createInternalTexture;
  28011. private reset;
  28012. /**
  28013. * @hidden Internal method to initiate `update`.
  28014. */
  28015. _rebuild(): void;
  28016. /**
  28017. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  28018. */
  28019. update(): void;
  28020. /**
  28021. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  28022. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  28023. */
  28024. updateTexture(isVisible: boolean): void;
  28025. protected _updateInternalTexture: () => void;
  28026. /**
  28027. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  28028. * @param url New url.
  28029. */
  28030. updateURL(url: string): void;
  28031. /**
  28032. * Dispose the texture and release its associated resources.
  28033. */
  28034. dispose(): void;
  28035. /**
  28036. * Creates a video texture straight from a stream.
  28037. * @param scene Define the scene the texture should be created in
  28038. * @param stream Define the stream the texture should be created from
  28039. * @returns The created video texture as a promise
  28040. */
  28041. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  28042. /**
  28043. * Creates a video texture straight from your WebCam video feed.
  28044. * @param scene Define the scene the texture should be created in
  28045. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28046. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28047. * @returns The created video texture as a promise
  28048. */
  28049. static CreateFromWebCamAsync(scene: Scene, constraints: {
  28050. minWidth: number;
  28051. maxWidth: number;
  28052. minHeight: number;
  28053. maxHeight: number;
  28054. deviceId: string;
  28055. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  28056. /**
  28057. * Creates a video texture straight from your WebCam video feed.
  28058. * @param scene Define the scene the texture should be created in
  28059. * @param onReady Define a callback to triggered once the texture will be ready
  28060. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28061. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28062. */
  28063. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  28064. minWidth: number;
  28065. maxWidth: number;
  28066. minHeight: number;
  28067. maxHeight: number;
  28068. deviceId: string;
  28069. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  28070. }
  28071. }
  28072. declare module "babylonjs/Engines/engine" {
  28073. import { Observable } from "babylonjs/Misc/observable";
  28074. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  28075. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  28076. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  28077. import { Camera } from "babylonjs/Cameras/camera";
  28078. import { Scene } from "babylonjs/scene";
  28079. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  28080. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28081. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  28082. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  28083. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  28084. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28085. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28086. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  28087. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  28088. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  28089. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  28090. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  28091. import { WebRequest } from "babylonjs/Misc/webRequest";
  28092. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  28093. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28094. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28095. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  28096. import { Material } from "babylonjs/Materials/material";
  28097. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28098. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28099. /**
  28100. * Interface for attribute information associated with buffer instanciation
  28101. */
  28102. export class InstancingAttributeInfo {
  28103. /**
  28104. * Index/offset of the attribute in the vertex shader
  28105. */
  28106. index: number;
  28107. /**
  28108. * size of the attribute, 1, 2, 3 or 4
  28109. */
  28110. attributeSize: number;
  28111. /**
  28112. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  28113. * default is FLOAT
  28114. */
  28115. attribyteType: number;
  28116. /**
  28117. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  28118. */
  28119. normalized: boolean;
  28120. /**
  28121. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28122. */
  28123. offset: number;
  28124. /**
  28125. * Name of the GLSL attribute, for debugging purpose only
  28126. */
  28127. attributeName: string;
  28128. }
  28129. /**
  28130. * Define options used to create a depth texture
  28131. */
  28132. export class DepthTextureCreationOptions {
  28133. /** Specifies whether or not a stencil should be allocated in the texture */
  28134. generateStencil?: boolean;
  28135. /** Specifies whether or not bilinear filtering is enable on the texture */
  28136. bilinearFiltering?: boolean;
  28137. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  28138. comparisonFunction?: number;
  28139. /** Specifies if the created texture is a cube texture */
  28140. isCube?: boolean;
  28141. }
  28142. /**
  28143. * Class used to describe the capabilities of the engine relatively to the current browser
  28144. */
  28145. export class EngineCapabilities {
  28146. /** Maximum textures units per fragment shader */
  28147. maxTexturesImageUnits: number;
  28148. /** Maximum texture units per vertex shader */
  28149. maxVertexTextureImageUnits: number;
  28150. /** Maximum textures units in the entire pipeline */
  28151. maxCombinedTexturesImageUnits: number;
  28152. /** Maximum texture size */
  28153. maxTextureSize: number;
  28154. /** Maximum cube texture size */
  28155. maxCubemapTextureSize: number;
  28156. /** Maximum render texture size */
  28157. maxRenderTextureSize: number;
  28158. /** Maximum number of vertex attributes */
  28159. maxVertexAttribs: number;
  28160. /** Maximum number of varyings */
  28161. maxVaryingVectors: number;
  28162. /** Maximum number of uniforms per vertex shader */
  28163. maxVertexUniformVectors: number;
  28164. /** Maximum number of uniforms per fragment shader */
  28165. maxFragmentUniformVectors: number;
  28166. /** Defines if standard derivates (dx/dy) are supported */
  28167. standardDerivatives: boolean;
  28168. /** Defines if s3tc texture compression is supported */
  28169. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  28170. /** Defines if pvrtc texture compression is supported */
  28171. pvrtc: any;
  28172. /** Defines if etc1 texture compression is supported */
  28173. etc1: any;
  28174. /** Defines if etc2 texture compression is supported */
  28175. etc2: any;
  28176. /** Defines if astc texture compression is supported */
  28177. astc: any;
  28178. /** Defines if float textures are supported */
  28179. textureFloat: boolean;
  28180. /** Defines if vertex array objects are supported */
  28181. vertexArrayObject: boolean;
  28182. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28183. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  28184. /** Gets the maximum level of anisotropy supported */
  28185. maxAnisotropy: number;
  28186. /** Defines if instancing is supported */
  28187. instancedArrays: boolean;
  28188. /** Defines if 32 bits indices are supported */
  28189. uintIndices: boolean;
  28190. /** Defines if high precision shaders are supported */
  28191. highPrecisionShaderSupported: boolean;
  28192. /** Defines if depth reading in the fragment shader is supported */
  28193. fragmentDepthSupported: boolean;
  28194. /** Defines if float texture linear filtering is supported*/
  28195. textureFloatLinearFiltering: boolean;
  28196. /** Defines if rendering to float textures is supported */
  28197. textureFloatRender: boolean;
  28198. /** Defines if half float textures are supported*/
  28199. textureHalfFloat: boolean;
  28200. /** Defines if half float texture linear filtering is supported*/
  28201. textureHalfFloatLinearFiltering: boolean;
  28202. /** Defines if rendering to half float textures is supported */
  28203. textureHalfFloatRender: boolean;
  28204. /** Defines if textureLOD shader command is supported */
  28205. textureLOD: boolean;
  28206. /** Defines if draw buffers extension is supported */
  28207. drawBuffersExtension: boolean;
  28208. /** Defines if depth textures are supported */
  28209. depthTextureExtension: boolean;
  28210. /** Defines if float color buffer are supported */
  28211. colorBufferFloat: boolean;
  28212. /** Gets disjoint timer query extension (null if not supported) */
  28213. timerQuery: EXT_disjoint_timer_query;
  28214. /** Defines if timestamp can be used with timer query */
  28215. canUseTimestampForTimerQuery: boolean;
  28216. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28217. multiview: any;
  28218. /** Function used to let the system compiles shaders in background */
  28219. parallelShaderCompile: {
  28220. COMPLETION_STATUS_KHR: number;
  28221. };
  28222. }
  28223. /** Interface defining initialization parameters for Engine class */
  28224. export interface EngineOptions extends WebGLContextAttributes {
  28225. /**
  28226. * Defines if the engine should no exceed a specified device ratio
  28227. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  28228. */
  28229. limitDeviceRatio?: number;
  28230. /**
  28231. * Defines if webvr should be enabled automatically
  28232. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28233. */
  28234. autoEnableWebVR?: boolean;
  28235. /**
  28236. * Defines if webgl2 should be turned off even if supported
  28237. * @see http://doc.babylonjs.com/features/webgl2
  28238. */
  28239. disableWebGL2Support?: boolean;
  28240. /**
  28241. * Defines if webaudio should be initialized as well
  28242. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28243. */
  28244. audioEngine?: boolean;
  28245. /**
  28246. * Defines if animations should run using a deterministic lock step
  28247. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28248. */
  28249. deterministicLockstep?: boolean;
  28250. /** Defines the maximum steps to use with deterministic lock step mode */
  28251. lockstepMaxSteps?: number;
  28252. /**
  28253. * Defines that engine should ignore context lost events
  28254. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  28255. */
  28256. doNotHandleContextLost?: boolean;
  28257. /**
  28258. * Defines that engine should ignore modifying touch action attribute and style
  28259. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  28260. */
  28261. doNotHandleTouchAction?: boolean;
  28262. /**
  28263. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  28264. */
  28265. useHighPrecisionFloats?: boolean;
  28266. }
  28267. /**
  28268. * Defines the interface used by display changed events
  28269. */
  28270. export interface IDisplayChangedEventArgs {
  28271. /** Gets the vrDisplay object (if any) */
  28272. vrDisplay: Nullable<any>;
  28273. /** Gets a boolean indicating if webVR is supported */
  28274. vrSupported: boolean;
  28275. }
  28276. /**
  28277. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  28278. */
  28279. export class Engine {
  28280. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  28281. static ExceptionList: ({
  28282. key: string;
  28283. capture: string;
  28284. captureConstraint: number;
  28285. targets: string[];
  28286. } | {
  28287. key: string;
  28288. capture: null;
  28289. captureConstraint: null;
  28290. targets: string[];
  28291. })[];
  28292. /** Gets the list of created engines */
  28293. static readonly Instances: Engine[];
  28294. /**
  28295. * Gets the latest created engine
  28296. */
  28297. static readonly LastCreatedEngine: Nullable<Engine>;
  28298. /**
  28299. * Gets the latest created scene
  28300. */
  28301. static readonly LastCreatedScene: Nullable<Scene>;
  28302. /**
  28303. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  28304. * @param flag defines which part of the materials must be marked as dirty
  28305. * @param predicate defines a predicate used to filter which materials should be affected
  28306. */
  28307. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  28308. /** @hidden */
  28309. static _TextureLoaders: IInternalTextureLoader[];
  28310. /** Defines that alpha blending is disabled */
  28311. static readonly ALPHA_DISABLE: number;
  28312. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  28313. static readonly ALPHA_ADD: number;
  28314. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  28315. static readonly ALPHA_COMBINE: number;
  28316. /** Defines that alpha blending to DEST - SRC * DEST */
  28317. static readonly ALPHA_SUBTRACT: number;
  28318. /** Defines that alpha blending to SRC * DEST */
  28319. static readonly ALPHA_MULTIPLY: number;
  28320. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  28321. static readonly ALPHA_MAXIMIZED: number;
  28322. /** Defines that alpha blending to SRC + DEST */
  28323. static readonly ALPHA_ONEONE: number;
  28324. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  28325. static readonly ALPHA_PREMULTIPLIED: number;
  28326. /**
  28327. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  28328. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  28329. */
  28330. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  28331. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  28332. static readonly ALPHA_INTERPOLATE: number;
  28333. /**
  28334. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  28335. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  28336. */
  28337. static readonly ALPHA_SCREENMODE: number;
  28338. /** Defines that the ressource is not delayed*/
  28339. static readonly DELAYLOADSTATE_NONE: number;
  28340. /** Defines that the ressource was successfully delay loaded */
  28341. static readonly DELAYLOADSTATE_LOADED: number;
  28342. /** Defines that the ressource is currently delay loading */
  28343. static readonly DELAYLOADSTATE_LOADING: number;
  28344. /** Defines that the ressource is delayed and has not started loading */
  28345. static readonly DELAYLOADSTATE_NOTLOADED: number;
  28346. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  28347. static readonly NEVER: number;
  28348. /** 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 */
  28349. static readonly ALWAYS: number;
  28350. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  28351. static readonly LESS: number;
  28352. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  28353. static readonly EQUAL: number;
  28354. /** 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 */
  28355. static readonly LEQUAL: number;
  28356. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  28357. static readonly GREATER: number;
  28358. /** 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 */
  28359. static readonly GEQUAL: number;
  28360. /** 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 */
  28361. static readonly NOTEQUAL: number;
  28362. /** Passed to stencilOperation to specify that stencil value must be kept */
  28363. static readonly KEEP: number;
  28364. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28365. static readonly REPLACE: number;
  28366. /** Passed to stencilOperation to specify that stencil value must be incremented */
  28367. static readonly INCR: number;
  28368. /** Passed to stencilOperation to specify that stencil value must be decremented */
  28369. static readonly DECR: number;
  28370. /** Passed to stencilOperation to specify that stencil value must be inverted */
  28371. static readonly INVERT: number;
  28372. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  28373. static readonly INCR_WRAP: number;
  28374. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  28375. static readonly DECR_WRAP: number;
  28376. /** Texture is not repeating outside of 0..1 UVs */
  28377. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  28378. /** Texture is repeating outside of 0..1 UVs */
  28379. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  28380. /** Texture is repeating and mirrored */
  28381. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  28382. /** ALPHA */
  28383. static readonly TEXTUREFORMAT_ALPHA: number;
  28384. /** LUMINANCE */
  28385. static readonly TEXTUREFORMAT_LUMINANCE: number;
  28386. /** LUMINANCE_ALPHA */
  28387. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  28388. /** RGB */
  28389. static readonly TEXTUREFORMAT_RGB: number;
  28390. /** RGBA */
  28391. static readonly TEXTUREFORMAT_RGBA: number;
  28392. /** RED */
  28393. static readonly TEXTUREFORMAT_RED: number;
  28394. /** RED (2nd reference) */
  28395. static readonly TEXTUREFORMAT_R: number;
  28396. /** RG */
  28397. static readonly TEXTUREFORMAT_RG: number;
  28398. /** RED_INTEGER */
  28399. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  28400. /** RED_INTEGER (2nd reference) */
  28401. static readonly TEXTUREFORMAT_R_INTEGER: number;
  28402. /** RG_INTEGER */
  28403. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  28404. /** RGB_INTEGER */
  28405. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  28406. /** RGBA_INTEGER */
  28407. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  28408. /** UNSIGNED_BYTE */
  28409. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  28410. /** UNSIGNED_BYTE (2nd reference) */
  28411. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  28412. /** FLOAT */
  28413. static readonly TEXTURETYPE_FLOAT: number;
  28414. /** HALF_FLOAT */
  28415. static readonly TEXTURETYPE_HALF_FLOAT: number;
  28416. /** BYTE */
  28417. static readonly TEXTURETYPE_BYTE: number;
  28418. /** SHORT */
  28419. static readonly TEXTURETYPE_SHORT: number;
  28420. /** UNSIGNED_SHORT */
  28421. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  28422. /** INT */
  28423. static readonly TEXTURETYPE_INT: number;
  28424. /** UNSIGNED_INT */
  28425. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  28426. /** UNSIGNED_SHORT_4_4_4_4 */
  28427. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  28428. /** UNSIGNED_SHORT_5_5_5_1 */
  28429. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  28430. /** UNSIGNED_SHORT_5_6_5 */
  28431. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  28432. /** UNSIGNED_INT_2_10_10_10_REV */
  28433. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  28434. /** UNSIGNED_INT_24_8 */
  28435. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  28436. /** UNSIGNED_INT_10F_11F_11F_REV */
  28437. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  28438. /** UNSIGNED_INT_5_9_9_9_REV */
  28439. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  28440. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  28441. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  28442. /** nearest is mag = nearest and min = nearest and mip = linear */
  28443. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  28444. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28445. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  28446. /** Trilinear is mag = linear and min = linear and mip = linear */
  28447. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  28448. /** nearest is mag = nearest and min = nearest and mip = linear */
  28449. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  28450. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28451. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  28452. /** Trilinear is mag = linear and min = linear and mip = linear */
  28453. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  28454. /** mag = nearest and min = nearest and mip = nearest */
  28455. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  28456. /** mag = nearest and min = linear and mip = nearest */
  28457. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  28458. /** mag = nearest and min = linear and mip = linear */
  28459. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  28460. /** mag = nearest and min = linear and mip = none */
  28461. static readonly TEXTURE_NEAREST_LINEAR: number;
  28462. /** mag = nearest and min = nearest and mip = none */
  28463. static readonly TEXTURE_NEAREST_NEAREST: number;
  28464. /** mag = linear and min = nearest and mip = nearest */
  28465. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  28466. /** mag = linear and min = nearest and mip = linear */
  28467. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  28468. /** mag = linear and min = linear and mip = none */
  28469. static readonly TEXTURE_LINEAR_LINEAR: number;
  28470. /** mag = linear and min = nearest and mip = none */
  28471. static readonly TEXTURE_LINEAR_NEAREST: number;
  28472. /** Explicit coordinates mode */
  28473. static readonly TEXTURE_EXPLICIT_MODE: number;
  28474. /** Spherical coordinates mode */
  28475. static readonly TEXTURE_SPHERICAL_MODE: number;
  28476. /** Planar coordinates mode */
  28477. static readonly TEXTURE_PLANAR_MODE: number;
  28478. /** Cubic coordinates mode */
  28479. static readonly TEXTURE_CUBIC_MODE: number;
  28480. /** Projection coordinates mode */
  28481. static readonly TEXTURE_PROJECTION_MODE: number;
  28482. /** Skybox coordinates mode */
  28483. static readonly TEXTURE_SKYBOX_MODE: number;
  28484. /** Inverse Cubic coordinates mode */
  28485. static readonly TEXTURE_INVCUBIC_MODE: number;
  28486. /** Equirectangular coordinates mode */
  28487. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  28488. /** Equirectangular Fixed coordinates mode */
  28489. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  28490. /** Equirectangular Fixed Mirrored coordinates mode */
  28491. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28492. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28493. static readonly SCALEMODE_FLOOR: number;
  28494. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28495. static readonly SCALEMODE_NEAREST: number;
  28496. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28497. static readonly SCALEMODE_CEILING: number;
  28498. /**
  28499. * Returns the current npm package of the sdk
  28500. */
  28501. static readonly NpmPackage: string;
  28502. /**
  28503. * Returns the current version of the framework
  28504. */
  28505. static readonly Version: string;
  28506. /**
  28507. * Returns a string describing the current engine
  28508. */
  28509. readonly description: string;
  28510. /**
  28511. * Gets or sets the epsilon value used by collision engine
  28512. */
  28513. static CollisionsEpsilon: number;
  28514. /**
  28515. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28516. */
  28517. static ShadersRepository: string;
  28518. /**
  28519. * Method called to create the default loading screen.
  28520. * This can be overriden in your own app.
  28521. * @param canvas The rendering canvas element
  28522. * @returns The loading screen
  28523. */
  28524. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  28525. /**
  28526. * Method called to create the default rescale post process on each engine.
  28527. */
  28528. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  28529. /** @hidden */
  28530. _shaderProcessor: IShaderProcessor;
  28531. /**
  28532. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28533. */
  28534. forcePOTTextures: boolean;
  28535. /**
  28536. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28537. */
  28538. isFullscreen: boolean;
  28539. /**
  28540. * Gets a boolean indicating if the pointer is currently locked
  28541. */
  28542. isPointerLock: boolean;
  28543. /**
  28544. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28545. */
  28546. cullBackFaces: boolean;
  28547. /**
  28548. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28549. */
  28550. renderEvenInBackground: boolean;
  28551. /**
  28552. * Gets or sets a boolean indicating that cache can be kept between frames
  28553. */
  28554. preventCacheWipeBetweenFrames: boolean;
  28555. /**
  28556. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28557. **/
  28558. enableOfflineSupport: boolean;
  28559. /**
  28560. * 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)
  28561. **/
  28562. disableManifestCheck: boolean;
  28563. /**
  28564. * Gets the list of created scenes
  28565. */
  28566. scenes: Scene[];
  28567. /**
  28568. * Event raised when a new scene is created
  28569. */
  28570. onNewSceneAddedObservable: Observable<Scene>;
  28571. /**
  28572. * Gets the list of created postprocesses
  28573. */
  28574. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  28575. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28576. validateShaderPrograms: boolean;
  28577. /**
  28578. * Observable event triggered each time the rendering canvas is resized
  28579. */
  28580. onResizeObservable: Observable<Engine>;
  28581. /**
  28582. * Observable event triggered each time the canvas loses focus
  28583. */
  28584. onCanvasBlurObservable: Observable<Engine>;
  28585. /**
  28586. * Observable event triggered each time the canvas gains focus
  28587. */
  28588. onCanvasFocusObservable: Observable<Engine>;
  28589. /**
  28590. * Observable event triggered each time the canvas receives pointerout event
  28591. */
  28592. onCanvasPointerOutObservable: Observable<PointerEvent>;
  28593. /**
  28594. * Observable event triggered before each texture is initialized
  28595. */
  28596. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  28597. /**
  28598. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28599. */
  28600. disableUniformBuffers: boolean;
  28601. /** @hidden */
  28602. _uniformBuffers: UniformBuffer[];
  28603. /**
  28604. * Gets a boolean indicating that the engine supports uniform buffers
  28605. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28606. */
  28607. readonly supportsUniformBuffers: boolean;
  28608. /**
  28609. * Observable raised when the engine begins a new frame
  28610. */
  28611. onBeginFrameObservable: Observable<Engine>;
  28612. /**
  28613. * If set, will be used to request the next animation frame for the render loop
  28614. */
  28615. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  28616. /**
  28617. * Observable raised when the engine ends the current frame
  28618. */
  28619. onEndFrameObservable: Observable<Engine>;
  28620. /**
  28621. * Observable raised when the engine is about to compile a shader
  28622. */
  28623. onBeforeShaderCompilationObservable: Observable<Engine>;
  28624. /**
  28625. * Observable raised when the engine has jsut compiled a shader
  28626. */
  28627. onAfterShaderCompilationObservable: Observable<Engine>;
  28628. /** @hidden */
  28629. _gl: WebGLRenderingContext;
  28630. private _renderingCanvas;
  28631. private _windowIsBackground;
  28632. private _webGLVersion;
  28633. protected _highPrecisionShadersAllowed: boolean;
  28634. /** @hidden */
  28635. readonly _shouldUseHighPrecisionShader: boolean;
  28636. /**
  28637. * Gets a boolean indicating that only power of 2 textures are supported
  28638. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28639. */
  28640. readonly needPOTTextures: boolean;
  28641. /** @hidden */
  28642. _badOS: boolean;
  28643. /** @hidden */
  28644. _badDesktopOS: boolean;
  28645. /**
  28646. * Gets the audio engine
  28647. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28648. * @ignorenaming
  28649. */
  28650. static audioEngine: IAudioEngine;
  28651. /**
  28652. * Default AudioEngine factory responsible of creating the Audio Engine.
  28653. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28654. */
  28655. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28656. /**
  28657. * Default offline support factory responsible of creating a tool used to store data locally.
  28658. * By default, this will create a Database object if the workload has been embedded.
  28659. */
  28660. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28661. private _onFocus;
  28662. private _onBlur;
  28663. private _onCanvasPointerOut;
  28664. private _onCanvasBlur;
  28665. private _onCanvasFocus;
  28666. private _onFullscreenChange;
  28667. private _onPointerLockChange;
  28668. private _hardwareScalingLevel;
  28669. /** @hidden */
  28670. _caps: EngineCapabilities;
  28671. private _pointerLockRequested;
  28672. private _isStencilEnable;
  28673. private _colorWrite;
  28674. private _loadingScreen;
  28675. /** @hidden */
  28676. _drawCalls: PerfCounter;
  28677. private _glVersion;
  28678. private _glRenderer;
  28679. private _glVendor;
  28680. private _videoTextureSupported;
  28681. private _renderingQueueLaunched;
  28682. private _activeRenderLoops;
  28683. private _deterministicLockstep;
  28684. private _lockstepMaxSteps;
  28685. /**
  28686. * Observable signaled when a context lost event is raised
  28687. */
  28688. onContextLostObservable: Observable<Engine>;
  28689. /**
  28690. * Observable signaled when a context restored event is raised
  28691. */
  28692. onContextRestoredObservable: Observable<Engine>;
  28693. private _onContextLost;
  28694. private _onContextRestored;
  28695. private _contextWasLost;
  28696. /** @hidden */
  28697. _doNotHandleContextLost: boolean;
  28698. /**
  28699. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28700. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28701. */
  28702. doNotHandleContextLost: boolean;
  28703. private _performanceMonitor;
  28704. private _fps;
  28705. private _deltaTime;
  28706. /**
  28707. * Turn this value on if you want to pause FPS computation when in background
  28708. */
  28709. disablePerformanceMonitorInBackground: boolean;
  28710. /**
  28711. * Gets the performance monitor attached to this engine
  28712. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28713. */
  28714. readonly performanceMonitor: PerformanceMonitor;
  28715. /**
  28716. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28717. */
  28718. disableVertexArrayObjects: boolean;
  28719. /** @hidden */
  28720. protected _depthCullingState: _DepthCullingState;
  28721. /** @hidden */
  28722. protected _stencilState: _StencilState;
  28723. /** @hidden */
  28724. protected _alphaState: _AlphaState;
  28725. /** @hidden */
  28726. protected _alphaMode: number;
  28727. /** @hidden */
  28728. _internalTexturesCache: InternalTexture[];
  28729. /** @hidden */
  28730. protected _activeChannel: number;
  28731. private _currentTextureChannel;
  28732. /** @hidden */
  28733. protected _boundTexturesCache: {
  28734. [key: string]: Nullable<InternalTexture>;
  28735. };
  28736. /** @hidden */
  28737. protected _currentEffect: Nullable<Effect>;
  28738. /** @hidden */
  28739. protected _currentProgram: Nullable<WebGLProgram>;
  28740. private _compiledEffects;
  28741. private _vertexAttribArraysEnabled;
  28742. /** @hidden */
  28743. protected _cachedViewport: Nullable<Viewport>;
  28744. private _cachedVertexArrayObject;
  28745. /** @hidden */
  28746. protected _cachedVertexBuffers: any;
  28747. /** @hidden */
  28748. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28749. /** @hidden */
  28750. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28751. /** @hidden */
  28752. _currentRenderTarget: Nullable<InternalTexture>;
  28753. private _uintIndicesCurrentlySet;
  28754. private _currentBoundBuffer;
  28755. /** @hidden */
  28756. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28757. private _currentBufferPointers;
  28758. private _currentInstanceLocations;
  28759. private _currentInstanceBuffers;
  28760. private _textureUnits;
  28761. /** @hidden */
  28762. _workingCanvas: Nullable<HTMLCanvasElement>;
  28763. /** @hidden */
  28764. _workingContext: Nullable<CanvasRenderingContext2D>;
  28765. private _rescalePostProcess;
  28766. private _dummyFramebuffer;
  28767. private _externalData;
  28768. /** @hidden */
  28769. _bindedRenderFunction: any;
  28770. private _vaoRecordInProgress;
  28771. private _mustWipeVertexAttributes;
  28772. private _emptyTexture;
  28773. private _emptyCubeTexture;
  28774. private _emptyTexture3D;
  28775. /** @hidden */
  28776. _frameHandler: number;
  28777. private _nextFreeTextureSlots;
  28778. private _maxSimultaneousTextures;
  28779. private _activeRequests;
  28780. private _texturesSupported;
  28781. /** @hidden */
  28782. _textureFormatInUse: Nullable<string>;
  28783. /**
  28784. * Gets the list of texture formats supported
  28785. */
  28786. readonly texturesSupported: Array<string>;
  28787. /**
  28788. * Gets the list of texture formats in use
  28789. */
  28790. readonly textureFormatInUse: Nullable<string>;
  28791. /**
  28792. * Gets the current viewport
  28793. */
  28794. readonly currentViewport: Nullable<Viewport>;
  28795. /**
  28796. * Gets the default empty texture
  28797. */
  28798. readonly emptyTexture: InternalTexture;
  28799. /**
  28800. * Gets the default empty 3D texture
  28801. */
  28802. readonly emptyTexture3D: InternalTexture;
  28803. /**
  28804. * Gets the default empty cube texture
  28805. */
  28806. readonly emptyCubeTexture: InternalTexture;
  28807. /**
  28808. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28809. */
  28810. readonly premultipliedAlpha: boolean;
  28811. /**
  28812. * Creates a new engine
  28813. * @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
  28814. * @param antialias defines enable antialiasing (default: false)
  28815. * @param options defines further options to be sent to the getContext() function
  28816. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28817. */
  28818. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28819. /**
  28820. * Initializes a webVR display and starts listening to display change events
  28821. * The onVRDisplayChangedObservable will be notified upon these changes
  28822. * @returns The onVRDisplayChangedObservable
  28823. */
  28824. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28825. /** @hidden */
  28826. _prepareVRComponent(): void;
  28827. /** @hidden */
  28828. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  28829. /** @hidden */
  28830. _submitVRFrame(): void;
  28831. /**
  28832. * Call this function to leave webVR mode
  28833. * Will do nothing if webVR is not supported or if there is no webVR device
  28834. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28835. */
  28836. disableVR(): void;
  28837. /**
  28838. * Gets a boolean indicating that the system is in VR mode and is presenting
  28839. * @returns true if VR mode is engaged
  28840. */
  28841. isVRPresenting(): boolean;
  28842. /** @hidden */
  28843. _requestVRFrame(): void;
  28844. private _disableTouchAction;
  28845. private _rebuildInternalTextures;
  28846. private _rebuildEffects;
  28847. /**
  28848. * Gets a boolean indicating if all created effects are ready
  28849. * @returns true if all effects are ready
  28850. */
  28851. areAllEffectsReady(): boolean;
  28852. private _rebuildBuffers;
  28853. private _initGLContext;
  28854. /**
  28855. * Gets version of the current webGL context
  28856. */
  28857. readonly webGLVersion: number;
  28858. /**
  28859. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28860. */
  28861. readonly isStencilEnable: boolean;
  28862. /** @hidden */
  28863. _prepareWorkingCanvas(): void;
  28864. /**
  28865. * Reset the texture cache to empty state
  28866. */
  28867. resetTextureCache(): void;
  28868. /**
  28869. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28870. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28871. * @returns true if engine is in deterministic lock step mode
  28872. */
  28873. isDeterministicLockStep(): boolean;
  28874. /**
  28875. * Gets the max steps when engine is running in deterministic lock step
  28876. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28877. * @returns the max steps
  28878. */
  28879. getLockstepMaxSteps(): number;
  28880. /**
  28881. * Gets an object containing information about the current webGL context
  28882. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28883. */
  28884. getGlInfo(): {
  28885. vendor: string;
  28886. renderer: string;
  28887. version: string;
  28888. };
  28889. /**
  28890. * Gets current aspect ratio
  28891. * @param camera defines the camera to use to get the aspect ratio
  28892. * @param useScreen defines if screen size must be used (or the current render target if any)
  28893. * @returns a number defining the aspect ratio
  28894. */
  28895. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28896. /**
  28897. * Gets current screen aspect ratio
  28898. * @returns a number defining the aspect ratio
  28899. */
  28900. getScreenAspectRatio(): number;
  28901. /**
  28902. * Gets the current render width
  28903. * @param useScreen defines if screen size must be used (or the current render target if any)
  28904. * @returns a number defining the current render width
  28905. */
  28906. getRenderWidth(useScreen?: boolean): number;
  28907. /**
  28908. * Gets the current render height
  28909. * @param useScreen defines if screen size must be used (or the current render target if any)
  28910. * @returns a number defining the current render height
  28911. */
  28912. getRenderHeight(useScreen?: boolean): number;
  28913. /**
  28914. * Gets the HTML canvas attached with the current webGL context
  28915. * @returns a HTML canvas
  28916. */
  28917. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28918. /**
  28919. * Gets the client rect of the HTML canvas attached with the current webGL context
  28920. * @returns a client rectanglee
  28921. */
  28922. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28923. /**
  28924. * Defines the hardware scaling level.
  28925. * By default the hardware scaling level is computed from the window device ratio.
  28926. * 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.
  28927. * @param level defines the level to use
  28928. */
  28929. setHardwareScalingLevel(level: number): void;
  28930. /**
  28931. * Gets the current hardware scaling level.
  28932. * By default the hardware scaling level is computed from the window device ratio.
  28933. * 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.
  28934. * @returns a number indicating the current hardware scaling level
  28935. */
  28936. getHardwareScalingLevel(): number;
  28937. /**
  28938. * Gets the list of loaded textures
  28939. * @returns an array containing all loaded textures
  28940. */
  28941. getLoadedTexturesCache(): InternalTexture[];
  28942. /**
  28943. * Gets the object containing all engine capabilities
  28944. * @returns the EngineCapabilities object
  28945. */
  28946. getCaps(): EngineCapabilities;
  28947. /**
  28948. * Gets the current depth function
  28949. * @returns a number defining the depth function
  28950. */
  28951. getDepthFunction(): Nullable<number>;
  28952. /**
  28953. * Sets the current depth function
  28954. * @param depthFunc defines the function to use
  28955. */
  28956. setDepthFunction(depthFunc: number): void;
  28957. /**
  28958. * Sets the current depth function to GREATER
  28959. */
  28960. setDepthFunctionToGreater(): void;
  28961. /**
  28962. * Sets the current depth function to GEQUAL
  28963. */
  28964. setDepthFunctionToGreaterOrEqual(): void;
  28965. /**
  28966. * Sets the current depth function to LESS
  28967. */
  28968. setDepthFunctionToLess(): void;
  28969. private _cachedStencilBuffer;
  28970. private _cachedStencilFunction;
  28971. private _cachedStencilMask;
  28972. private _cachedStencilOperationPass;
  28973. private _cachedStencilOperationFail;
  28974. private _cachedStencilOperationDepthFail;
  28975. private _cachedStencilReference;
  28976. /**
  28977. * Caches the the state of the stencil buffer
  28978. */
  28979. cacheStencilState(): void;
  28980. /**
  28981. * Restores the state of the stencil buffer
  28982. */
  28983. restoreStencilState(): void;
  28984. /**
  28985. * Sets the current depth function to LEQUAL
  28986. */
  28987. setDepthFunctionToLessOrEqual(): void;
  28988. /**
  28989. * Gets a boolean indicating if stencil buffer is enabled
  28990. * @returns the current stencil buffer state
  28991. */
  28992. getStencilBuffer(): boolean;
  28993. /**
  28994. * Enable or disable the stencil buffer
  28995. * @param enable defines if the stencil buffer must be enabled or disabled
  28996. */
  28997. setStencilBuffer(enable: boolean): void;
  28998. /**
  28999. * Gets the current stencil mask
  29000. * @returns a number defining the new stencil mask to use
  29001. */
  29002. getStencilMask(): number;
  29003. /**
  29004. * Sets the current stencil mask
  29005. * @param mask defines the new stencil mask to use
  29006. */
  29007. setStencilMask(mask: number): void;
  29008. /**
  29009. * Gets the current stencil function
  29010. * @returns a number defining the stencil function to use
  29011. */
  29012. getStencilFunction(): number;
  29013. /**
  29014. * Gets the current stencil reference value
  29015. * @returns a number defining the stencil reference value to use
  29016. */
  29017. getStencilFunctionReference(): number;
  29018. /**
  29019. * Gets the current stencil mask
  29020. * @returns a number defining the stencil mask to use
  29021. */
  29022. getStencilFunctionMask(): number;
  29023. /**
  29024. * Sets the current stencil function
  29025. * @param stencilFunc defines the new stencil function to use
  29026. */
  29027. setStencilFunction(stencilFunc: number): void;
  29028. /**
  29029. * Sets the current stencil reference
  29030. * @param reference defines the new stencil reference to use
  29031. */
  29032. setStencilFunctionReference(reference: number): void;
  29033. /**
  29034. * Sets the current stencil mask
  29035. * @param mask defines the new stencil mask to use
  29036. */
  29037. setStencilFunctionMask(mask: number): void;
  29038. /**
  29039. * Gets the current stencil operation when stencil fails
  29040. * @returns a number defining stencil operation to use when stencil fails
  29041. */
  29042. getStencilOperationFail(): number;
  29043. /**
  29044. * Gets the current stencil operation when depth fails
  29045. * @returns a number defining stencil operation to use when depth fails
  29046. */
  29047. getStencilOperationDepthFail(): number;
  29048. /**
  29049. * Gets the current stencil operation when stencil passes
  29050. * @returns a number defining stencil operation to use when stencil passes
  29051. */
  29052. getStencilOperationPass(): number;
  29053. /**
  29054. * Sets the stencil operation to use when stencil fails
  29055. * @param operation defines the stencil operation to use when stencil fails
  29056. */
  29057. setStencilOperationFail(operation: number): void;
  29058. /**
  29059. * Sets the stencil operation to use when depth fails
  29060. * @param operation defines the stencil operation to use when depth fails
  29061. */
  29062. setStencilOperationDepthFail(operation: number): void;
  29063. /**
  29064. * Sets the stencil operation to use when stencil passes
  29065. * @param operation defines the stencil operation to use when stencil passes
  29066. */
  29067. setStencilOperationPass(operation: number): void;
  29068. /**
  29069. * Sets a boolean indicating if the dithering state is enabled or disabled
  29070. * @param value defines the dithering state
  29071. */
  29072. setDitheringState(value: boolean): void;
  29073. /**
  29074. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  29075. * @param value defines the rasterizer state
  29076. */
  29077. setRasterizerState(value: boolean): void;
  29078. /**
  29079. * stop executing a render loop function and remove it from the execution array
  29080. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29081. */
  29082. stopRenderLoop(renderFunction?: () => void): void;
  29083. /** @hidden */
  29084. _renderLoop(): void;
  29085. /**
  29086. * Register and execute a render loop. The engine can have more than one render function
  29087. * @param renderFunction defines the function to continuously execute
  29088. */
  29089. runRenderLoop(renderFunction: () => void): void;
  29090. /**
  29091. * Toggle full screen mode
  29092. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29093. */
  29094. switchFullscreen(requestPointerLock: boolean): void;
  29095. /**
  29096. * Enters full screen mode
  29097. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29098. */
  29099. enterFullscreen(requestPointerLock: boolean): void;
  29100. /**
  29101. * Exits full screen mode
  29102. */
  29103. exitFullscreen(): void;
  29104. /**
  29105. * Enters Pointerlock mode
  29106. */
  29107. enterPointerlock(): void;
  29108. /**
  29109. * Exits Pointerlock mode
  29110. */
  29111. exitPointerlock(): void;
  29112. /**
  29113. * Clear the current render buffer or the current render target (if any is set up)
  29114. * @param color defines the color to use
  29115. * @param backBuffer defines if the back buffer must be cleared
  29116. * @param depth defines if the depth buffer must be cleared
  29117. * @param stencil defines if the stencil buffer must be cleared
  29118. */
  29119. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29120. /**
  29121. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  29122. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29123. * @param y defines the y-coordinate of the corner of the clear rectangle
  29124. * @param width defines the width of the clear rectangle
  29125. * @param height defines the height of the clear rectangle
  29126. * @param clearColor defines the clear color
  29127. */
  29128. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  29129. /**
  29130. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  29131. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29132. * @param y defines the y-coordinate of the corner of the clear rectangle
  29133. * @param width defines the width of the clear rectangle
  29134. * @param height defines the height of the clear rectangle
  29135. */
  29136. enableScissor(x: number, y: number, width: number, height: number): void;
  29137. /**
  29138. * Disable previously set scissor test rectangle
  29139. */
  29140. disableScissor(): void;
  29141. private _viewportCached;
  29142. /** @hidden */
  29143. _viewport(x: number, y: number, width: number, height: number): void;
  29144. /**
  29145. * Set the WebGL's viewport
  29146. * @param viewport defines the viewport element to be used
  29147. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29148. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29149. */
  29150. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  29151. /**
  29152. * Directly set the WebGL Viewport
  29153. * @param x defines the x coordinate of the viewport (in screen space)
  29154. * @param y defines the y coordinate of the viewport (in screen space)
  29155. * @param width defines the width of the viewport (in screen space)
  29156. * @param height defines the height of the viewport (in screen space)
  29157. * @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
  29158. */
  29159. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  29160. /**
  29161. * Begin a new frame
  29162. */
  29163. beginFrame(): void;
  29164. /**
  29165. * Enf the current frame
  29166. */
  29167. endFrame(): void;
  29168. /**
  29169. * Resize the view according to the canvas' size
  29170. */
  29171. resize(): void;
  29172. /**
  29173. * Force a specific size of the canvas
  29174. * @param width defines the new canvas' width
  29175. * @param height defines the new canvas' height
  29176. */
  29177. setSize(width: number, height: number): void;
  29178. /**
  29179. * Binds the frame buffer to the specified texture.
  29180. * @param texture The texture to render to or null for the default canvas
  29181. * @param faceIndex The face of the texture to render to in case of cube texture
  29182. * @param requiredWidth The width of the target to render to
  29183. * @param requiredHeight The height of the target to render to
  29184. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29185. * @param depthStencilTexture The depth stencil texture to use to render
  29186. * @param lodLevel defines le lod level to bind to the frame buffer
  29187. */
  29188. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29189. /** @hidden */
  29190. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29191. /**
  29192. * Unbind the current render target texture from the webGL context
  29193. * @param texture defines the render target texture to unbind
  29194. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29195. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29196. */
  29197. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29198. /**
  29199. * Force the mipmap generation for the given render target texture
  29200. * @param texture defines the render target texture to use
  29201. */
  29202. generateMipMapsForCubemap(texture: InternalTexture): void;
  29203. /**
  29204. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29205. */
  29206. flushFramebuffer(): void;
  29207. /**
  29208. * Unbind the current render target and bind the default framebuffer
  29209. */
  29210. restoreDefaultFramebuffer(): void;
  29211. /**
  29212. * Create an uniform buffer
  29213. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29214. * @param elements defines the content of the uniform buffer
  29215. * @returns the webGL uniform buffer
  29216. */
  29217. createUniformBuffer(elements: FloatArray): DataBuffer;
  29218. /**
  29219. * Create a dynamic uniform buffer
  29220. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29221. * @param elements defines the content of the uniform buffer
  29222. * @returns the webGL uniform buffer
  29223. */
  29224. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  29225. /**
  29226. * Update an existing uniform buffer
  29227. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29228. * @param uniformBuffer defines the target uniform buffer
  29229. * @param elements defines the content to update
  29230. * @param offset defines the offset in the uniform buffer where update should start
  29231. * @param count defines the size of the data to update
  29232. */
  29233. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  29234. private _resetVertexBufferBinding;
  29235. /**
  29236. * Creates a vertex buffer
  29237. * @param data the data for the vertex buffer
  29238. * @returns the new WebGL static buffer
  29239. */
  29240. createVertexBuffer(data: DataArray): DataBuffer;
  29241. /**
  29242. * Creates a dynamic vertex buffer
  29243. * @param data the data for the dynamic vertex buffer
  29244. * @returns the new WebGL dynamic buffer
  29245. */
  29246. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29247. /**
  29248. * Update a dynamic index buffer
  29249. * @param indexBuffer defines the target index buffer
  29250. * @param indices defines the data to update
  29251. * @param offset defines the offset in the target index buffer where update should start
  29252. */
  29253. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  29254. /**
  29255. * Updates a dynamic vertex buffer.
  29256. * @param vertexBuffer the vertex buffer to update
  29257. * @param data the data used to update the vertex buffer
  29258. * @param byteOffset the byte offset of the data
  29259. * @param byteLength the byte length of the data
  29260. */
  29261. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  29262. private _resetIndexBufferBinding;
  29263. /**
  29264. * Creates a new index buffer
  29265. * @param indices defines the content of the index buffer
  29266. * @param updatable defines if the index buffer must be updatable
  29267. * @returns a new webGL buffer
  29268. */
  29269. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29270. /**
  29271. * Bind a webGL buffer to the webGL context
  29272. * @param buffer defines the buffer to bind
  29273. */
  29274. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29275. /**
  29276. * Bind an uniform buffer to the current webGL context
  29277. * @param buffer defines the buffer to bind
  29278. */
  29279. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  29280. /**
  29281. * Bind a buffer to the current webGL context at a given location
  29282. * @param buffer defines the buffer to bind
  29283. * @param location defines the index where to bind the buffer
  29284. */
  29285. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  29286. /**
  29287. * Bind a specific block at a given index in a specific shader program
  29288. * @param pipelineContext defines the pipeline context to use
  29289. * @param blockName defines the block name
  29290. * @param index defines the index where to bind the block
  29291. */
  29292. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  29293. private bindIndexBuffer;
  29294. private bindBuffer;
  29295. /**
  29296. * update the bound buffer with the given data
  29297. * @param data defines the data to update
  29298. */
  29299. updateArrayBuffer(data: Float32Array): void;
  29300. private _vertexAttribPointer;
  29301. private _bindIndexBufferWithCache;
  29302. private _bindVertexBuffersAttributes;
  29303. /**
  29304. * Records a vertex array object
  29305. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29306. * @param vertexBuffers defines the list of vertex buffers to store
  29307. * @param indexBuffer defines the index buffer to store
  29308. * @param effect defines the effect to store
  29309. * @returns the new vertex array object
  29310. */
  29311. recordVertexArrayObject(vertexBuffers: {
  29312. [key: string]: VertexBuffer;
  29313. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29314. /**
  29315. * Bind a specific vertex array object
  29316. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29317. * @param vertexArrayObject defines the vertex array object to bind
  29318. * @param indexBuffer defines the index buffer to bind
  29319. */
  29320. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29321. /**
  29322. * Bind webGl buffers directly to the webGL context
  29323. * @param vertexBuffer defines the vertex buffer to bind
  29324. * @param indexBuffer defines the index buffer to bind
  29325. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29326. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29327. * @param effect defines the effect associated with the vertex buffer
  29328. */
  29329. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29330. private _unbindVertexArrayObject;
  29331. /**
  29332. * Bind a list of vertex buffers to the webGL context
  29333. * @param vertexBuffers defines the list of vertex buffers to bind
  29334. * @param indexBuffer defines the index buffer to bind
  29335. * @param effect defines the effect associated with the vertex buffers
  29336. */
  29337. bindBuffers(vertexBuffers: {
  29338. [key: string]: Nullable<VertexBuffer>;
  29339. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29340. /**
  29341. * Unbind all instance attributes
  29342. */
  29343. unbindInstanceAttributes(): void;
  29344. /**
  29345. * Release and free the memory of a vertex array object
  29346. * @param vao defines the vertex array object to delete
  29347. */
  29348. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29349. /** @hidden */
  29350. _releaseBuffer(buffer: DataBuffer): boolean;
  29351. /**
  29352. * Creates a webGL buffer to use with instanciation
  29353. * @param capacity defines the size of the buffer
  29354. * @returns the webGL buffer
  29355. */
  29356. createInstancesBuffer(capacity: number): DataBuffer;
  29357. /**
  29358. * Delete a webGL buffer used with instanciation
  29359. * @param buffer defines the webGL buffer to delete
  29360. */
  29361. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29362. /**
  29363. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29364. * @param instancesBuffer defines the webGL buffer to update and bind
  29365. * @param data defines the data to store in the buffer
  29366. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29367. */
  29368. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29369. /**
  29370. * Apply all cached states (depth, culling, stencil and alpha)
  29371. */
  29372. applyStates(): void;
  29373. /**
  29374. * Send a draw order
  29375. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29376. * @param indexStart defines the starting index
  29377. * @param indexCount defines the number of index to draw
  29378. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29379. */
  29380. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29381. /**
  29382. * Draw a list of points
  29383. * @param verticesStart defines the index of first vertex to draw
  29384. * @param verticesCount defines the count of vertices to draw
  29385. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29386. */
  29387. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29388. /**
  29389. * Draw a list of unindexed primitives
  29390. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29391. * @param verticesStart defines the index of first vertex to draw
  29392. * @param verticesCount defines the count of vertices to draw
  29393. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29394. */
  29395. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29396. /**
  29397. * Draw a list of indexed primitives
  29398. * @param fillMode defines the primitive to use
  29399. * @param indexStart defines the starting index
  29400. * @param indexCount defines the number of index to draw
  29401. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29402. */
  29403. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29404. /**
  29405. * Draw a list of unindexed primitives
  29406. * @param fillMode defines the primitive to use
  29407. * @param verticesStart defines the index of first vertex to draw
  29408. * @param verticesCount defines the count of vertices to draw
  29409. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29410. */
  29411. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29412. private _drawMode;
  29413. /** @hidden */
  29414. _releaseEffect(effect: Effect): void;
  29415. /** @hidden */
  29416. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29417. /**
  29418. * Create a new effect (used to store vertex/fragment shaders)
  29419. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29420. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29421. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29422. * @param samplers defines an array of string used to represent textures
  29423. * @param defines defines the string containing the defines to use to compile the shaders
  29424. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29425. * @param onCompiled defines a function to call when the effect creation is successful
  29426. * @param onError defines a function to call when the effect creation has failed
  29427. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29428. * @returns the new Effect
  29429. */
  29430. 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;
  29431. private _compileShader;
  29432. private _compileRawShader;
  29433. /**
  29434. * Directly creates a webGL program
  29435. * @param pipelineContext defines the pipeline context to attach to
  29436. * @param vertexCode defines the vertex shader code to use
  29437. * @param fragmentCode defines the fragment shader code to use
  29438. * @param context defines the webGL context to use (if not set, the current one will be used)
  29439. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29440. * @returns the new webGL program
  29441. */
  29442. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29443. /**
  29444. * Creates a webGL program
  29445. * @param pipelineContext defines the pipeline context to attach to
  29446. * @param vertexCode defines the vertex shader code to use
  29447. * @param fragmentCode defines the fragment shader code to use
  29448. * @param defines defines the string containing the defines to use to compile the shaders
  29449. * @param context defines the webGL context to use (if not set, the current one will be used)
  29450. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29451. * @returns the new webGL program
  29452. */
  29453. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29454. /**
  29455. * Creates a new pipeline context
  29456. * @returns the new pipeline
  29457. */
  29458. createPipelineContext(): WebGLPipelineContext;
  29459. private _createShaderProgram;
  29460. private _finalizePipelineContext;
  29461. /** @hidden */
  29462. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29463. /** @hidden */
  29464. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29465. /** @hidden */
  29466. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29467. /**
  29468. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29469. * @param pipelineContext defines the pipeline context to use
  29470. * @param uniformsNames defines the list of uniform names
  29471. * @returns an array of webGL uniform locations
  29472. */
  29473. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29474. /**
  29475. * Gets the lsit of active attributes for a given webGL program
  29476. * @param pipelineContext defines the pipeline context to use
  29477. * @param attributesNames defines the list of attribute names to get
  29478. * @returns an array of indices indicating the offset of each attribute
  29479. */
  29480. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29481. /**
  29482. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29483. * @param effect defines the effect to activate
  29484. */
  29485. enableEffect(effect: Nullable<Effect>): void;
  29486. /**
  29487. * Set the value of an uniform to an array of int32
  29488. * @param uniform defines the webGL uniform location where to store the value
  29489. * @param array defines the array of int32 to store
  29490. */
  29491. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29492. /**
  29493. * Set the value of an uniform to an array of int32 (stored as vec2)
  29494. * @param uniform defines the webGL uniform location where to store the value
  29495. * @param array defines the array of int32 to store
  29496. */
  29497. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29498. /**
  29499. * Set the value of an uniform to an array of int32 (stored as vec3)
  29500. * @param uniform defines the webGL uniform location where to store the value
  29501. * @param array defines the array of int32 to store
  29502. */
  29503. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29504. /**
  29505. * Set the value of an uniform to an array of int32 (stored as vec4)
  29506. * @param uniform defines the webGL uniform location where to store the value
  29507. * @param array defines the array of int32 to store
  29508. */
  29509. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29510. /**
  29511. * Set the value of an uniform to an array of float32
  29512. * @param uniform defines the webGL uniform location where to store the value
  29513. * @param array defines the array of float32 to store
  29514. */
  29515. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29516. /**
  29517. * Set the value of an uniform to an array of float32 (stored as vec2)
  29518. * @param uniform defines the webGL uniform location where to store the value
  29519. * @param array defines the array of float32 to store
  29520. */
  29521. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29522. /**
  29523. * Set the value of an uniform to an array of float32 (stored as vec3)
  29524. * @param uniform defines the webGL uniform location where to store the value
  29525. * @param array defines the array of float32 to store
  29526. */
  29527. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29528. /**
  29529. * Set the value of an uniform to an array of float32 (stored as vec4)
  29530. * @param uniform defines the webGL uniform location where to store the value
  29531. * @param array defines the array of float32 to store
  29532. */
  29533. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29534. /**
  29535. * Set the value of an uniform to an array of number
  29536. * @param uniform defines the webGL uniform location where to store the value
  29537. * @param array defines the array of number to store
  29538. */
  29539. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29540. /**
  29541. * Set the value of an uniform to an array of number (stored as vec2)
  29542. * @param uniform defines the webGL uniform location where to store the value
  29543. * @param array defines the array of number to store
  29544. */
  29545. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29546. /**
  29547. * Set the value of an uniform to an array of number (stored as vec3)
  29548. * @param uniform defines the webGL uniform location where to store the value
  29549. * @param array defines the array of number to store
  29550. */
  29551. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29552. /**
  29553. * Set the value of an uniform to an array of number (stored as vec4)
  29554. * @param uniform defines the webGL uniform location where to store the value
  29555. * @param array defines the array of number to store
  29556. */
  29557. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29558. /**
  29559. * Set the value of an uniform to an array of float32 (stored as matrices)
  29560. * @param uniform defines the webGL uniform location where to store the value
  29561. * @param matrices defines the array of float32 to store
  29562. */
  29563. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29564. /**
  29565. * Set the value of an uniform to a matrix
  29566. * @param uniform defines the webGL uniform location where to store the value
  29567. * @param matrix defines the matrix to store
  29568. */
  29569. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  29570. /**
  29571. * Set the value of an uniform to a matrix (3x3)
  29572. * @param uniform defines the webGL uniform location where to store the value
  29573. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29574. */
  29575. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29576. /**
  29577. * Set the value of an uniform to a matrix (2x2)
  29578. * @param uniform defines the webGL uniform location where to store the value
  29579. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29580. */
  29581. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29582. /**
  29583. * Set the value of an uniform to a number (int)
  29584. * @param uniform defines the webGL uniform location where to store the value
  29585. * @param value defines the int number to store
  29586. */
  29587. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29588. /**
  29589. * Set the value of an uniform to a number (float)
  29590. * @param uniform defines the webGL uniform location where to store the value
  29591. * @param value defines the float number to store
  29592. */
  29593. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29594. /**
  29595. * Set the value of an uniform to a vec2
  29596. * @param uniform defines the webGL uniform location where to store the value
  29597. * @param x defines the 1st component of the value
  29598. * @param y defines the 2nd component of the value
  29599. */
  29600. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29601. /**
  29602. * Set the value of an uniform to a vec3
  29603. * @param uniform defines the webGL uniform location where to store the value
  29604. * @param x defines the 1st component of the value
  29605. * @param y defines the 2nd component of the value
  29606. * @param z defines the 3rd component of the value
  29607. */
  29608. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29609. /**
  29610. * Set the value of an uniform to a boolean
  29611. * @param uniform defines the webGL uniform location where to store the value
  29612. * @param bool defines the boolean to store
  29613. */
  29614. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29615. /**
  29616. * Set the value of an uniform to a vec4
  29617. * @param uniform defines the webGL uniform location where to store the value
  29618. * @param x defines the 1st component of the value
  29619. * @param y defines the 2nd component of the value
  29620. * @param z defines the 3rd component of the value
  29621. * @param w defines the 4th component of the value
  29622. */
  29623. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29624. /**
  29625. * Set the value of an uniform to a Color3
  29626. * @param uniform defines the webGL uniform location where to store the value
  29627. * @param color3 defines the color to store
  29628. */
  29629. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29630. /**
  29631. * Set the value of an uniform to a Color3 and an alpha value
  29632. * @param uniform defines the webGL uniform location where to store the value
  29633. * @param color3 defines the color to store
  29634. * @param alpha defines the alpha component to store
  29635. */
  29636. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29637. /**
  29638. * Sets a Color4 on a uniform variable
  29639. * @param uniform defines the uniform location
  29640. * @param color4 defines the value to be set
  29641. */
  29642. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29643. /**
  29644. * Set various states to the webGL context
  29645. * @param culling defines backface culling state
  29646. * @param zOffset defines the value to apply to zOffset (0 by default)
  29647. * @param force defines if states must be applied even if cache is up to date
  29648. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29649. */
  29650. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29651. /**
  29652. * Set the z offset to apply to current rendering
  29653. * @param value defines the offset to apply
  29654. */
  29655. setZOffset(value: number): void;
  29656. /**
  29657. * Gets the current value of the zOffset
  29658. * @returns the current zOffset state
  29659. */
  29660. getZOffset(): number;
  29661. /**
  29662. * Enable or disable depth buffering
  29663. * @param enable defines the state to set
  29664. */
  29665. setDepthBuffer(enable: boolean): void;
  29666. /**
  29667. * Gets a boolean indicating if depth writing is enabled
  29668. * @returns the current depth writing state
  29669. */
  29670. getDepthWrite(): boolean;
  29671. /**
  29672. * Enable or disable depth writing
  29673. * @param enable defines the state to set
  29674. */
  29675. setDepthWrite(enable: boolean): void;
  29676. /**
  29677. * Enable or disable color writing
  29678. * @param enable defines the state to set
  29679. */
  29680. setColorWrite(enable: boolean): void;
  29681. /**
  29682. * Gets a boolean indicating if color writing is enabled
  29683. * @returns the current color writing state
  29684. */
  29685. getColorWrite(): boolean;
  29686. /**
  29687. * Sets alpha constants used by some alpha blending modes
  29688. * @param r defines the red component
  29689. * @param g defines the green component
  29690. * @param b defines the blue component
  29691. * @param a defines the alpha component
  29692. */
  29693. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29694. /**
  29695. * Sets the current alpha mode
  29696. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29697. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29698. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29699. */
  29700. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29701. /**
  29702. * Gets the current alpha mode
  29703. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29704. * @returns the current alpha mode
  29705. */
  29706. getAlphaMode(): number;
  29707. /**
  29708. * Clears the list of texture accessible through engine.
  29709. * This can help preventing texture load conflict due to name collision.
  29710. */
  29711. clearInternalTexturesCache(): void;
  29712. /**
  29713. * Force the entire cache to be cleared
  29714. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29715. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29716. */
  29717. wipeCaches(bruteForce?: boolean): void;
  29718. /**
  29719. * Set the compressed texture format to use, based on the formats you have, and the formats
  29720. * supported by the hardware / browser.
  29721. *
  29722. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29723. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29724. * to API arguments needed to compressed textures. This puts the burden on the container
  29725. * generator to house the arcane code for determining these for current & future formats.
  29726. *
  29727. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29728. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29729. *
  29730. * Note: The result of this call is not taken into account when a texture is base64.
  29731. *
  29732. * @param formatsAvailable defines the list of those format families you have created
  29733. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29734. *
  29735. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29736. * @returns The extension selected.
  29737. */
  29738. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29739. /** @hidden */
  29740. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29741. min: number;
  29742. mag: number;
  29743. };
  29744. /** @hidden */
  29745. _createTexture(): WebGLTexture;
  29746. /**
  29747. * Usually called from Texture.ts.
  29748. * Passed information to create a WebGLTexture
  29749. * @param urlArg defines a value which contains one of the following:
  29750. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29751. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29752. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29753. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29754. * @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)
  29755. * @param scene needed for loading to the correct scene
  29756. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29757. * @param onLoad optional callback to be called upon successful completion
  29758. * @param onError optional callback to be called upon failure
  29759. * @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
  29760. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29761. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29762. * @param forcedExtension defines the extension to use to pick the right loader
  29763. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29764. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29765. */
  29766. 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;
  29767. /**
  29768. * @hidden
  29769. * Rescales a texture
  29770. * @param source input texutre
  29771. * @param destination destination texture
  29772. * @param scene scene to use to render the resize
  29773. * @param internalFormat format to use when resizing
  29774. * @param onComplete callback to be called when resize has completed
  29775. */
  29776. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  29777. private _unpackFlipYCached;
  29778. /**
  29779. * In case you are sharing the context with other applications, it might
  29780. * be interested to not cache the unpack flip y state to ensure a consistent
  29781. * value would be set.
  29782. */
  29783. enableUnpackFlipYCached: boolean;
  29784. /** @hidden */
  29785. _unpackFlipY(value: boolean): void;
  29786. /** @hidden */
  29787. _getUnpackAlignement(): number;
  29788. /**
  29789. * Creates a dynamic texture
  29790. * @param width defines the width of the texture
  29791. * @param height defines the height of the texture
  29792. * @param generateMipMaps defines if the engine should generate the mip levels
  29793. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29794. * @returns the dynamic texture inside an InternalTexture
  29795. */
  29796. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29797. /**
  29798. * Update the sampling mode of a given texture
  29799. * @param samplingMode defines the required sampling mode
  29800. * @param texture defines the texture to update
  29801. */
  29802. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29803. /**
  29804. * Update the content of a dynamic texture
  29805. * @param texture defines the texture to update
  29806. * @param canvas defines the canvas containing the source
  29807. * @param invertY defines if data must be stored with Y axis inverted
  29808. * @param premulAlpha defines if alpha is stored as premultiplied
  29809. * @param format defines the format of the data
  29810. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29811. */
  29812. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29813. /**
  29814. * Update a video texture
  29815. * @param texture defines the texture to update
  29816. * @param video defines the video element to use
  29817. * @param invertY defines if data must be stored with Y axis inverted
  29818. */
  29819. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29820. /**
  29821. * Updates a depth texture Comparison Mode and Function.
  29822. * If the comparison Function is equal to 0, the mode will be set to none.
  29823. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29824. * @param texture The texture to set the comparison function for
  29825. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29826. */
  29827. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29828. /** @hidden */
  29829. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29830. width: number;
  29831. height: number;
  29832. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29833. /**
  29834. * Creates a depth stencil texture.
  29835. * This is only available in WebGL 2 or with the depth texture extension available.
  29836. * @param size The size of face edge in the texture.
  29837. * @param options The options defining the texture.
  29838. * @returns The texture
  29839. */
  29840. createDepthStencilTexture(size: number | {
  29841. width: number;
  29842. height: number;
  29843. }, options: DepthTextureCreationOptions): InternalTexture;
  29844. /**
  29845. * Creates a depth stencil texture.
  29846. * This is only available in WebGL 2 or with the depth texture extension available.
  29847. * @param size The size of face edge in the texture.
  29848. * @param options The options defining the texture.
  29849. * @returns The texture
  29850. */
  29851. private _createDepthStencilTexture;
  29852. /**
  29853. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29854. * @param renderTarget The render target to set the frame buffer for
  29855. */
  29856. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29857. /**
  29858. * Creates a new render target texture
  29859. * @param size defines the size of the texture
  29860. * @param options defines the options used to create the texture
  29861. * @returns a new render target texture stored in an InternalTexture
  29862. */
  29863. createRenderTargetTexture(size: number | {
  29864. width: number;
  29865. height: number;
  29866. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29867. /** @hidden */
  29868. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29869. /**
  29870. * Updates the sample count of a render target texture
  29871. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29872. * @param texture defines the texture to update
  29873. * @param samples defines the sample count to set
  29874. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29875. */
  29876. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29877. /** @hidden */
  29878. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29879. /** @hidden */
  29880. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  29881. /** @hidden */
  29882. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29883. /** @hidden */
  29884. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29885. /**
  29886. * @hidden
  29887. */
  29888. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29889. private _prepareWebGLTextureContinuation;
  29890. private _prepareWebGLTexture;
  29891. /** @hidden */
  29892. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29893. /** @hidden */
  29894. _releaseFramebufferObjects(texture: InternalTexture): void;
  29895. /** @hidden */
  29896. _releaseTexture(texture: InternalTexture): void;
  29897. private setProgram;
  29898. private _boundUniforms;
  29899. /**
  29900. * Binds an effect to the webGL context
  29901. * @param effect defines the effect to bind
  29902. */
  29903. bindSamplers(effect: Effect): void;
  29904. private _activateCurrentTexture;
  29905. /** @hidden */
  29906. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29907. /** @hidden */
  29908. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29909. /**
  29910. * Sets a texture to the webGL context from a postprocess
  29911. * @param channel defines the channel to use
  29912. * @param postProcess defines the source postprocess
  29913. */
  29914. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29915. /**
  29916. * Binds the output of the passed in post process to the texture channel specified
  29917. * @param channel The channel the texture should be bound to
  29918. * @param postProcess The post process which's output should be bound
  29919. */
  29920. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29921. /**
  29922. * Unbind all textures from the webGL context
  29923. */
  29924. unbindAllTextures(): void;
  29925. /**
  29926. * Sets a texture to the according uniform.
  29927. * @param channel The texture channel
  29928. * @param uniform The uniform to set
  29929. * @param texture The texture to apply
  29930. */
  29931. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29932. /**
  29933. * Sets a depth stencil texture from a render target to the according uniform.
  29934. * @param channel The texture channel
  29935. * @param uniform The uniform to set
  29936. * @param texture The render target texture containing the depth stencil texture to apply
  29937. */
  29938. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29939. private _bindSamplerUniformToChannel;
  29940. private _getTextureWrapMode;
  29941. private _setTexture;
  29942. /**
  29943. * Sets an array of texture to the webGL context
  29944. * @param channel defines the channel where the texture array must be set
  29945. * @param uniform defines the associated uniform location
  29946. * @param textures defines the array of textures to bind
  29947. */
  29948. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29949. /** @hidden */
  29950. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29951. private _setTextureParameterFloat;
  29952. private _setTextureParameterInteger;
  29953. /**
  29954. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29955. * @param x defines the x coordinate of the rectangle where pixels must be read
  29956. * @param y defines the y coordinate of the rectangle where pixels must be read
  29957. * @param width defines the width of the rectangle where pixels must be read
  29958. * @param height defines the height of the rectangle where pixels must be read
  29959. * @returns a Uint8Array containing RGBA colors
  29960. */
  29961. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29962. /**
  29963. * Add an externaly attached data from its key.
  29964. * This method call will fail and return false, if such key already exists.
  29965. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29966. * @param key the unique key that identifies the data
  29967. * @param data the data object to associate to the key for this Engine instance
  29968. * @return true if no such key were already present and the data was added successfully, false otherwise
  29969. */
  29970. addExternalData<T>(key: string, data: T): boolean;
  29971. /**
  29972. * Get an externaly attached data from its key
  29973. * @param key the unique key that identifies the data
  29974. * @return the associated data, if present (can be null), or undefined if not present
  29975. */
  29976. getExternalData<T>(key: string): T;
  29977. /**
  29978. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29979. * @param key the unique key that identifies the data
  29980. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29981. * @return the associated data, can be null if the factory returned null.
  29982. */
  29983. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29984. /**
  29985. * Remove an externaly attached data from the Engine instance
  29986. * @param key the unique key that identifies the data
  29987. * @return true if the data was successfully removed, false if it doesn't exist
  29988. */
  29989. removeExternalData(key: string): boolean;
  29990. /**
  29991. * Unbind all vertex attributes from the webGL context
  29992. */
  29993. unbindAllAttributes(): void;
  29994. /**
  29995. * 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
  29996. */
  29997. releaseEffects(): void;
  29998. /**
  29999. * Dispose and release all associated resources
  30000. */
  30001. dispose(): void;
  30002. /**
  30003. * Display the loading screen
  30004. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30005. */
  30006. displayLoadingUI(): void;
  30007. /**
  30008. * Hide the loading screen
  30009. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30010. */
  30011. hideLoadingUI(): void;
  30012. /**
  30013. * Gets the current loading screen object
  30014. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30015. */
  30016. /**
  30017. * Sets the current loading screen object
  30018. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30019. */
  30020. loadingScreen: ILoadingScreen;
  30021. /**
  30022. * Sets the current loading screen text
  30023. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30024. */
  30025. loadingUIText: string;
  30026. /**
  30027. * Sets the current loading screen background color
  30028. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30029. */
  30030. loadingUIBackgroundColor: string;
  30031. /**
  30032. * Attach a new callback raised when context lost event is fired
  30033. * @param callback defines the callback to call
  30034. */
  30035. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30036. /**
  30037. * Attach a new callback raised when context restored event is fired
  30038. * @param callback defines the callback to call
  30039. */
  30040. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30041. /**
  30042. * Gets the source code of the vertex shader associated with a specific webGL program
  30043. * @param program defines the program to use
  30044. * @returns a string containing the source code of the vertex shader associated with the program
  30045. */
  30046. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  30047. /**
  30048. * Gets the source code of the fragment shader associated with a specific webGL program
  30049. * @param program defines the program to use
  30050. * @returns a string containing the source code of the fragment shader associated with the program
  30051. */
  30052. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  30053. /**
  30054. * Get the current error code of the webGL context
  30055. * @returns the error code
  30056. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30057. */
  30058. getError(): number;
  30059. /**
  30060. * Gets the current framerate
  30061. * @returns a number representing the framerate
  30062. */
  30063. getFps(): number;
  30064. /**
  30065. * Gets the time spent between current and previous frame
  30066. * @returns a number representing the delta time in ms
  30067. */
  30068. getDeltaTime(): number;
  30069. private _measureFps;
  30070. /** @hidden */
  30071. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  30072. private _canRenderToFloatFramebuffer;
  30073. private _canRenderToHalfFloatFramebuffer;
  30074. private _canRenderToFramebuffer;
  30075. /** @hidden */
  30076. _getWebGLTextureType(type: number): number;
  30077. /** @hidden */
  30078. _getInternalFormat(format: number): number;
  30079. /** @hidden */
  30080. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30081. /** @hidden */
  30082. _getRGBAMultiSampleBufferFormat(type: number): number;
  30083. /** @hidden */
  30084. _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;
  30085. /** @hidden */
  30086. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  30087. /**
  30088. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30089. * @returns true if the engine can be created
  30090. * @ignorenaming
  30091. */
  30092. static isSupported(): boolean;
  30093. }
  30094. }
  30095. declare module "babylonjs/Materials/effect" {
  30096. import { Observable } from "babylonjs/Misc/observable";
  30097. import { Nullable } from "babylonjs/types";
  30098. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  30099. import { IDisposable } from "babylonjs/scene";
  30100. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30101. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30102. import { Engine } from "babylonjs/Engines/engine";
  30103. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30104. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30105. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30106. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30107. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30108. /**
  30109. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  30110. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  30111. */
  30112. export class EffectFallbacks {
  30113. private _defines;
  30114. private _currentRank;
  30115. private _maxRank;
  30116. private _mesh;
  30117. /**
  30118. * Removes the fallback from the bound mesh.
  30119. */
  30120. unBindMesh(): void;
  30121. /**
  30122. * Adds a fallback on the specified property.
  30123. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  30124. * @param define The name of the define in the shader
  30125. */
  30126. addFallback(rank: number, define: string): void;
  30127. /**
  30128. * Sets the mesh to use CPU skinning when needing to fallback.
  30129. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  30130. * @param mesh The mesh to use the fallbacks.
  30131. */
  30132. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  30133. /**
  30134. * Checks to see if more fallbacks are still availible.
  30135. */
  30136. readonly isMoreFallbacks: boolean;
  30137. /**
  30138. * Removes the defines that should be removed when falling back.
  30139. * @param currentDefines defines the current define statements for the shader.
  30140. * @param effect defines the current effect we try to compile
  30141. * @returns The resulting defines with defines of the current rank removed.
  30142. */
  30143. reduce(currentDefines: string, effect: Effect): string;
  30144. }
  30145. /**
  30146. * Options to be used when creating an effect.
  30147. */
  30148. export class EffectCreationOptions {
  30149. /**
  30150. * Atrributes that will be used in the shader.
  30151. */
  30152. attributes: string[];
  30153. /**
  30154. * Uniform varible names that will be set in the shader.
  30155. */
  30156. uniformsNames: string[];
  30157. /**
  30158. * Uniform buffer varible names that will be set in the shader.
  30159. */
  30160. uniformBuffersNames: string[];
  30161. /**
  30162. * Sampler texture variable names that will be set in the shader.
  30163. */
  30164. samplers: string[];
  30165. /**
  30166. * Define statements that will be set in the shader.
  30167. */
  30168. defines: any;
  30169. /**
  30170. * Possible fallbacks for this effect to improve performance when needed.
  30171. */
  30172. fallbacks: Nullable<EffectFallbacks>;
  30173. /**
  30174. * Callback that will be called when the shader is compiled.
  30175. */
  30176. onCompiled: Nullable<(effect: Effect) => void>;
  30177. /**
  30178. * Callback that will be called if an error occurs during shader compilation.
  30179. */
  30180. onError: Nullable<(effect: Effect, errors: string) => void>;
  30181. /**
  30182. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30183. */
  30184. indexParameters: any;
  30185. /**
  30186. * Max number of lights that can be used in the shader.
  30187. */
  30188. maxSimultaneousLights: number;
  30189. /**
  30190. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30191. */
  30192. transformFeedbackVaryings: Nullable<string[]>;
  30193. }
  30194. /**
  30195. * Effect containing vertex and fragment shader that can be executed on an object.
  30196. */
  30197. export class Effect implements IDisposable {
  30198. /**
  30199. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30200. */
  30201. static ShadersRepository: string;
  30202. /**
  30203. * Name of the effect.
  30204. */
  30205. name: any;
  30206. /**
  30207. * String container all the define statements that should be set on the shader.
  30208. */
  30209. defines: string;
  30210. /**
  30211. * Callback that will be called when the shader is compiled.
  30212. */
  30213. onCompiled: Nullable<(effect: Effect) => void>;
  30214. /**
  30215. * Callback that will be called if an error occurs during shader compilation.
  30216. */
  30217. onError: Nullable<(effect: Effect, errors: string) => void>;
  30218. /**
  30219. * Callback that will be called when effect is bound.
  30220. */
  30221. onBind: Nullable<(effect: Effect) => void>;
  30222. /**
  30223. * Unique ID of the effect.
  30224. */
  30225. uniqueId: number;
  30226. /**
  30227. * Observable that will be called when the shader is compiled.
  30228. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30229. */
  30230. onCompileObservable: Observable<Effect>;
  30231. /**
  30232. * Observable that will be called if an error occurs during shader compilation.
  30233. */
  30234. onErrorObservable: Observable<Effect>;
  30235. /** @hidden */
  30236. _onBindObservable: Nullable<Observable<Effect>>;
  30237. /**
  30238. * Observable that will be called when effect is bound.
  30239. */
  30240. readonly onBindObservable: Observable<Effect>;
  30241. /** @hidden */
  30242. _bonesComputationForcedToCPU: boolean;
  30243. private static _uniqueIdSeed;
  30244. private _engine;
  30245. private _uniformBuffersNames;
  30246. private _uniformsNames;
  30247. private _samplerList;
  30248. private _samplers;
  30249. private _isReady;
  30250. private _compilationError;
  30251. private _attributesNames;
  30252. private _attributes;
  30253. private _uniforms;
  30254. /**
  30255. * Key for the effect.
  30256. * @hidden
  30257. */
  30258. _key: string;
  30259. private _indexParameters;
  30260. private _fallbacks;
  30261. private _vertexSourceCode;
  30262. private _fragmentSourceCode;
  30263. private _vertexSourceCodeOverride;
  30264. private _fragmentSourceCodeOverride;
  30265. private _transformFeedbackVaryings;
  30266. /**
  30267. * Compiled shader to webGL program.
  30268. * @hidden
  30269. */
  30270. _pipelineContext: Nullable<IPipelineContext>;
  30271. private _valueCache;
  30272. private static _baseCache;
  30273. /**
  30274. * Instantiates an effect.
  30275. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30276. * @param baseName Name of the effect.
  30277. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30278. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30279. * @param samplers List of sampler variables that will be passed to the shader.
  30280. * @param engine Engine to be used to render the effect
  30281. * @param defines Define statements to be added to the shader.
  30282. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30283. * @param onCompiled Callback that will be called when the shader is compiled.
  30284. * @param onError Callback that will be called if an error occurs during shader compilation.
  30285. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30286. */
  30287. 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);
  30288. private _useFinalCode;
  30289. /**
  30290. * Unique key for this effect
  30291. */
  30292. readonly key: string;
  30293. /**
  30294. * If the effect has been compiled and prepared.
  30295. * @returns if the effect is compiled and prepared.
  30296. */
  30297. isReady(): boolean;
  30298. /**
  30299. * The engine the effect was initialized with.
  30300. * @returns the engine.
  30301. */
  30302. getEngine(): Engine;
  30303. /**
  30304. * The pipeline context for this effect
  30305. * @returns the associated pipeline context
  30306. */
  30307. getPipelineContext(): Nullable<IPipelineContext>;
  30308. /**
  30309. * The set of names of attribute variables for the shader.
  30310. * @returns An array of attribute names.
  30311. */
  30312. getAttributesNames(): string[];
  30313. /**
  30314. * Returns the attribute at the given index.
  30315. * @param index The index of the attribute.
  30316. * @returns The location of the attribute.
  30317. */
  30318. getAttributeLocation(index: number): number;
  30319. /**
  30320. * Returns the attribute based on the name of the variable.
  30321. * @param name of the attribute to look up.
  30322. * @returns the attribute location.
  30323. */
  30324. getAttributeLocationByName(name: string): number;
  30325. /**
  30326. * The number of attributes.
  30327. * @returns the numnber of attributes.
  30328. */
  30329. getAttributesCount(): number;
  30330. /**
  30331. * Gets the index of a uniform variable.
  30332. * @param uniformName of the uniform to look up.
  30333. * @returns the index.
  30334. */
  30335. getUniformIndex(uniformName: string): number;
  30336. /**
  30337. * Returns the attribute based on the name of the variable.
  30338. * @param uniformName of the uniform to look up.
  30339. * @returns the location of the uniform.
  30340. */
  30341. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30342. /**
  30343. * Returns an array of sampler variable names
  30344. * @returns The array of sampler variable neames.
  30345. */
  30346. getSamplers(): string[];
  30347. /**
  30348. * The error from the last compilation.
  30349. * @returns the error string.
  30350. */
  30351. getCompilationError(): string;
  30352. /**
  30353. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30354. * @param func The callback to be used.
  30355. */
  30356. executeWhenCompiled(func: (effect: Effect) => void): void;
  30357. private _checkIsReady;
  30358. /** @hidden */
  30359. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  30360. /** @hidden */
  30361. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  30362. /** @hidden */
  30363. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  30364. /**
  30365. * Recompiles the webGL program
  30366. * @param vertexSourceCode The source code for the vertex shader.
  30367. * @param fragmentSourceCode The source code for the fragment shader.
  30368. * @param onCompiled Callback called when completed.
  30369. * @param onError Callback called on error.
  30370. * @hidden
  30371. */
  30372. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30373. /**
  30374. * Prepares the effect
  30375. * @hidden
  30376. */
  30377. _prepareEffect(): void;
  30378. /**
  30379. * Checks if the effect is supported. (Must be called after compilation)
  30380. */
  30381. readonly isSupported: boolean;
  30382. /**
  30383. * Binds a texture to the engine to be used as output of the shader.
  30384. * @param channel Name of the output variable.
  30385. * @param texture Texture to bind.
  30386. * @hidden
  30387. */
  30388. _bindTexture(channel: string, texture: InternalTexture): void;
  30389. /**
  30390. * Sets a texture on the engine to be used in the shader.
  30391. * @param channel Name of the sampler variable.
  30392. * @param texture Texture to set.
  30393. */
  30394. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30395. /**
  30396. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30397. * @param channel Name of the sampler variable.
  30398. * @param texture Texture to set.
  30399. */
  30400. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30401. /**
  30402. * Sets an array of textures on the engine to be used in the shader.
  30403. * @param channel Name of the variable.
  30404. * @param textures Textures to set.
  30405. */
  30406. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30407. /**
  30408. * 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)
  30409. * @param channel Name of the sampler variable.
  30410. * @param postProcess Post process to get the input texture from.
  30411. */
  30412. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30413. /**
  30414. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30415. * 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)
  30416. * @param channel Name of the sampler variable.
  30417. * @param postProcess Post process to get the output texture from.
  30418. */
  30419. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30420. /** @hidden */
  30421. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  30422. /** @hidden */
  30423. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30424. /** @hidden */
  30425. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30426. /** @hidden */
  30427. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30428. /**
  30429. * Binds a buffer to a uniform.
  30430. * @param buffer Buffer to bind.
  30431. * @param name Name of the uniform variable to bind to.
  30432. */
  30433. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30434. /**
  30435. * Binds block to a uniform.
  30436. * @param blockName Name of the block to bind.
  30437. * @param index Index to bind.
  30438. */
  30439. bindUniformBlock(blockName: string, index: number): void;
  30440. /**
  30441. * Sets an interger value on a uniform variable.
  30442. * @param uniformName Name of the variable.
  30443. * @param value Value to be set.
  30444. * @returns this effect.
  30445. */
  30446. setInt(uniformName: string, value: number): Effect;
  30447. /**
  30448. * Sets an int array on a uniform variable.
  30449. * @param uniformName Name of the variable.
  30450. * @param array array to be set.
  30451. * @returns this effect.
  30452. */
  30453. setIntArray(uniformName: string, array: Int32Array): Effect;
  30454. /**
  30455. * 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)
  30456. * @param uniformName Name of the variable.
  30457. * @param array array to be set.
  30458. * @returns this effect.
  30459. */
  30460. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30461. /**
  30462. * 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)
  30463. * @param uniformName Name of the variable.
  30464. * @param array array to be set.
  30465. * @returns this effect.
  30466. */
  30467. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30468. /**
  30469. * 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)
  30470. * @param uniformName Name of the variable.
  30471. * @param array array to be set.
  30472. * @returns this effect.
  30473. */
  30474. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30475. /**
  30476. * Sets an float array on a uniform variable.
  30477. * @param uniformName Name of the variable.
  30478. * @param array array to be set.
  30479. * @returns this effect.
  30480. */
  30481. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30482. /**
  30483. * 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)
  30484. * @param uniformName Name of the variable.
  30485. * @param array array to be set.
  30486. * @returns this effect.
  30487. */
  30488. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30489. /**
  30490. * 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)
  30491. * @param uniformName Name of the variable.
  30492. * @param array array to be set.
  30493. * @returns this effect.
  30494. */
  30495. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30496. /**
  30497. * 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)
  30498. * @param uniformName Name of the variable.
  30499. * @param array array to be set.
  30500. * @returns this effect.
  30501. */
  30502. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30503. /**
  30504. * Sets an array on a uniform variable.
  30505. * @param uniformName Name of the variable.
  30506. * @param array array to be set.
  30507. * @returns this effect.
  30508. */
  30509. setArray(uniformName: string, array: number[]): Effect;
  30510. /**
  30511. * 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)
  30512. * @param uniformName Name of the variable.
  30513. * @param array array to be set.
  30514. * @returns this effect.
  30515. */
  30516. setArray2(uniformName: string, array: number[]): Effect;
  30517. /**
  30518. * 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)
  30519. * @param uniformName Name of the variable.
  30520. * @param array array to be set.
  30521. * @returns this effect.
  30522. */
  30523. setArray3(uniformName: string, array: number[]): Effect;
  30524. /**
  30525. * 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)
  30526. * @param uniformName Name of the variable.
  30527. * @param array array to be set.
  30528. * @returns this effect.
  30529. */
  30530. setArray4(uniformName: string, array: number[]): Effect;
  30531. /**
  30532. * Sets matrices on a uniform variable.
  30533. * @param uniformName Name of the variable.
  30534. * @param matrices matrices to be set.
  30535. * @returns this effect.
  30536. */
  30537. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30538. /**
  30539. * Sets matrix on a uniform variable.
  30540. * @param uniformName Name of the variable.
  30541. * @param matrix matrix to be set.
  30542. * @returns this effect.
  30543. */
  30544. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30545. /**
  30546. * 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)
  30547. * @param uniformName Name of the variable.
  30548. * @param matrix matrix to be set.
  30549. * @returns this effect.
  30550. */
  30551. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30552. /**
  30553. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30554. * @param uniformName Name of the variable.
  30555. * @param matrix matrix to be set.
  30556. * @returns this effect.
  30557. */
  30558. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30559. /**
  30560. * Sets a float on a uniform variable.
  30561. * @param uniformName Name of the variable.
  30562. * @param value value to be set.
  30563. * @returns this effect.
  30564. */
  30565. setFloat(uniformName: string, value: number): Effect;
  30566. /**
  30567. * Sets a boolean on a uniform variable.
  30568. * @param uniformName Name of the variable.
  30569. * @param bool value to be set.
  30570. * @returns this effect.
  30571. */
  30572. setBool(uniformName: string, bool: boolean): Effect;
  30573. /**
  30574. * Sets a Vector2 on a uniform variable.
  30575. * @param uniformName Name of the variable.
  30576. * @param vector2 vector2 to be set.
  30577. * @returns this effect.
  30578. */
  30579. setVector2(uniformName: string, vector2: Vector2): Effect;
  30580. /**
  30581. * Sets a float2 on a uniform variable.
  30582. * @param uniformName Name of the variable.
  30583. * @param x First float in float2.
  30584. * @param y Second float in float2.
  30585. * @returns this effect.
  30586. */
  30587. setFloat2(uniformName: string, x: number, y: number): Effect;
  30588. /**
  30589. * Sets a Vector3 on a uniform variable.
  30590. * @param uniformName Name of the variable.
  30591. * @param vector3 Value to be set.
  30592. * @returns this effect.
  30593. */
  30594. setVector3(uniformName: string, vector3: Vector3): Effect;
  30595. /**
  30596. * Sets a float3 on a uniform variable.
  30597. * @param uniformName Name of the variable.
  30598. * @param x First float in float3.
  30599. * @param y Second float in float3.
  30600. * @param z Third float in float3.
  30601. * @returns this effect.
  30602. */
  30603. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30604. /**
  30605. * Sets a Vector4 on a uniform variable.
  30606. * @param uniformName Name of the variable.
  30607. * @param vector4 Value to be set.
  30608. * @returns this effect.
  30609. */
  30610. setVector4(uniformName: string, vector4: Vector4): Effect;
  30611. /**
  30612. * Sets a float4 on a uniform variable.
  30613. * @param uniformName Name of the variable.
  30614. * @param x First float in float4.
  30615. * @param y Second float in float4.
  30616. * @param z Third float in float4.
  30617. * @param w Fourth float in float4.
  30618. * @returns this effect.
  30619. */
  30620. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30621. /**
  30622. * Sets a Color3 on a uniform variable.
  30623. * @param uniformName Name of the variable.
  30624. * @param color3 Value to be set.
  30625. * @returns this effect.
  30626. */
  30627. setColor3(uniformName: string, color3: Color3): Effect;
  30628. /**
  30629. * Sets a Color4 on a uniform variable.
  30630. * @param uniformName Name of the variable.
  30631. * @param color3 Value to be set.
  30632. * @param alpha Alpha value to be set.
  30633. * @returns this effect.
  30634. */
  30635. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30636. /**
  30637. * Sets a Color4 on a uniform variable
  30638. * @param uniformName defines the name of the variable
  30639. * @param color4 defines the value to be set
  30640. * @returns this effect.
  30641. */
  30642. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30643. /** Release all associated resources */
  30644. dispose(): void;
  30645. /**
  30646. * This function will add a new shader to the shader store
  30647. * @param name the name of the shader
  30648. * @param pixelShader optional pixel shader content
  30649. * @param vertexShader optional vertex shader content
  30650. */
  30651. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30652. /**
  30653. * Store of each shader (The can be looked up using effect.key)
  30654. */
  30655. static ShadersStore: {
  30656. [key: string]: string;
  30657. };
  30658. /**
  30659. * Store of each included file for a shader (The can be looked up using effect.key)
  30660. */
  30661. static IncludesShadersStore: {
  30662. [key: string]: string;
  30663. };
  30664. /**
  30665. * Resets the cache of effects.
  30666. */
  30667. static ResetCache(): void;
  30668. }
  30669. }
  30670. declare module "babylonjs/Materials/colorCurves" {
  30671. import { Effect } from "babylonjs/Materials/effect";
  30672. /**
  30673. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30674. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30675. * 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;
  30676. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30677. */
  30678. export class ColorCurves {
  30679. private _dirty;
  30680. private _tempColor;
  30681. private _globalCurve;
  30682. private _highlightsCurve;
  30683. private _midtonesCurve;
  30684. private _shadowsCurve;
  30685. private _positiveCurve;
  30686. private _negativeCurve;
  30687. private _globalHue;
  30688. private _globalDensity;
  30689. private _globalSaturation;
  30690. private _globalExposure;
  30691. /**
  30692. * Gets the global Hue value.
  30693. * 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).
  30694. */
  30695. /**
  30696. * Sets the global Hue value.
  30697. * 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).
  30698. */
  30699. globalHue: number;
  30700. /**
  30701. * Gets the global Density value.
  30702. * 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.
  30703. * Values less than zero provide a filter of opposite hue.
  30704. */
  30705. /**
  30706. * Sets the global Density value.
  30707. * 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.
  30708. * Values less than zero provide a filter of opposite hue.
  30709. */
  30710. globalDensity: number;
  30711. /**
  30712. * Gets the global Saturation value.
  30713. * 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.
  30714. */
  30715. /**
  30716. * Sets the global Saturation value.
  30717. * 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.
  30718. */
  30719. globalSaturation: number;
  30720. /**
  30721. * Gets the global Exposure value.
  30722. * 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.
  30723. */
  30724. /**
  30725. * Sets the global Exposure value.
  30726. * 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.
  30727. */
  30728. globalExposure: number;
  30729. private _highlightsHue;
  30730. private _highlightsDensity;
  30731. private _highlightsSaturation;
  30732. private _highlightsExposure;
  30733. /**
  30734. * Gets the highlights Hue value.
  30735. * 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).
  30736. */
  30737. /**
  30738. * Sets the highlights Hue value.
  30739. * 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).
  30740. */
  30741. highlightsHue: number;
  30742. /**
  30743. * Gets the highlights Density value.
  30744. * 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.
  30745. * Values less than zero provide a filter of opposite hue.
  30746. */
  30747. /**
  30748. * Sets the highlights Density value.
  30749. * 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.
  30750. * Values less than zero provide a filter of opposite hue.
  30751. */
  30752. highlightsDensity: number;
  30753. /**
  30754. * Gets the highlights Saturation value.
  30755. * 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.
  30756. */
  30757. /**
  30758. * Sets the highlights Saturation value.
  30759. * 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.
  30760. */
  30761. highlightsSaturation: number;
  30762. /**
  30763. * Gets the highlights Exposure value.
  30764. * 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.
  30765. */
  30766. /**
  30767. * Sets the highlights Exposure value.
  30768. * 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.
  30769. */
  30770. highlightsExposure: number;
  30771. private _midtonesHue;
  30772. private _midtonesDensity;
  30773. private _midtonesSaturation;
  30774. private _midtonesExposure;
  30775. /**
  30776. * Gets the midtones Hue value.
  30777. * 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).
  30778. */
  30779. /**
  30780. * Sets the midtones Hue value.
  30781. * 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).
  30782. */
  30783. midtonesHue: number;
  30784. /**
  30785. * Gets the midtones Density value.
  30786. * 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.
  30787. * Values less than zero provide a filter of opposite hue.
  30788. */
  30789. /**
  30790. * Sets the midtones Density value.
  30791. * 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.
  30792. * Values less than zero provide a filter of opposite hue.
  30793. */
  30794. midtonesDensity: number;
  30795. /**
  30796. * Gets the midtones Saturation value.
  30797. * 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.
  30798. */
  30799. /**
  30800. * Sets the midtones Saturation value.
  30801. * 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.
  30802. */
  30803. midtonesSaturation: number;
  30804. /**
  30805. * Gets the midtones Exposure value.
  30806. * 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.
  30807. */
  30808. /**
  30809. * Sets the midtones Exposure value.
  30810. * 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.
  30811. */
  30812. midtonesExposure: number;
  30813. private _shadowsHue;
  30814. private _shadowsDensity;
  30815. private _shadowsSaturation;
  30816. private _shadowsExposure;
  30817. /**
  30818. * Gets the shadows Hue value.
  30819. * 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).
  30820. */
  30821. /**
  30822. * Sets the shadows Hue value.
  30823. * 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).
  30824. */
  30825. shadowsHue: number;
  30826. /**
  30827. * Gets the shadows Density value.
  30828. * 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.
  30829. * Values less than zero provide a filter of opposite hue.
  30830. */
  30831. /**
  30832. * Sets the shadows Density value.
  30833. * 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.
  30834. * Values less than zero provide a filter of opposite hue.
  30835. */
  30836. shadowsDensity: number;
  30837. /**
  30838. * Gets the shadows Saturation value.
  30839. * 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.
  30840. */
  30841. /**
  30842. * Sets the shadows Saturation value.
  30843. * 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.
  30844. */
  30845. shadowsSaturation: number;
  30846. /**
  30847. * Gets the shadows Exposure value.
  30848. * 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.
  30849. */
  30850. /**
  30851. * Sets the shadows Exposure value.
  30852. * 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.
  30853. */
  30854. shadowsExposure: number;
  30855. /**
  30856. * Returns the class name
  30857. * @returns The class name
  30858. */
  30859. getClassName(): string;
  30860. /**
  30861. * Binds the color curves to the shader.
  30862. * @param colorCurves The color curve to bind
  30863. * @param effect The effect to bind to
  30864. * @param positiveUniform The positive uniform shader parameter
  30865. * @param neutralUniform The neutral uniform shader parameter
  30866. * @param negativeUniform The negative uniform shader parameter
  30867. */
  30868. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30869. /**
  30870. * Prepare the list of uniforms associated with the ColorCurves effects.
  30871. * @param uniformsList The list of uniforms used in the effect
  30872. */
  30873. static PrepareUniforms(uniformsList: string[]): void;
  30874. /**
  30875. * Returns color grading data based on a hue, density, saturation and exposure value.
  30876. * @param filterHue The hue of the color filter.
  30877. * @param filterDensity The density of the color filter.
  30878. * @param saturation The saturation.
  30879. * @param exposure The exposure.
  30880. * @param result The result data container.
  30881. */
  30882. private getColorGradingDataToRef;
  30883. /**
  30884. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30885. * @param value The input slider value in range [-100,100].
  30886. * @returns Adjusted value.
  30887. */
  30888. private static applyColorGradingSliderNonlinear;
  30889. /**
  30890. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30891. * @param hue The hue (H) input.
  30892. * @param saturation The saturation (S) input.
  30893. * @param brightness The brightness (B) input.
  30894. * @result An RGBA color represented as Vector4.
  30895. */
  30896. private static fromHSBToRef;
  30897. /**
  30898. * Returns a value clamped between min and max
  30899. * @param value The value to clamp
  30900. * @param min The minimum of value
  30901. * @param max The maximum of value
  30902. * @returns The clamped value.
  30903. */
  30904. private static clamp;
  30905. /**
  30906. * Clones the current color curve instance.
  30907. * @return The cloned curves
  30908. */
  30909. clone(): ColorCurves;
  30910. /**
  30911. * Serializes the current color curve instance to a json representation.
  30912. * @return a JSON representation
  30913. */
  30914. serialize(): any;
  30915. /**
  30916. * Parses the color curve from a json representation.
  30917. * @param source the JSON source to parse
  30918. * @return The parsed curves
  30919. */
  30920. static Parse(source: any): ColorCurves;
  30921. }
  30922. }
  30923. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30924. import { Observable } from "babylonjs/Misc/observable";
  30925. import { Nullable } from "babylonjs/types";
  30926. import { Color4 } from "babylonjs/Maths/math";
  30927. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30928. import { Effect } from "babylonjs/Materials/effect";
  30929. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30930. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30931. /**
  30932. * Interface to follow in your material defines to integrate easily the
  30933. * Image proccessing functions.
  30934. * @hidden
  30935. */
  30936. export interface IImageProcessingConfigurationDefines {
  30937. IMAGEPROCESSING: boolean;
  30938. VIGNETTE: boolean;
  30939. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30940. VIGNETTEBLENDMODEOPAQUE: boolean;
  30941. TONEMAPPING: boolean;
  30942. TONEMAPPING_ACES: boolean;
  30943. CONTRAST: boolean;
  30944. EXPOSURE: boolean;
  30945. COLORCURVES: boolean;
  30946. COLORGRADING: boolean;
  30947. COLORGRADING3D: boolean;
  30948. SAMPLER3DGREENDEPTH: boolean;
  30949. SAMPLER3DBGRMAP: boolean;
  30950. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30951. }
  30952. /**
  30953. * @hidden
  30954. */
  30955. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30956. IMAGEPROCESSING: boolean;
  30957. VIGNETTE: boolean;
  30958. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30959. VIGNETTEBLENDMODEOPAQUE: boolean;
  30960. TONEMAPPING: boolean;
  30961. TONEMAPPING_ACES: boolean;
  30962. CONTRAST: boolean;
  30963. COLORCURVES: boolean;
  30964. COLORGRADING: boolean;
  30965. COLORGRADING3D: boolean;
  30966. SAMPLER3DGREENDEPTH: boolean;
  30967. SAMPLER3DBGRMAP: boolean;
  30968. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30969. EXPOSURE: boolean;
  30970. constructor();
  30971. }
  30972. /**
  30973. * This groups together the common properties used for image processing either in direct forward pass
  30974. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30975. * or not.
  30976. */
  30977. export class ImageProcessingConfiguration {
  30978. /**
  30979. * Default tone mapping applied in BabylonJS.
  30980. */
  30981. static readonly TONEMAPPING_STANDARD: number;
  30982. /**
  30983. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30984. * to other engines rendering to increase portability.
  30985. */
  30986. static readonly TONEMAPPING_ACES: number;
  30987. /**
  30988. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30989. */
  30990. colorCurves: Nullable<ColorCurves>;
  30991. private _colorCurvesEnabled;
  30992. /**
  30993. * Gets wether the color curves effect is enabled.
  30994. */
  30995. /**
  30996. * Sets wether the color curves effect is enabled.
  30997. */
  30998. colorCurvesEnabled: boolean;
  30999. private _colorGradingTexture;
  31000. /**
  31001. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  31002. */
  31003. /**
  31004. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  31005. */
  31006. colorGradingTexture: Nullable<BaseTexture>;
  31007. private _colorGradingEnabled;
  31008. /**
  31009. * Gets wether the color grading effect is enabled.
  31010. */
  31011. /**
  31012. * Sets wether the color grading effect is enabled.
  31013. */
  31014. colorGradingEnabled: boolean;
  31015. private _colorGradingWithGreenDepth;
  31016. /**
  31017. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  31018. */
  31019. /**
  31020. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  31021. */
  31022. colorGradingWithGreenDepth: boolean;
  31023. private _colorGradingBGR;
  31024. /**
  31025. * Gets wether the color grading texture contains BGR values.
  31026. */
  31027. /**
  31028. * Sets wether the color grading texture contains BGR values.
  31029. */
  31030. colorGradingBGR: boolean;
  31031. /** @hidden */
  31032. _exposure: number;
  31033. /**
  31034. * Gets the Exposure used in the effect.
  31035. */
  31036. /**
  31037. * Sets the Exposure used in the effect.
  31038. */
  31039. exposure: number;
  31040. private _toneMappingEnabled;
  31041. /**
  31042. * Gets wether the tone mapping effect is enabled.
  31043. */
  31044. /**
  31045. * Sets wether the tone mapping effect is enabled.
  31046. */
  31047. toneMappingEnabled: boolean;
  31048. private _toneMappingType;
  31049. /**
  31050. * Gets the type of tone mapping effect.
  31051. */
  31052. /**
  31053. * Sets the type of tone mapping effect used in BabylonJS.
  31054. */
  31055. toneMappingType: number;
  31056. protected _contrast: number;
  31057. /**
  31058. * Gets the contrast used in the effect.
  31059. */
  31060. /**
  31061. * Sets the contrast used in the effect.
  31062. */
  31063. contrast: number;
  31064. /**
  31065. * Vignette stretch size.
  31066. */
  31067. vignetteStretch: number;
  31068. /**
  31069. * Vignette centre X Offset.
  31070. */
  31071. vignetteCentreX: number;
  31072. /**
  31073. * Vignette centre Y Offset.
  31074. */
  31075. vignetteCentreY: number;
  31076. /**
  31077. * Vignette weight or intensity of the vignette effect.
  31078. */
  31079. vignetteWeight: number;
  31080. /**
  31081. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  31082. * if vignetteEnabled is set to true.
  31083. */
  31084. vignetteColor: Color4;
  31085. /**
  31086. * Camera field of view used by the Vignette effect.
  31087. */
  31088. vignetteCameraFov: number;
  31089. private _vignetteBlendMode;
  31090. /**
  31091. * Gets the vignette blend mode allowing different kind of effect.
  31092. */
  31093. /**
  31094. * Sets the vignette blend mode allowing different kind of effect.
  31095. */
  31096. vignetteBlendMode: number;
  31097. private _vignetteEnabled;
  31098. /**
  31099. * Gets wether the vignette effect is enabled.
  31100. */
  31101. /**
  31102. * Sets wether the vignette effect is enabled.
  31103. */
  31104. vignetteEnabled: boolean;
  31105. private _applyByPostProcess;
  31106. /**
  31107. * Gets wether the image processing is applied through a post process or not.
  31108. */
  31109. /**
  31110. * Sets wether the image processing is applied through a post process or not.
  31111. */
  31112. applyByPostProcess: boolean;
  31113. private _isEnabled;
  31114. /**
  31115. * Gets wether the image processing is enabled or not.
  31116. */
  31117. /**
  31118. * Sets wether the image processing is enabled or not.
  31119. */
  31120. isEnabled: boolean;
  31121. /**
  31122. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  31123. */
  31124. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  31125. /**
  31126. * Method called each time the image processing information changes requires to recompile the effect.
  31127. */
  31128. protected _updateParameters(): void;
  31129. /**
  31130. * Gets the current class name.
  31131. * @return "ImageProcessingConfiguration"
  31132. */
  31133. getClassName(): string;
  31134. /**
  31135. * Prepare the list of uniforms associated with the Image Processing effects.
  31136. * @param uniforms The list of uniforms used in the effect
  31137. * @param defines the list of defines currently in use
  31138. */
  31139. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  31140. /**
  31141. * Prepare the list of samplers associated with the Image Processing effects.
  31142. * @param samplersList The list of uniforms used in the effect
  31143. * @param defines the list of defines currently in use
  31144. */
  31145. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  31146. /**
  31147. * Prepare the list of defines associated to the shader.
  31148. * @param defines the list of defines to complete
  31149. * @param forPostProcess Define if we are currently in post process mode or not
  31150. */
  31151. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  31152. /**
  31153. * Returns true if all the image processing information are ready.
  31154. * @returns True if ready, otherwise, false
  31155. */
  31156. isReady(): boolean;
  31157. /**
  31158. * Binds the image processing to the shader.
  31159. * @param effect The effect to bind to
  31160. * @param aspectRatio Define the current aspect ratio of the effect
  31161. */
  31162. bind(effect: Effect, aspectRatio?: number): void;
  31163. /**
  31164. * Clones the current image processing instance.
  31165. * @return The cloned image processing
  31166. */
  31167. clone(): ImageProcessingConfiguration;
  31168. /**
  31169. * Serializes the current image processing instance to a json representation.
  31170. * @return a JSON representation
  31171. */
  31172. serialize(): any;
  31173. /**
  31174. * Parses the image processing from a json representation.
  31175. * @param source the JSON source to parse
  31176. * @return The parsed image processing
  31177. */
  31178. static Parse(source: any): ImageProcessingConfiguration;
  31179. private static _VIGNETTEMODE_MULTIPLY;
  31180. private static _VIGNETTEMODE_OPAQUE;
  31181. /**
  31182. * Used to apply the vignette as a mix with the pixel color.
  31183. */
  31184. static readonly VIGNETTEMODE_MULTIPLY: number;
  31185. /**
  31186. * Used to apply the vignette as a replacement of the pixel color.
  31187. */
  31188. static readonly VIGNETTEMODE_OPAQUE: number;
  31189. }
  31190. }
  31191. declare module "babylonjs/Materials/fresnelParameters" {
  31192. import { Color3 } from "babylonjs/Maths/math";
  31193. /**
  31194. * This represents all the required information to add a fresnel effect on a material:
  31195. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31196. */
  31197. export class FresnelParameters {
  31198. private _isEnabled;
  31199. /**
  31200. * Define if the fresnel effect is enable or not.
  31201. */
  31202. isEnabled: boolean;
  31203. /**
  31204. * Define the color used on edges (grazing angle)
  31205. */
  31206. leftColor: Color3;
  31207. /**
  31208. * Define the color used on center
  31209. */
  31210. rightColor: Color3;
  31211. /**
  31212. * Define bias applied to computed fresnel term
  31213. */
  31214. bias: number;
  31215. /**
  31216. * Defined the power exponent applied to fresnel term
  31217. */
  31218. power: number;
  31219. /**
  31220. * Clones the current fresnel and its valuues
  31221. * @returns a clone fresnel configuration
  31222. */
  31223. clone(): FresnelParameters;
  31224. /**
  31225. * Serializes the current fresnel parameters to a JSON representation.
  31226. * @return the JSON serialization
  31227. */
  31228. serialize(): any;
  31229. /**
  31230. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31231. * @param parsedFresnelParameters Define the JSON representation
  31232. * @returns the parsed parameters
  31233. */
  31234. static Parse(parsedFresnelParameters: any): FresnelParameters;
  31235. }
  31236. }
  31237. declare module "babylonjs/Misc/decorators" {
  31238. import { Nullable } from "babylonjs/types";
  31239. import { Scene } from "babylonjs/scene";
  31240. import { IAnimatable } from "babylonjs/Misc/tools";
  31241. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  31242. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31243. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31244. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31245. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31246. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31247. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31248. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31249. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31250. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31251. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31252. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31253. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31254. /**
  31255. * Decorator used to define property that can be serialized as reference to a camera
  31256. * @param sourceName defines the name of the property to decorate
  31257. */
  31258. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31259. /**
  31260. * Class used to help serialization objects
  31261. */
  31262. export class SerializationHelper {
  31263. /** @hidden */
  31264. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  31265. /** @hidden */
  31266. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  31267. /** @hidden */
  31268. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  31269. /** @hidden */
  31270. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  31271. /**
  31272. * Appends the serialized animations from the source animations
  31273. * @param source Source containing the animations
  31274. * @param destination Target to store the animations
  31275. */
  31276. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  31277. /**
  31278. * Static function used to serialized a specific entity
  31279. * @param entity defines the entity to serialize
  31280. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  31281. * @returns a JSON compatible object representing the serialization of the entity
  31282. */
  31283. static Serialize<T>(entity: T, serializationObject?: any): any;
  31284. /**
  31285. * Creates a new entity from a serialization data object
  31286. * @param creationFunction defines a function used to instanciated the new entity
  31287. * @param source defines the source serialization data
  31288. * @param scene defines the hosting scene
  31289. * @param rootUrl defines the root url for resources
  31290. * @returns a new entity
  31291. */
  31292. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  31293. /**
  31294. * Clones an object
  31295. * @param creationFunction defines the function used to instanciate the new object
  31296. * @param source defines the source object
  31297. * @returns the cloned object
  31298. */
  31299. static Clone<T>(creationFunction: () => T, source: T): T;
  31300. /**
  31301. * Instanciates a new object based on a source one (some data will be shared between both object)
  31302. * @param creationFunction defines the function used to instanciate the new object
  31303. * @param source defines the source object
  31304. * @returns the new object
  31305. */
  31306. static Instanciate<T>(creationFunction: () => T, source: T): T;
  31307. }
  31308. }
  31309. declare module "babylonjs/Cameras/camera" {
  31310. import { SmartArray } from "babylonjs/Misc/smartArray";
  31311. import { Observable } from "babylonjs/Misc/observable";
  31312. import { Nullable } from "babylonjs/types";
  31313. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  31314. import { Scene } from "babylonjs/scene";
  31315. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  31316. import { Node } from "babylonjs/node";
  31317. import { Mesh } from "babylonjs/Meshes/mesh";
  31318. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31319. import { ICullable } from "babylonjs/Culling/boundingInfo";
  31320. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31321. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31322. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  31323. import { Ray } from "babylonjs/Culling/ray";
  31324. /**
  31325. * This is the base class of all the camera used in the application.
  31326. * @see http://doc.babylonjs.com/features/cameras
  31327. */
  31328. export class Camera extends Node {
  31329. /** @hidden */
  31330. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  31331. /**
  31332. * This is the default projection mode used by the cameras.
  31333. * It helps recreating a feeling of perspective and better appreciate depth.
  31334. * This is the best way to simulate real life cameras.
  31335. */
  31336. static readonly PERSPECTIVE_CAMERA: number;
  31337. /**
  31338. * This helps creating camera with an orthographic mode.
  31339. * 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.
  31340. */
  31341. static readonly ORTHOGRAPHIC_CAMERA: number;
  31342. /**
  31343. * This is the default FOV mode for perspective cameras.
  31344. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  31345. */
  31346. static readonly FOVMODE_VERTICAL_FIXED: number;
  31347. /**
  31348. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  31349. */
  31350. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  31351. /**
  31352. * This specifies ther is no need for a camera rig.
  31353. * Basically only one eye is rendered corresponding to the camera.
  31354. */
  31355. static readonly RIG_MODE_NONE: number;
  31356. /**
  31357. * Simulates a camera Rig with one blue eye and one red eye.
  31358. * This can be use with 3d blue and red glasses.
  31359. */
  31360. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  31361. /**
  31362. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  31363. */
  31364. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  31365. /**
  31366. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  31367. */
  31368. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  31369. /**
  31370. * Defines that both eyes of the camera will be rendered over under each other.
  31371. */
  31372. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  31373. /**
  31374. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  31375. */
  31376. static readonly RIG_MODE_VR: number;
  31377. /**
  31378. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  31379. */
  31380. static readonly RIG_MODE_WEBVR: number;
  31381. /**
  31382. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  31383. */
  31384. static readonly RIG_MODE_CUSTOM: number;
  31385. /**
  31386. * Defines if by default attaching controls should prevent the default javascript event to continue.
  31387. */
  31388. static ForceAttachControlToAlwaysPreventDefault: boolean;
  31389. /**
  31390. * Define the input manager associated with the camera.
  31391. */
  31392. inputs: CameraInputsManager<Camera>;
  31393. /** @hidden */
  31394. _position: Vector3;
  31395. /**
  31396. * Define the current local position of the camera in the scene
  31397. */
  31398. position: Vector3;
  31399. /**
  31400. * The vector the camera should consider as up.
  31401. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  31402. */
  31403. upVector: Vector3;
  31404. /**
  31405. * Define the current limit on the left side for an orthographic camera
  31406. * In scene unit
  31407. */
  31408. orthoLeft: Nullable<number>;
  31409. /**
  31410. * Define the current limit on the right side for an orthographic camera
  31411. * In scene unit
  31412. */
  31413. orthoRight: Nullable<number>;
  31414. /**
  31415. * Define the current limit on the bottom side for an orthographic camera
  31416. * In scene unit
  31417. */
  31418. orthoBottom: Nullable<number>;
  31419. /**
  31420. * Define the current limit on the top side for an orthographic camera
  31421. * In scene unit
  31422. */
  31423. orthoTop: Nullable<number>;
  31424. /**
  31425. * Field Of View is set in Radians. (default is 0.8)
  31426. */
  31427. fov: number;
  31428. /**
  31429. * Define the minimum distance the camera can see from.
  31430. * This is important to note that the depth buffer are not infinite and the closer it starts
  31431. * the more your scene might encounter depth fighting issue.
  31432. */
  31433. minZ: number;
  31434. /**
  31435. * Define the maximum distance the camera can see to.
  31436. * This is important to note that the depth buffer are not infinite and the further it end
  31437. * the more your scene might encounter depth fighting issue.
  31438. */
  31439. maxZ: number;
  31440. /**
  31441. * Define the default inertia of the camera.
  31442. * This helps giving a smooth feeling to the camera movement.
  31443. */
  31444. inertia: number;
  31445. /**
  31446. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  31447. */
  31448. mode: number;
  31449. /**
  31450. * Define wether the camera is intermediate.
  31451. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  31452. */
  31453. isIntermediate: boolean;
  31454. /**
  31455. * Define the viewport of the camera.
  31456. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  31457. */
  31458. viewport: Viewport;
  31459. /**
  31460. * Restricts the camera to viewing objects with the same layerMask.
  31461. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  31462. */
  31463. layerMask: number;
  31464. /**
  31465. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  31466. */
  31467. fovMode: number;
  31468. /**
  31469. * Rig mode of the camera.
  31470. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  31471. * This is normally controlled byt the camera themselves as internal use.
  31472. */
  31473. cameraRigMode: number;
  31474. /**
  31475. * Defines the distance between both "eyes" in case of a RIG
  31476. */
  31477. interaxialDistance: number;
  31478. /**
  31479. * Defines if stereoscopic rendering is done side by side or over under.
  31480. */
  31481. isStereoscopicSideBySide: boolean;
  31482. /**
  31483. * 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
  31484. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  31485. * else in the scene.
  31486. */
  31487. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  31488. /**
  31489. * When set, the camera will render to this render target instead of the default canvas
  31490. */
  31491. outputRenderTarget: Nullable<RenderTargetTexture>;
  31492. /**
  31493. * Observable triggered when the camera view matrix has changed.
  31494. */
  31495. onViewMatrixChangedObservable: Observable<Camera>;
  31496. /**
  31497. * Observable triggered when the camera Projection matrix has changed.
  31498. */
  31499. onProjectionMatrixChangedObservable: Observable<Camera>;
  31500. /**
  31501. * Observable triggered when the inputs have been processed.
  31502. */
  31503. onAfterCheckInputsObservable: Observable<Camera>;
  31504. /**
  31505. * Observable triggered when reset has been called and applied to the camera.
  31506. */
  31507. onRestoreStateObservable: Observable<Camera>;
  31508. /** @hidden */
  31509. _cameraRigParams: any;
  31510. /** @hidden */
  31511. _rigCameras: Camera[];
  31512. /** @hidden */
  31513. _rigPostProcess: Nullable<PostProcess>;
  31514. protected _webvrViewMatrix: Matrix;
  31515. /** @hidden */
  31516. _skipRendering: boolean;
  31517. /** @hidden */
  31518. _projectionMatrix: Matrix;
  31519. /** @hidden */
  31520. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31521. /** @hidden */
  31522. _activeMeshes: SmartArray<AbstractMesh>;
  31523. protected _globalPosition: Vector3;
  31524. /** @hidden */
  31525. _computedViewMatrix: Matrix;
  31526. private _doNotComputeProjectionMatrix;
  31527. private _transformMatrix;
  31528. private _frustumPlanes;
  31529. private _refreshFrustumPlanes;
  31530. private _storedFov;
  31531. private _stateStored;
  31532. /**
  31533. * Instantiates a new camera object.
  31534. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31535. * @see http://doc.babylonjs.com/features/cameras
  31536. * @param name Defines the name of the camera in the scene
  31537. * @param position Defines the position of the camera
  31538. * @param scene Defines the scene the camera belongs too
  31539. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31540. */
  31541. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31542. /**
  31543. * Store current camera state (fov, position, etc..)
  31544. * @returns the camera
  31545. */
  31546. storeState(): Camera;
  31547. /**
  31548. * Restores the camera state values if it has been stored. You must call storeState() first
  31549. */
  31550. protected _restoreStateValues(): boolean;
  31551. /**
  31552. * Restored camera state. You must call storeState() first.
  31553. * @returns true if restored and false otherwise
  31554. */
  31555. restoreState(): boolean;
  31556. /**
  31557. * Gets the class name of the camera.
  31558. * @returns the class name
  31559. */
  31560. getClassName(): string;
  31561. /** @hidden */
  31562. readonly _isCamera: boolean;
  31563. /**
  31564. * Gets a string representation of the camera useful for debug purpose.
  31565. * @param fullDetails Defines that a more verboe level of logging is required
  31566. * @returns the string representation
  31567. */
  31568. toString(fullDetails?: boolean): string;
  31569. /**
  31570. * Gets the current world space position of the camera.
  31571. */
  31572. readonly globalPosition: Vector3;
  31573. /**
  31574. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31575. * @returns the active meshe list
  31576. */
  31577. getActiveMeshes(): SmartArray<AbstractMesh>;
  31578. /**
  31579. * Check wether a mesh is part of the current active mesh list of the camera
  31580. * @param mesh Defines the mesh to check
  31581. * @returns true if active, false otherwise
  31582. */
  31583. isActiveMesh(mesh: Mesh): boolean;
  31584. /**
  31585. * Is this camera ready to be used/rendered
  31586. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31587. * @return true if the camera is ready
  31588. */
  31589. isReady(completeCheck?: boolean): boolean;
  31590. /** @hidden */
  31591. _initCache(): void;
  31592. /** @hidden */
  31593. _updateCache(ignoreParentClass?: boolean): void;
  31594. /** @hidden */
  31595. _isSynchronized(): boolean;
  31596. /** @hidden */
  31597. _isSynchronizedViewMatrix(): boolean;
  31598. /** @hidden */
  31599. _isSynchronizedProjectionMatrix(): boolean;
  31600. /**
  31601. * Attach the input controls to a specific dom element to get the input from.
  31602. * @param element Defines the element the controls should be listened from
  31603. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31604. */
  31605. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31606. /**
  31607. * Detach the current controls from the specified dom element.
  31608. * @param element Defines the element to stop listening the inputs from
  31609. */
  31610. detachControl(element: HTMLElement): void;
  31611. /**
  31612. * Update the camera state according to the different inputs gathered during the frame.
  31613. */
  31614. update(): void;
  31615. /** @hidden */
  31616. _checkInputs(): void;
  31617. /** @hidden */
  31618. readonly rigCameras: Camera[];
  31619. /**
  31620. * Gets the post process used by the rig cameras
  31621. */
  31622. readonly rigPostProcess: Nullable<PostProcess>;
  31623. /**
  31624. * Internal, gets the first post proces.
  31625. * @returns the first post process to be run on this camera.
  31626. */
  31627. _getFirstPostProcess(): Nullable<PostProcess>;
  31628. private _cascadePostProcessesToRigCams;
  31629. /**
  31630. * Attach a post process to the camera.
  31631. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31632. * @param postProcess The post process to attach to the camera
  31633. * @param insertAt The position of the post process in case several of them are in use in the scene
  31634. * @returns the position the post process has been inserted at
  31635. */
  31636. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31637. /**
  31638. * Detach a post process to the camera.
  31639. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31640. * @param postProcess The post process to detach from the camera
  31641. */
  31642. detachPostProcess(postProcess: PostProcess): void;
  31643. /**
  31644. * Gets the current world matrix of the camera
  31645. */
  31646. getWorldMatrix(): Matrix;
  31647. /** @hidden */
  31648. _getViewMatrix(): Matrix;
  31649. /**
  31650. * Gets the current view matrix of the camera.
  31651. * @param force forces the camera to recompute the matrix without looking at the cached state
  31652. * @returns the view matrix
  31653. */
  31654. getViewMatrix(force?: boolean): Matrix;
  31655. /**
  31656. * Freeze the projection matrix.
  31657. * It will prevent the cache check of the camera projection compute and can speed up perf
  31658. * if no parameter of the camera are meant to change
  31659. * @param projection Defines manually a projection if necessary
  31660. */
  31661. freezeProjectionMatrix(projection?: Matrix): void;
  31662. /**
  31663. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31664. */
  31665. unfreezeProjectionMatrix(): void;
  31666. /**
  31667. * Gets the current projection matrix of the camera.
  31668. * @param force forces the camera to recompute the matrix without looking at the cached state
  31669. * @returns the projection matrix
  31670. */
  31671. getProjectionMatrix(force?: boolean): Matrix;
  31672. /**
  31673. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31674. * @returns a Matrix
  31675. */
  31676. getTransformationMatrix(): Matrix;
  31677. private _updateFrustumPlanes;
  31678. /**
  31679. * Checks if a cullable object (mesh...) is in the camera frustum
  31680. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31681. * @param target The object to check
  31682. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  31683. * @returns true if the object is in frustum otherwise false
  31684. */
  31685. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  31686. /**
  31687. * Checks if a cullable object (mesh...) is in the camera frustum
  31688. * Unlike isInFrustum this cheks the full bounding box
  31689. * @param target The object to check
  31690. * @returns true if the object is in frustum otherwise false
  31691. */
  31692. isCompletelyInFrustum(target: ICullable): boolean;
  31693. /**
  31694. * Gets a ray in the forward direction from the camera.
  31695. * @param length Defines the length of the ray to create
  31696. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31697. * @param origin Defines the start point of the ray which defaults to the camera position
  31698. * @returns the forward ray
  31699. */
  31700. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31701. /**
  31702. * Releases resources associated with this node.
  31703. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31704. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31705. */
  31706. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31707. /** @hidden */
  31708. _isLeftCamera: boolean;
  31709. /**
  31710. * Gets the left camera of a rig setup in case of Rigged Camera
  31711. */
  31712. readonly isLeftCamera: boolean;
  31713. /** @hidden */
  31714. _isRightCamera: boolean;
  31715. /**
  31716. * Gets the right camera of a rig setup in case of Rigged Camera
  31717. */
  31718. readonly isRightCamera: boolean;
  31719. /**
  31720. * Gets the left camera of a rig setup in case of Rigged Camera
  31721. */
  31722. readonly leftCamera: Nullable<FreeCamera>;
  31723. /**
  31724. * Gets the right camera of a rig setup in case of Rigged Camera
  31725. */
  31726. readonly rightCamera: Nullable<FreeCamera>;
  31727. /**
  31728. * Gets the left camera target of a rig setup in case of Rigged Camera
  31729. * @returns the target position
  31730. */
  31731. getLeftTarget(): Nullable<Vector3>;
  31732. /**
  31733. * Gets the right camera target of a rig setup in case of Rigged Camera
  31734. * @returns the target position
  31735. */
  31736. getRightTarget(): Nullable<Vector3>;
  31737. /**
  31738. * @hidden
  31739. */
  31740. setCameraRigMode(mode: number, rigParams: any): void;
  31741. /** @hidden */
  31742. static _setStereoscopicRigMode(camera: Camera): void;
  31743. /** @hidden */
  31744. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31745. /** @hidden */
  31746. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31747. /** @hidden */
  31748. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31749. /** @hidden */
  31750. _getVRProjectionMatrix(): Matrix;
  31751. protected _updateCameraRotationMatrix(): void;
  31752. protected _updateWebVRCameraRotationMatrix(): void;
  31753. /**
  31754. * This function MUST be overwritten by the different WebVR cameras available.
  31755. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31756. * @hidden
  31757. */
  31758. _getWebVRProjectionMatrix(): Matrix;
  31759. /**
  31760. * This function MUST be overwritten by the different WebVR cameras available.
  31761. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31762. * @hidden
  31763. */
  31764. _getWebVRViewMatrix(): Matrix;
  31765. /** @hidden */
  31766. setCameraRigParameter(name: string, value: any): void;
  31767. /**
  31768. * needs to be overridden by children so sub has required properties to be copied
  31769. * @hidden
  31770. */
  31771. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31772. /**
  31773. * May need to be overridden by children
  31774. * @hidden
  31775. */
  31776. _updateRigCameras(): void;
  31777. /** @hidden */
  31778. _setupInputs(): void;
  31779. /**
  31780. * Serialiaze the camera setup to a json represention
  31781. * @returns the JSON representation
  31782. */
  31783. serialize(): any;
  31784. /**
  31785. * Clones the current camera.
  31786. * @param name The cloned camera name
  31787. * @returns the cloned camera
  31788. */
  31789. clone(name: string): Camera;
  31790. /**
  31791. * Gets the direction of the camera relative to a given local axis.
  31792. * @param localAxis Defines the reference axis to provide a relative direction.
  31793. * @return the direction
  31794. */
  31795. getDirection(localAxis: Vector3): Vector3;
  31796. /**
  31797. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31798. * @param localAxis Defines the reference axis to provide a relative direction.
  31799. * @param result Defines the vector to store the result in
  31800. */
  31801. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31802. /**
  31803. * Gets a camera constructor for a given camera type
  31804. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31805. * @param name The name of the camera the result will be able to instantiate
  31806. * @param scene The scene the result will construct the camera in
  31807. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31808. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31809. * @returns a factory method to construc the camera
  31810. */
  31811. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31812. /**
  31813. * Compute the world matrix of the camera.
  31814. * @returns the camera workd matrix
  31815. */
  31816. computeWorldMatrix(): Matrix;
  31817. /**
  31818. * Parse a JSON and creates the camera from the parsed information
  31819. * @param parsedCamera The JSON to parse
  31820. * @param scene The scene to instantiate the camera in
  31821. * @returns the newly constructed camera
  31822. */
  31823. static Parse(parsedCamera: any, scene: Scene): Camera;
  31824. }
  31825. }
  31826. declare module "babylonjs/Misc/tools" {
  31827. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31828. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31829. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31830. import { Observable } from "babylonjs/Misc/observable";
  31831. import { DomManagement } from "babylonjs/Misc/domManagement";
  31832. import { WebRequest } from "babylonjs/Misc/webRequest";
  31833. import { Camera } from "babylonjs/Cameras/camera";
  31834. import { Engine } from "babylonjs/Engines/engine";
  31835. import { Animation } from "babylonjs/Animations/animation";
  31836. /**
  31837. * Interface for any object that can request an animation frame
  31838. */
  31839. export interface ICustomAnimationFrameRequester {
  31840. /**
  31841. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31842. */
  31843. renderFunction?: Function;
  31844. /**
  31845. * Called to request the next frame to render to
  31846. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31847. */
  31848. requestAnimationFrame: Function;
  31849. /**
  31850. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31851. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31852. */
  31853. requestID?: number;
  31854. }
  31855. /**
  31856. * Interface containing an array of animations
  31857. */
  31858. export interface IAnimatable {
  31859. /**
  31860. * Array of animations
  31861. */
  31862. animations: Nullable<Array<Animation>>;
  31863. }
  31864. /** Interface used by value gradients (color, factor, ...) */
  31865. export interface IValueGradient {
  31866. /**
  31867. * Gets or sets the gradient value (between 0 and 1)
  31868. */
  31869. gradient: number;
  31870. }
  31871. /** Class used to store color4 gradient */
  31872. export class ColorGradient implements IValueGradient {
  31873. /**
  31874. * Gets or sets the gradient value (between 0 and 1)
  31875. */
  31876. gradient: number;
  31877. /**
  31878. * Gets or sets first associated color
  31879. */
  31880. color1: Color4;
  31881. /**
  31882. * Gets or sets second associated color
  31883. */
  31884. color2?: Color4;
  31885. /**
  31886. * Will get a color picked randomly between color1 and color2.
  31887. * If color2 is undefined then color1 will be used
  31888. * @param result defines the target Color4 to store the result in
  31889. */
  31890. getColorToRef(result: Color4): void;
  31891. }
  31892. /** Class used to store color 3 gradient */
  31893. export class Color3Gradient implements IValueGradient {
  31894. /**
  31895. * Gets or sets the gradient value (between 0 and 1)
  31896. */
  31897. gradient: number;
  31898. /**
  31899. * Gets or sets the associated color
  31900. */
  31901. color: Color3;
  31902. }
  31903. /** Class used to store factor gradient */
  31904. export class FactorGradient implements IValueGradient {
  31905. /**
  31906. * Gets or sets the gradient value (between 0 and 1)
  31907. */
  31908. gradient: number;
  31909. /**
  31910. * Gets or sets first associated factor
  31911. */
  31912. factor1: number;
  31913. /**
  31914. * Gets or sets second associated factor
  31915. */
  31916. factor2?: number;
  31917. /**
  31918. * Will get a number picked randomly between factor1 and factor2.
  31919. * If factor2 is undefined then factor1 will be used
  31920. * @returns the picked number
  31921. */
  31922. getFactor(): number;
  31923. }
  31924. /**
  31925. * @ignore
  31926. * Application error to support additional information when loading a file
  31927. */
  31928. export class LoadFileError extends Error {
  31929. /** defines the optional web request */
  31930. request?: WebRequest | undefined;
  31931. private static _setPrototypeOf;
  31932. /**
  31933. * Creates a new LoadFileError
  31934. * @param message defines the message of the error
  31935. * @param request defines the optional web request
  31936. */
  31937. constructor(message: string,
  31938. /** defines the optional web request */
  31939. request?: WebRequest | undefined);
  31940. }
  31941. /**
  31942. * Class used to define a retry strategy when error happens while loading assets
  31943. */
  31944. export class RetryStrategy {
  31945. /**
  31946. * Function used to defines an exponential back off strategy
  31947. * @param maxRetries defines the maximum number of retries (3 by default)
  31948. * @param baseInterval defines the interval between retries
  31949. * @returns the strategy function to use
  31950. */
  31951. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31952. }
  31953. /**
  31954. * File request interface
  31955. */
  31956. export interface IFileRequest {
  31957. /**
  31958. * Raised when the request is complete (success or error).
  31959. */
  31960. onCompleteObservable: Observable<IFileRequest>;
  31961. /**
  31962. * Aborts the request for a file.
  31963. */
  31964. abort: () => void;
  31965. }
  31966. /**
  31967. * Class containing a set of static utilities functions
  31968. */
  31969. export class Tools {
  31970. /**
  31971. * Gets or sets the base URL to use to load assets
  31972. */
  31973. static BaseUrl: string;
  31974. /**
  31975. * Enable/Disable Custom HTTP Request Headers globally.
  31976. * default = false
  31977. * @see CustomRequestHeaders
  31978. */
  31979. static UseCustomRequestHeaders: boolean;
  31980. /**
  31981. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31982. * i.e. when loading files, where the server/service expects an Authorization header
  31983. */
  31984. static CustomRequestHeaders: {
  31985. [key: string]: string;
  31986. };
  31987. /**
  31988. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31989. */
  31990. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31991. /**
  31992. * Default behaviour for cors in the application.
  31993. * It can be a string if the expected behavior is identical in the entire app.
  31994. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31995. */
  31996. static CorsBehavior: string | ((url: string | string[]) => string);
  31997. /**
  31998. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31999. * @ignorenaming
  32000. */
  32001. static UseFallbackTexture: boolean;
  32002. /**
  32003. * Use this object to register external classes like custom textures or material
  32004. * to allow the laoders to instantiate them
  32005. */
  32006. static RegisteredExternalClasses: {
  32007. [key: string]: Object;
  32008. };
  32009. /**
  32010. * Texture content used if a texture cannot loaded
  32011. * @ignorenaming
  32012. */
  32013. static fallbackTexture: string;
  32014. /**
  32015. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32016. * @param u defines the coordinate on X axis
  32017. * @param v defines the coordinate on Y axis
  32018. * @param width defines the width of the source data
  32019. * @param height defines the height of the source data
  32020. * @param pixels defines the source byte array
  32021. * @param color defines the output color
  32022. */
  32023. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  32024. /**
  32025. * Interpolates between a and b via alpha
  32026. * @param a The lower value (returned when alpha = 0)
  32027. * @param b The upper value (returned when alpha = 1)
  32028. * @param alpha The interpolation-factor
  32029. * @return The mixed value
  32030. */
  32031. static Mix(a: number, b: number, alpha: number): number;
  32032. /**
  32033. * Tries to instantiate a new object from a given class name
  32034. * @param className defines the class name to instantiate
  32035. * @returns the new object or null if the system was not able to do the instantiation
  32036. */
  32037. static Instantiate(className: string): any;
  32038. /**
  32039. * Provides a slice function that will work even on IE
  32040. * @param data defines the array to slice
  32041. * @param start defines the start of the data (optional)
  32042. * @param end defines the end of the data (optional)
  32043. * @returns the new sliced array
  32044. */
  32045. static Slice<T>(data: T, start?: number, end?: number): T;
  32046. /**
  32047. * Polyfill for setImmediate
  32048. * @param action defines the action to execute after the current execution block
  32049. */
  32050. static SetImmediate(action: () => void): void;
  32051. /**
  32052. * Function indicating if a number is an exponent of 2
  32053. * @param value defines the value to test
  32054. * @returns true if the value is an exponent of 2
  32055. */
  32056. static IsExponentOfTwo(value: number): boolean;
  32057. private static _tmpFloatArray;
  32058. /**
  32059. * Returns the nearest 32-bit single precision float representation of a Number
  32060. * @param value A Number. If the parameter is of a different type, it will get converted
  32061. * to a number or to NaN if it cannot be converted
  32062. * @returns number
  32063. */
  32064. static FloatRound(value: number): number;
  32065. /**
  32066. * Find the next highest power of two.
  32067. * @param x Number to start search from.
  32068. * @return Next highest power of two.
  32069. */
  32070. static CeilingPOT(x: number): number;
  32071. /**
  32072. * Find the next lowest power of two.
  32073. * @param x Number to start search from.
  32074. * @return Next lowest power of two.
  32075. */
  32076. static FloorPOT(x: number): number;
  32077. /**
  32078. * Find the nearest power of two.
  32079. * @param x Number to start search from.
  32080. * @return Next nearest power of two.
  32081. */
  32082. static NearestPOT(x: number): number;
  32083. /**
  32084. * Get the closest exponent of two
  32085. * @param value defines the value to approximate
  32086. * @param max defines the maximum value to return
  32087. * @param mode defines how to define the closest value
  32088. * @returns closest exponent of two of the given value
  32089. */
  32090. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32091. /**
  32092. * Extracts the filename from a path
  32093. * @param path defines the path to use
  32094. * @returns the filename
  32095. */
  32096. static GetFilename(path: string): string;
  32097. /**
  32098. * Extracts the "folder" part of a path (everything before the filename).
  32099. * @param uri The URI to extract the info from
  32100. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32101. * @returns The "folder" part of the path
  32102. */
  32103. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32104. /**
  32105. * Extracts text content from a DOM element hierarchy
  32106. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32107. */
  32108. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32109. /**
  32110. * Convert an angle in radians to degrees
  32111. * @param angle defines the angle to convert
  32112. * @returns the angle in degrees
  32113. */
  32114. static ToDegrees(angle: number): number;
  32115. /**
  32116. * Convert an angle in degrees to radians
  32117. * @param angle defines the angle to convert
  32118. * @returns the angle in radians
  32119. */
  32120. static ToRadians(angle: number): number;
  32121. /**
  32122. * Encode a buffer to a base64 string
  32123. * @param buffer defines the buffer to encode
  32124. * @returns the encoded string
  32125. */
  32126. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32127. /**
  32128. * Extracts minimum and maximum values from a list of indexed positions
  32129. * @param positions defines the positions to use
  32130. * @param indices defines the indices to the positions
  32131. * @param indexStart defines the start index
  32132. * @param indexCount defines the end index
  32133. * @param bias defines bias value to add to the result
  32134. * @return minimum and maximum values
  32135. */
  32136. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  32137. minimum: Vector3;
  32138. maximum: Vector3;
  32139. };
  32140. /**
  32141. * Extracts minimum and maximum values from a list of positions
  32142. * @param positions defines the positions to use
  32143. * @param start defines the start index in the positions array
  32144. * @param count defines the number of positions to handle
  32145. * @param bias defines bias value to add to the result
  32146. * @param stride defines the stride size to use (distance between two positions in the positions array)
  32147. * @return minimum and maximum values
  32148. */
  32149. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  32150. minimum: Vector3;
  32151. maximum: Vector3;
  32152. };
  32153. /**
  32154. * Returns an array if obj is not an array
  32155. * @param obj defines the object to evaluate as an array
  32156. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32157. * @returns either obj directly if obj is an array or a new array containing obj
  32158. */
  32159. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32160. /**
  32161. * Gets the pointer prefix to use
  32162. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32163. */
  32164. static GetPointerPrefix(): string;
  32165. /**
  32166. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32167. * @param func - the function to be called
  32168. * @param requester - the object that will request the next frame. Falls back to window.
  32169. * @returns frame number
  32170. */
  32171. static QueueNewFrame(func: () => void, requester?: any): number;
  32172. /**
  32173. * Ask the browser to promote the current element to fullscreen rendering mode
  32174. * @param element defines the DOM element to promote
  32175. */
  32176. static RequestFullscreen(element: HTMLElement): void;
  32177. /**
  32178. * Asks the browser to exit fullscreen mode
  32179. */
  32180. static ExitFullscreen(): void;
  32181. /**
  32182. * Ask the browser to promote the current element to pointerlock mode
  32183. * @param element defines the DOM element to promote
  32184. */
  32185. static RequestPointerlock(element: HTMLElement): void;
  32186. /**
  32187. * Asks the browser to exit pointerlock mode
  32188. */
  32189. static ExitPointerlock(): void;
  32190. /**
  32191. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32192. * @param url define the url we are trying
  32193. * @param element define the dom element where to configure the cors policy
  32194. */
  32195. static SetCorsBehavior(url: string | string[], element: {
  32196. crossOrigin: string | null;
  32197. }): void;
  32198. /**
  32199. * Removes unwanted characters from an url
  32200. * @param url defines the url to clean
  32201. * @returns the cleaned url
  32202. */
  32203. static CleanUrl(url: string): string;
  32204. /**
  32205. * Gets or sets a function used to pre-process url before using them to load assets
  32206. */
  32207. static PreprocessUrl: (url: string) => string;
  32208. /**
  32209. * Loads an image as an HTMLImageElement.
  32210. * @param input url string, ArrayBuffer, or Blob to load
  32211. * @param onLoad callback called when the image successfully loads
  32212. * @param onError callback called when the image fails to load
  32213. * @param offlineProvider offline provider for caching
  32214. * @returns the HTMLImageElement of the loaded image
  32215. */
  32216. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32217. /**
  32218. * Loads a file
  32219. * @param url url string, ArrayBuffer, or Blob to load
  32220. * @param onSuccess callback called when the file successfully loads
  32221. * @param onProgress callback called while file is loading (if the server supports this mode)
  32222. * @param offlineProvider defines the offline provider for caching
  32223. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32224. * @param onError callback called when the file fails to load
  32225. * @returns a file request object
  32226. */
  32227. 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;
  32228. /**
  32229. * Loads a file from a url
  32230. * @param url the file url to load
  32231. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32232. */
  32233. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32234. /**
  32235. * Load a script (identified by an url). When the url returns, the
  32236. * content of this file is added into a new script element, attached to the DOM (body element)
  32237. * @param scriptUrl defines the url of the script to laod
  32238. * @param onSuccess defines the callback called when the script is loaded
  32239. * @param onError defines the callback to call if an error occurs
  32240. * @param scriptId defines the id of the script element
  32241. */
  32242. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32243. /**
  32244. * Load an asynchronous script (identified by an url). When the url returns, the
  32245. * content of this file is added into a new script element, attached to the DOM (body element)
  32246. * @param scriptUrl defines the url of the script to laod
  32247. * @param scriptId defines the id of the script element
  32248. * @returns a promise request object
  32249. */
  32250. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32251. /**
  32252. * Loads a file from a blob
  32253. * @param fileToLoad defines the blob to use
  32254. * @param callback defines the callback to call when data is loaded
  32255. * @param progressCallback defines the callback to call during loading process
  32256. * @returns a file request object
  32257. */
  32258. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32259. /**
  32260. * Loads a file
  32261. * @param fileToLoad defines the file to load
  32262. * @param callback defines the callback to call when data is loaded
  32263. * @param progressCallBack defines the callback to call during loading process
  32264. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32265. * @returns a file request object
  32266. */
  32267. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32268. /**
  32269. * Creates a data url from a given string content
  32270. * @param content defines the content to convert
  32271. * @returns the new data url link
  32272. */
  32273. static FileAsURL(content: string): string;
  32274. /**
  32275. * Format the given number to a specific decimal format
  32276. * @param value defines the number to format
  32277. * @param decimals defines the number of decimals to use
  32278. * @returns the formatted string
  32279. */
  32280. static Format(value: number, decimals?: number): string;
  32281. /**
  32282. * Checks if a given vector is inside a specific range
  32283. * @param v defines the vector to test
  32284. * @param min defines the minimum range
  32285. * @param max defines the maximum range
  32286. */
  32287. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  32288. /**
  32289. * Tries to copy an object by duplicating every property
  32290. * @param source defines the source object
  32291. * @param destination defines the target object
  32292. * @param doNotCopyList defines a list of properties to avoid
  32293. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32294. */
  32295. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32296. /**
  32297. * Gets a boolean indicating if the given object has no own property
  32298. * @param obj defines the object to test
  32299. * @returns true if object has no own property
  32300. */
  32301. static IsEmpty(obj: any): boolean;
  32302. /**
  32303. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  32304. * @param str Source string
  32305. * @param suffix Suffix to search for in the source string
  32306. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  32307. */
  32308. static EndsWith(str: string, suffix: string): boolean;
  32309. /**
  32310. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  32311. * @param str Source string
  32312. * @param suffix Suffix to search for in the source string
  32313. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  32314. */
  32315. static StartsWith(str: string, suffix: string): boolean;
  32316. /**
  32317. * Function used to register events at window level
  32318. * @param events defines the events to register
  32319. */
  32320. static RegisterTopRootEvents(events: {
  32321. name: string;
  32322. handler: Nullable<(e: FocusEvent) => any>;
  32323. }[]): void;
  32324. /**
  32325. * Function used to unregister events from window level
  32326. * @param events defines the events to unregister
  32327. */
  32328. static UnregisterTopRootEvents(events: {
  32329. name: string;
  32330. handler: Nullable<(e: FocusEvent) => any>;
  32331. }[]): void;
  32332. /**
  32333. * @ignore
  32334. */
  32335. static _ScreenshotCanvas: HTMLCanvasElement;
  32336. /**
  32337. * Dumps the current bound framebuffer
  32338. * @param width defines the rendering width
  32339. * @param height defines the rendering height
  32340. * @param engine defines the hosting engine
  32341. * @param successCallback defines the callback triggered once the data are available
  32342. * @param mimeType defines the mime type of the result
  32343. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32344. */
  32345. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32346. /**
  32347. * Converts the canvas data to blob.
  32348. * This acts as a polyfill for browsers not supporting the to blob function.
  32349. * @param canvas Defines the canvas to extract the data from
  32350. * @param successCallback Defines the callback triggered once the data are available
  32351. * @param mimeType Defines the mime type of the result
  32352. */
  32353. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32354. /**
  32355. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32356. * @param successCallback defines the callback triggered once the data are available
  32357. * @param mimeType defines the mime type of the result
  32358. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32359. */
  32360. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32361. /**
  32362. * Downloads a blob in the browser
  32363. * @param blob defines the blob to download
  32364. * @param fileName defines the name of the downloaded file
  32365. */
  32366. static Download(blob: Blob, fileName: string): void;
  32367. /**
  32368. * Captures a screenshot of the current rendering
  32369. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32370. * @param engine defines the rendering engine
  32371. * @param camera defines the source camera
  32372. * @param size This parameter can be set to a single number or to an object with the
  32373. * following (optional) properties: precision, width, height. If a single number is passed,
  32374. * it will be used for both width and height. If an object is passed, the screenshot size
  32375. * will be derived from the parameters. The precision property is a multiplier allowing
  32376. * rendering at a higher or lower resolution
  32377. * @param successCallback defines the callback receives a single parameter which contains the
  32378. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32379. * src parameter of an <img> to display it
  32380. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32381. * Check your browser for supported MIME types
  32382. */
  32383. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32384. /**
  32385. * Generates an image screenshot from the specified camera.
  32386. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32387. * @param engine The engine to use for rendering
  32388. * @param camera The camera to use for rendering
  32389. * @param size This parameter can be set to a single number or to an object with the
  32390. * following (optional) properties: precision, width, height. If a single number is passed,
  32391. * it will be used for both width and height. If an object is passed, the screenshot size
  32392. * will be derived from the parameters. The precision property is a multiplier allowing
  32393. * rendering at a higher or lower resolution
  32394. * @param successCallback The callback receives a single parameter which contains the
  32395. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32396. * src parameter of an <img> to display it
  32397. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32398. * Check your browser for supported MIME types
  32399. * @param samples Texture samples (default: 1)
  32400. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32401. * @param fileName A name for for the downloaded file.
  32402. */
  32403. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32404. /**
  32405. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32406. * Be aware Math.random() could cause collisions, but:
  32407. * "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"
  32408. * @returns a pseudo random id
  32409. */
  32410. static RandomId(): string;
  32411. /**
  32412. * Test if the given uri is a base64 string
  32413. * @param uri The uri to test
  32414. * @return True if the uri is a base64 string or false otherwise
  32415. */
  32416. static IsBase64(uri: string): boolean;
  32417. /**
  32418. * Decode the given base64 uri.
  32419. * @param uri The uri to decode
  32420. * @return The decoded base64 data.
  32421. */
  32422. static DecodeBase64(uri: string): ArrayBuffer;
  32423. /**
  32424. * Gets the absolute url.
  32425. * @param url the input url
  32426. * @return the absolute url
  32427. */
  32428. static GetAbsoluteUrl(url: string): string;
  32429. /**
  32430. * No log
  32431. */
  32432. static readonly NoneLogLevel: number;
  32433. /**
  32434. * Only message logs
  32435. */
  32436. static readonly MessageLogLevel: number;
  32437. /**
  32438. * Only warning logs
  32439. */
  32440. static readonly WarningLogLevel: number;
  32441. /**
  32442. * Only error logs
  32443. */
  32444. static readonly ErrorLogLevel: number;
  32445. /**
  32446. * All logs
  32447. */
  32448. static readonly AllLogLevel: number;
  32449. /**
  32450. * Gets a value indicating the number of loading errors
  32451. * @ignorenaming
  32452. */
  32453. static readonly errorsCount: number;
  32454. /**
  32455. * Callback called when a new log is added
  32456. */
  32457. static OnNewCacheEntry: (entry: string) => void;
  32458. /**
  32459. * Log a message to the console
  32460. * @param message defines the message to log
  32461. */
  32462. static Log(message: string): void;
  32463. /**
  32464. * Write a warning message to the console
  32465. * @param message defines the message to log
  32466. */
  32467. static Warn(message: string): void;
  32468. /**
  32469. * Write an error message to the console
  32470. * @param message defines the message to log
  32471. */
  32472. static Error(message: string): void;
  32473. /**
  32474. * Gets current log cache (list of logs)
  32475. */
  32476. static readonly LogCache: string;
  32477. /**
  32478. * Clears the log cache
  32479. */
  32480. static ClearLogCache(): void;
  32481. /**
  32482. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32483. */
  32484. static LogLevels: number;
  32485. /**
  32486. * Checks if the loaded document was accessed via `file:`-Protocol.
  32487. * @returns boolean
  32488. */
  32489. static IsFileURL(): boolean;
  32490. /**
  32491. * Checks if the window object exists
  32492. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32493. */
  32494. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32495. /**
  32496. * No performance log
  32497. */
  32498. static readonly PerformanceNoneLogLevel: number;
  32499. /**
  32500. * Use user marks to log performance
  32501. */
  32502. static readonly PerformanceUserMarkLogLevel: number;
  32503. /**
  32504. * Log performance to the console
  32505. */
  32506. static readonly PerformanceConsoleLogLevel: number;
  32507. private static _performance;
  32508. /**
  32509. * Sets the current performance log level
  32510. */
  32511. static PerformanceLogLevel: number;
  32512. private static _StartPerformanceCounterDisabled;
  32513. private static _EndPerformanceCounterDisabled;
  32514. private static _StartUserMark;
  32515. private static _EndUserMark;
  32516. private static _StartPerformanceConsole;
  32517. private static _EndPerformanceConsole;
  32518. /**
  32519. * Starts a performance counter
  32520. */
  32521. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32522. /**
  32523. * Ends a specific performance coutner
  32524. */
  32525. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32526. /**
  32527. * Gets either window.performance.now() if supported or Date.now() else
  32528. */
  32529. static readonly Now: number;
  32530. /**
  32531. * This method will return the name of the class used to create the instance of the given object.
  32532. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32533. * @param object the object to get the class name from
  32534. * @param isType defines if the object is actually a type
  32535. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32536. */
  32537. static GetClassName(object: any, isType?: boolean): string;
  32538. /**
  32539. * Gets the first element of an array satisfying a given predicate
  32540. * @param array defines the array to browse
  32541. * @param predicate defines the predicate to use
  32542. * @returns null if not found or the element
  32543. */
  32544. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32545. /**
  32546. * This method will return the name of the full name of the class, including its owning module (if any).
  32547. * 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).
  32548. * @param object the object to get the class name from
  32549. * @param isType defines if the object is actually a type
  32550. * @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.
  32551. * @ignorenaming
  32552. */
  32553. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32554. /**
  32555. * Returns a promise that resolves after the given amount of time.
  32556. * @param delay Number of milliseconds to delay
  32557. * @returns Promise that resolves after the given amount of time
  32558. */
  32559. static DelayAsync(delay: number): Promise<void>;
  32560. /**
  32561. * Gets the current gradient from an array of IValueGradient
  32562. * @param ratio defines the current ratio to get
  32563. * @param gradients defines the array of IValueGradient
  32564. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32565. */
  32566. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32567. }
  32568. /**
  32569. * This class is used to track a performance counter which is number based.
  32570. * The user has access to many properties which give statistics of different nature.
  32571. *
  32572. * The implementer can track two kinds of Performance Counter: time and count.
  32573. * 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.
  32574. * 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.
  32575. */
  32576. export class PerfCounter {
  32577. /**
  32578. * Gets or sets a global boolean to turn on and off all the counters
  32579. */
  32580. static Enabled: boolean;
  32581. /**
  32582. * Returns the smallest value ever
  32583. */
  32584. readonly min: number;
  32585. /**
  32586. * Returns the biggest value ever
  32587. */
  32588. readonly max: number;
  32589. /**
  32590. * Returns the average value since the performance counter is running
  32591. */
  32592. readonly average: number;
  32593. /**
  32594. * Returns the average value of the last second the counter was monitored
  32595. */
  32596. readonly lastSecAverage: number;
  32597. /**
  32598. * Returns the current value
  32599. */
  32600. readonly current: number;
  32601. /**
  32602. * Gets the accumulated total
  32603. */
  32604. readonly total: number;
  32605. /**
  32606. * Gets the total value count
  32607. */
  32608. readonly count: number;
  32609. /**
  32610. * Creates a new counter
  32611. */
  32612. constructor();
  32613. /**
  32614. * Call this method to start monitoring a new frame.
  32615. * 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.
  32616. */
  32617. fetchNewFrame(): void;
  32618. /**
  32619. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32620. * @param newCount the count value to add to the monitored count
  32621. * @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.
  32622. */
  32623. addCount(newCount: number, fetchResult: boolean): void;
  32624. /**
  32625. * Start monitoring this performance counter
  32626. */
  32627. beginMonitoring(): void;
  32628. /**
  32629. * Compute the time lapsed since the previous beginMonitoring() call.
  32630. * @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
  32631. */
  32632. endMonitoring(newFrame?: boolean): void;
  32633. private _fetchResult;
  32634. private _startMonitoringTime;
  32635. private _min;
  32636. private _max;
  32637. private _average;
  32638. private _current;
  32639. private _totalValueCount;
  32640. private _totalAccumulated;
  32641. private _lastSecAverage;
  32642. private _lastSecAccumulated;
  32643. private _lastSecTime;
  32644. private _lastSecValueCount;
  32645. }
  32646. /**
  32647. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32648. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32649. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32650. * @param name The name of the class, case should be preserved
  32651. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32652. */
  32653. export function className(name: string, module?: string): (target: Object) => void;
  32654. /**
  32655. * An implementation of a loop for asynchronous functions.
  32656. */
  32657. export class AsyncLoop {
  32658. /**
  32659. * Defines the number of iterations for the loop
  32660. */
  32661. iterations: number;
  32662. /**
  32663. * Defines the current index of the loop.
  32664. */
  32665. index: number;
  32666. private _done;
  32667. private _fn;
  32668. private _successCallback;
  32669. /**
  32670. * Constructor.
  32671. * @param iterations the number of iterations.
  32672. * @param func the function to run each iteration
  32673. * @param successCallback the callback that will be called upon succesful execution
  32674. * @param offset starting offset.
  32675. */
  32676. constructor(
  32677. /**
  32678. * Defines the number of iterations for the loop
  32679. */
  32680. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32681. /**
  32682. * Execute the next iteration. Must be called after the last iteration was finished.
  32683. */
  32684. executeNext(): void;
  32685. /**
  32686. * Break the loop and run the success callback.
  32687. */
  32688. breakLoop(): void;
  32689. /**
  32690. * Create and run an async loop.
  32691. * @param iterations the number of iterations.
  32692. * @param fn the function to run each iteration
  32693. * @param successCallback the callback that will be called upon succesful execution
  32694. * @param offset starting offset.
  32695. * @returns the created async loop object
  32696. */
  32697. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32698. /**
  32699. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32700. * @param iterations total number of iterations
  32701. * @param syncedIterations number of synchronous iterations in each async iteration.
  32702. * @param fn the function to call each iteration.
  32703. * @param callback a success call back that will be called when iterating stops.
  32704. * @param breakFunction a break condition (optional)
  32705. * @param timeout timeout settings for the setTimeout function. default - 0.
  32706. * @returns the created async loop object
  32707. */
  32708. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32709. }
  32710. }
  32711. declare module "babylonjs/Collisions/collisionCoordinator" {
  32712. import { Nullable } from "babylonjs/types";
  32713. import { Scene } from "babylonjs/scene";
  32714. import { Vector3 } from "babylonjs/Maths/math";
  32715. import { Collider } from "babylonjs/Collisions/collider";
  32716. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32717. /** @hidden */
  32718. export interface ICollisionCoordinator {
  32719. createCollider(): Collider;
  32720. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32721. init(scene: Scene): void;
  32722. }
  32723. /** @hidden */
  32724. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32725. private _scene;
  32726. private _scaledPosition;
  32727. private _scaledVelocity;
  32728. private _finalPosition;
  32729. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32730. createCollider(): Collider;
  32731. init(scene: Scene): void;
  32732. private _collideWithWorld;
  32733. }
  32734. }
  32735. declare module "babylonjs/Inputs/scene.inputManager" {
  32736. import { Nullable } from "babylonjs/types";
  32737. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32738. import { Vector2 } from "babylonjs/Maths/math";
  32739. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32740. import { Scene } from "babylonjs/scene";
  32741. /**
  32742. * Class used to manage all inputs for the scene.
  32743. */
  32744. export class InputManager {
  32745. /** The distance in pixel that you have to move to prevent some events */
  32746. static DragMovementThreshold: number;
  32747. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32748. static LongPressDelay: number;
  32749. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32750. static DoubleClickDelay: number;
  32751. /** If you need to check double click without raising a single click at first click, enable this flag */
  32752. static ExclusiveDoubleClickMode: boolean;
  32753. private _wheelEventName;
  32754. private _onPointerMove;
  32755. private _onPointerDown;
  32756. private _onPointerUp;
  32757. private _initClickEvent;
  32758. private _initActionManager;
  32759. private _delayedSimpleClick;
  32760. private _delayedSimpleClickTimeout;
  32761. private _previousDelayedSimpleClickTimeout;
  32762. private _meshPickProceed;
  32763. private _previousButtonPressed;
  32764. private _currentPickResult;
  32765. private _previousPickResult;
  32766. private _totalPointersPressed;
  32767. private _doubleClickOccured;
  32768. private _pointerOverMesh;
  32769. private _pickedDownMesh;
  32770. private _pickedUpMesh;
  32771. private _pointerX;
  32772. private _pointerY;
  32773. private _unTranslatedPointerX;
  32774. private _unTranslatedPointerY;
  32775. private _startingPointerPosition;
  32776. private _previousStartingPointerPosition;
  32777. private _startingPointerTime;
  32778. private _previousStartingPointerTime;
  32779. private _pointerCaptures;
  32780. private _onKeyDown;
  32781. private _onKeyUp;
  32782. private _onCanvasFocusObserver;
  32783. private _onCanvasBlurObserver;
  32784. private _scene;
  32785. /**
  32786. * Creates a new InputManager
  32787. * @param scene defines the hosting scene
  32788. */
  32789. constructor(scene: Scene);
  32790. /**
  32791. * Gets the mesh that is currently under the pointer
  32792. */
  32793. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32794. /**
  32795. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32796. */
  32797. readonly unTranslatedPointer: Vector2;
  32798. /**
  32799. * Gets or sets the current on-screen X position of the pointer
  32800. */
  32801. pointerX: number;
  32802. /**
  32803. * Gets or sets the current on-screen Y position of the pointer
  32804. */
  32805. pointerY: number;
  32806. private _updatePointerPosition;
  32807. private _processPointerMove;
  32808. private _setRayOnPointerInfo;
  32809. private _checkPrePointerObservable;
  32810. /**
  32811. * Use this method to simulate a pointer move on a mesh
  32812. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32813. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32814. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32815. */
  32816. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32817. /**
  32818. * Use this method to simulate a pointer down on a mesh
  32819. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32820. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32821. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32822. */
  32823. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32824. private _processPointerDown;
  32825. /** @hidden */
  32826. _isPointerSwiping(): boolean;
  32827. /**
  32828. * Use this method to simulate a pointer up on a mesh
  32829. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32830. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32831. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32832. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32833. */
  32834. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32835. private _processPointerUp;
  32836. /**
  32837. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32838. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32839. * @returns true if the pointer was captured
  32840. */
  32841. isPointerCaptured(pointerId?: number): boolean;
  32842. /**
  32843. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32844. * @param attachUp defines if you want to attach events to pointerup
  32845. * @param attachDown defines if you want to attach events to pointerdown
  32846. * @param attachMove defines if you want to attach events to pointermove
  32847. */
  32848. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32849. /**
  32850. * Detaches all event handlers
  32851. */
  32852. detachControl(): void;
  32853. /**
  32854. * Force the value of meshUnderPointer
  32855. * @param mesh defines the mesh to use
  32856. */
  32857. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32858. /**
  32859. * Gets the mesh under the pointer
  32860. * @returns a Mesh or null if no mesh is under the pointer
  32861. */
  32862. getPointerOverMesh(): Nullable<AbstractMesh>;
  32863. }
  32864. }
  32865. declare module "babylonjs/Animations/animationGroup" {
  32866. import { Animatable } from "babylonjs/Animations/animatable";
  32867. import { Animation } from "babylonjs/Animations/animation";
  32868. import { Scene, IDisposable } from "babylonjs/scene";
  32869. import { Observable } from "babylonjs/Misc/observable";
  32870. import { Nullable } from "babylonjs/types";
  32871. import "babylonjs/Animations/animatable";
  32872. /**
  32873. * This class defines the direct association between an animation and a target
  32874. */
  32875. export class TargetedAnimation {
  32876. /**
  32877. * Animation to perform
  32878. */
  32879. animation: Animation;
  32880. /**
  32881. * Target to animate
  32882. */
  32883. target: any;
  32884. /**
  32885. * Serialize the object
  32886. * @returns the JSON object representing the current entity
  32887. */
  32888. serialize(): any;
  32889. }
  32890. /**
  32891. * Use this class to create coordinated animations on multiple targets
  32892. */
  32893. export class AnimationGroup implements IDisposable {
  32894. /** The name of the animation group */
  32895. name: string;
  32896. private _scene;
  32897. private _targetedAnimations;
  32898. private _animatables;
  32899. private _from;
  32900. private _to;
  32901. private _isStarted;
  32902. private _isPaused;
  32903. private _speedRatio;
  32904. private _loopAnimation;
  32905. /**
  32906. * Gets or sets the unique id of the node
  32907. */
  32908. uniqueId: number;
  32909. /**
  32910. * This observable will notify when one animation have ended
  32911. */
  32912. onAnimationEndObservable: Observable<TargetedAnimation>;
  32913. /**
  32914. * Observer raised when one animation loops
  32915. */
  32916. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32917. /**
  32918. * This observable will notify when all animations have ended.
  32919. */
  32920. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32921. /**
  32922. * This observable will notify when all animations have paused.
  32923. */
  32924. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32925. /**
  32926. * This observable will notify when all animations are playing.
  32927. */
  32928. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32929. /**
  32930. * Gets the first frame
  32931. */
  32932. readonly from: number;
  32933. /**
  32934. * Gets the last frame
  32935. */
  32936. readonly to: number;
  32937. /**
  32938. * Define if the animations are started
  32939. */
  32940. readonly isStarted: boolean;
  32941. /**
  32942. * Gets a value indicating that the current group is playing
  32943. */
  32944. readonly isPlaying: boolean;
  32945. /**
  32946. * Gets or sets the speed ratio to use for all animations
  32947. */
  32948. /**
  32949. * Gets or sets the speed ratio to use for all animations
  32950. */
  32951. speedRatio: number;
  32952. /**
  32953. * Gets or sets if all animations should loop or not
  32954. */
  32955. loopAnimation: boolean;
  32956. /**
  32957. * Gets the targeted animations for this animation group
  32958. */
  32959. readonly targetedAnimations: Array<TargetedAnimation>;
  32960. /**
  32961. * returning the list of animatables controlled by this animation group.
  32962. */
  32963. readonly animatables: Array<Animatable>;
  32964. /**
  32965. * Instantiates a new Animation Group.
  32966. * This helps managing several animations at once.
  32967. * @see http://doc.babylonjs.com/how_to/group
  32968. * @param name Defines the name of the group
  32969. * @param scene Defines the scene the group belongs to
  32970. */
  32971. constructor(
  32972. /** The name of the animation group */
  32973. name: string, scene?: Nullable<Scene>);
  32974. /**
  32975. * Add an animation (with its target) in the group
  32976. * @param animation defines the animation we want to add
  32977. * @param target defines the target of the animation
  32978. * @returns the TargetedAnimation object
  32979. */
  32980. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32981. /**
  32982. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32983. * It can add constant keys at begin or end
  32984. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32985. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32986. * @returns the animation group
  32987. */
  32988. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32989. /**
  32990. * Start all animations on given targets
  32991. * @param loop defines if animations must loop
  32992. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32993. * @param from defines the from key (optional)
  32994. * @param to defines the to key (optional)
  32995. * @returns the current animation group
  32996. */
  32997. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32998. /**
  32999. * Pause all animations
  33000. * @returns the animation group
  33001. */
  33002. pause(): AnimationGroup;
  33003. /**
  33004. * Play all animations to initial state
  33005. * This function will start() the animations if they were not started or will restart() them if they were paused
  33006. * @param loop defines if animations must loop
  33007. * @returns the animation group
  33008. */
  33009. play(loop?: boolean): AnimationGroup;
  33010. /**
  33011. * Reset all animations to initial state
  33012. * @returns the animation group
  33013. */
  33014. reset(): AnimationGroup;
  33015. /**
  33016. * Restart animations from key 0
  33017. * @returns the animation group
  33018. */
  33019. restart(): AnimationGroup;
  33020. /**
  33021. * Stop all animations
  33022. * @returns the animation group
  33023. */
  33024. stop(): AnimationGroup;
  33025. /**
  33026. * Set animation weight for all animatables
  33027. * @param weight defines the weight to use
  33028. * @return the animationGroup
  33029. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33030. */
  33031. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33032. /**
  33033. * Synchronize and normalize all animatables with a source animatable
  33034. * @param root defines the root animatable to synchronize with
  33035. * @return the animationGroup
  33036. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33037. */
  33038. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33039. /**
  33040. * Goes to a specific frame in this animation group
  33041. * @param frame the frame number to go to
  33042. * @return the animationGroup
  33043. */
  33044. goToFrame(frame: number): AnimationGroup;
  33045. /**
  33046. * Dispose all associated resources
  33047. */
  33048. dispose(): void;
  33049. private _checkAnimationGroupEnded;
  33050. /**
  33051. * Clone the current animation group and returns a copy
  33052. * @param newName defines the name of the new group
  33053. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33054. * @returns the new aniamtion group
  33055. */
  33056. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33057. /**
  33058. * Serializes the animationGroup to an object
  33059. * @returns Serialized object
  33060. */
  33061. serialize(): any;
  33062. /**
  33063. * Returns a new AnimationGroup object parsed from the source provided.
  33064. * @param parsedAnimationGroup defines the source
  33065. * @param scene defines the scene that will receive the animationGroup
  33066. * @returns a new AnimationGroup
  33067. */
  33068. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33069. /**
  33070. * Returns the string "AnimationGroup"
  33071. * @returns "AnimationGroup"
  33072. */
  33073. getClassName(): string;
  33074. /**
  33075. * Creates a detailled string about the object
  33076. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33077. * @returns a string representing the object
  33078. */
  33079. toString(fullDetails?: boolean): string;
  33080. }
  33081. }
  33082. declare module "babylonjs/scene" {
  33083. import { Nullable } from "babylonjs/types";
  33084. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  33085. import { Observable } from "babylonjs/Misc/observable";
  33086. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33087. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  33088. import { Geometry } from "babylonjs/Meshes/geometry";
  33089. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33090. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33091. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33092. import { Mesh } from "babylonjs/Meshes/mesh";
  33093. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33094. import { Bone } from "babylonjs/Bones/bone";
  33095. import { Skeleton } from "babylonjs/Bones/skeleton";
  33096. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33097. import { Camera } from "babylonjs/Cameras/camera";
  33098. import { AbstractScene } from "babylonjs/abstractScene";
  33099. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33100. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33101. import { Material } from "babylonjs/Materials/material";
  33102. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33103. import { Effect } from "babylonjs/Materials/effect";
  33104. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33105. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33106. import { Light } from "babylonjs/Lights/light";
  33107. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33108. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33109. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33110. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33111. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33112. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33113. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33114. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33115. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33116. import { Engine } from "babylonjs/Engines/engine";
  33117. import { Node } from "babylonjs/node";
  33118. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33119. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33120. import { WebRequest } from "babylonjs/Misc/webRequest";
  33121. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33122. import { Ray } from "babylonjs/Culling/ray";
  33123. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33124. import { Animation } from "babylonjs/Animations/animation";
  33125. import { Animatable } from "babylonjs/Animations/animatable";
  33126. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33127. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33128. import { Collider } from "babylonjs/Collisions/collider";
  33129. /**
  33130. * Define an interface for all classes that will hold resources
  33131. */
  33132. export interface IDisposable {
  33133. /**
  33134. * Releases all held resources
  33135. */
  33136. dispose(): void;
  33137. }
  33138. /** Interface defining initialization parameters for Scene class */
  33139. export interface SceneOptions {
  33140. /**
  33141. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33142. * It will improve performance when the number of geometries becomes important.
  33143. */
  33144. useGeometryUniqueIdsMap?: boolean;
  33145. /**
  33146. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33147. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33148. */
  33149. useMaterialMeshMap?: boolean;
  33150. /**
  33151. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33152. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33153. */
  33154. useClonedMeshhMap?: boolean;
  33155. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33156. virtual?: boolean;
  33157. }
  33158. /**
  33159. * Represents a scene to be rendered by the engine.
  33160. * @see http://doc.babylonjs.com/features/scene
  33161. */
  33162. export class Scene extends AbstractScene implements IAnimatable {
  33163. private static _uniqueIdCounter;
  33164. /** The fog is deactivated */
  33165. static readonly FOGMODE_NONE: number;
  33166. /** The fog density is following an exponential function */
  33167. static readonly FOGMODE_EXP: number;
  33168. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33169. static readonly FOGMODE_EXP2: number;
  33170. /** The fog density is following a linear function. */
  33171. static readonly FOGMODE_LINEAR: number;
  33172. /**
  33173. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33174. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33175. */
  33176. static MinDeltaTime: number;
  33177. /**
  33178. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33179. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33180. */
  33181. static MaxDeltaTime: number;
  33182. /**
  33183. * Factory used to create the default material.
  33184. * @param name The name of the material to create
  33185. * @param scene The scene to create the material for
  33186. * @returns The default material
  33187. */
  33188. static DefaultMaterialFactory(scene: Scene): Material;
  33189. /**
  33190. * Factory used to create the a collision coordinator.
  33191. * @returns The collision coordinator
  33192. */
  33193. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33194. /** @hidden */
  33195. _inputManager: InputManager;
  33196. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33197. cameraToUseForPointers: Nullable<Camera>;
  33198. /** @hidden */
  33199. readonly _isScene: boolean;
  33200. /**
  33201. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33202. */
  33203. autoClear: boolean;
  33204. /**
  33205. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33206. */
  33207. autoClearDepthAndStencil: boolean;
  33208. /**
  33209. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33210. */
  33211. clearColor: Color4;
  33212. /**
  33213. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33214. */
  33215. ambientColor: Color3;
  33216. /**
  33217. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33218. * It should only be one of the following (if not the default embedded one):
  33219. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33220. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33221. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33222. * The material properties need to be setup according to the type of texture in use.
  33223. */
  33224. environmentBRDFTexture: BaseTexture;
  33225. /** @hidden */
  33226. protected _environmentTexture: Nullable<BaseTexture>;
  33227. /**
  33228. * Texture used in all pbr material as the reflection texture.
  33229. * As in the majority of the scene they are the same (exception for multi room and so on),
  33230. * this is easier to reference from here than from all the materials.
  33231. */
  33232. /**
  33233. * Texture used in all pbr material as the reflection texture.
  33234. * As in the majority of the scene they are the same (exception for multi room and so on),
  33235. * this is easier to set here than in all the materials.
  33236. */
  33237. environmentTexture: Nullable<BaseTexture>;
  33238. /** @hidden */
  33239. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33240. /**
  33241. * Default image processing configuration used either in the rendering
  33242. * Forward main pass or through the imageProcessingPostProcess if present.
  33243. * As in the majority of the scene they are the same (exception for multi camera),
  33244. * this is easier to reference from here than from all the materials and post process.
  33245. *
  33246. * No setter as we it is a shared configuration, you can set the values instead.
  33247. */
  33248. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33249. private _forceWireframe;
  33250. /**
  33251. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33252. */
  33253. forceWireframe: boolean;
  33254. private _forcePointsCloud;
  33255. /**
  33256. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33257. */
  33258. forcePointsCloud: boolean;
  33259. /**
  33260. * Gets or sets the active clipplane 1
  33261. */
  33262. clipPlane: Nullable<Plane>;
  33263. /**
  33264. * Gets or sets the active clipplane 2
  33265. */
  33266. clipPlane2: Nullable<Plane>;
  33267. /**
  33268. * Gets or sets the active clipplane 3
  33269. */
  33270. clipPlane3: Nullable<Plane>;
  33271. /**
  33272. * Gets or sets the active clipplane 4
  33273. */
  33274. clipPlane4: Nullable<Plane>;
  33275. /**
  33276. * Gets or sets a boolean indicating if animations are enabled
  33277. */
  33278. animationsEnabled: boolean;
  33279. private _animationPropertiesOverride;
  33280. /**
  33281. * Gets or sets the animation properties override
  33282. */
  33283. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33284. /**
  33285. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33286. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33287. */
  33288. useConstantAnimationDeltaTime: boolean;
  33289. /**
  33290. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33291. * Please note that it requires to run a ray cast through the scene on every frame
  33292. */
  33293. constantlyUpdateMeshUnderPointer: boolean;
  33294. /**
  33295. * Defines the HTML cursor to use when hovering over interactive elements
  33296. */
  33297. hoverCursor: string;
  33298. /**
  33299. * Defines the HTML default cursor to use (empty by default)
  33300. */
  33301. defaultCursor: string;
  33302. /**
  33303. * This is used to call preventDefault() on pointer down
  33304. * in order to block unwanted artifacts like system double clicks
  33305. */
  33306. preventDefaultOnPointerDown: boolean;
  33307. /**
  33308. * This is used to call preventDefault() on pointer up
  33309. * in order to block unwanted artifacts like system double clicks
  33310. */
  33311. preventDefaultOnPointerUp: boolean;
  33312. /**
  33313. * Gets or sets user defined metadata
  33314. */
  33315. metadata: any;
  33316. /**
  33317. * For internal use only. Please do not use.
  33318. */
  33319. reservedDataStore: any;
  33320. /**
  33321. * Gets the name of the plugin used to load this scene (null by default)
  33322. */
  33323. loadingPluginName: string;
  33324. /**
  33325. * Use this array to add regular expressions used to disable offline support for specific urls
  33326. */
  33327. disableOfflineSupportExceptionRules: RegExp[];
  33328. /**
  33329. * An event triggered when the scene is disposed.
  33330. */
  33331. onDisposeObservable: Observable<Scene>;
  33332. private _onDisposeObserver;
  33333. /** Sets a function to be executed when this scene is disposed. */
  33334. onDispose: () => void;
  33335. /**
  33336. * An event triggered before rendering the scene (right after animations and physics)
  33337. */
  33338. onBeforeRenderObservable: Observable<Scene>;
  33339. private _onBeforeRenderObserver;
  33340. /** Sets a function to be executed before rendering this scene */
  33341. beforeRender: Nullable<() => void>;
  33342. /**
  33343. * An event triggered after rendering the scene
  33344. */
  33345. onAfterRenderObservable: Observable<Scene>;
  33346. /**
  33347. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33348. */
  33349. onAfterRenderCameraObservable: Observable<Camera>;
  33350. private _onAfterRenderObserver;
  33351. /** Sets a function to be executed after rendering this scene */
  33352. afterRender: Nullable<() => void>;
  33353. /**
  33354. * An event triggered before animating the scene
  33355. */
  33356. onBeforeAnimationsObservable: Observable<Scene>;
  33357. /**
  33358. * An event triggered after animations processing
  33359. */
  33360. onAfterAnimationsObservable: Observable<Scene>;
  33361. /**
  33362. * An event triggered before draw calls are ready to be sent
  33363. */
  33364. onBeforeDrawPhaseObservable: Observable<Scene>;
  33365. /**
  33366. * An event triggered after draw calls have been sent
  33367. */
  33368. onAfterDrawPhaseObservable: Observable<Scene>;
  33369. /**
  33370. * An event triggered when the scene is ready
  33371. */
  33372. onReadyObservable: Observable<Scene>;
  33373. /**
  33374. * An event triggered before rendering a camera
  33375. */
  33376. onBeforeCameraRenderObservable: Observable<Camera>;
  33377. private _onBeforeCameraRenderObserver;
  33378. /** Sets a function to be executed before rendering a camera*/
  33379. beforeCameraRender: () => void;
  33380. /**
  33381. * An event triggered after rendering a camera
  33382. */
  33383. onAfterCameraRenderObservable: Observable<Camera>;
  33384. private _onAfterCameraRenderObserver;
  33385. /** Sets a function to be executed after rendering a camera*/
  33386. afterCameraRender: () => void;
  33387. /**
  33388. * An event triggered when active meshes evaluation is about to start
  33389. */
  33390. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33391. /**
  33392. * An event triggered when active meshes evaluation is done
  33393. */
  33394. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33395. /**
  33396. * An event triggered when particles rendering is about to start
  33397. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33398. */
  33399. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33400. /**
  33401. * An event triggered when particles rendering is done
  33402. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33403. */
  33404. onAfterParticlesRenderingObservable: Observable<Scene>;
  33405. /**
  33406. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33407. */
  33408. onDataLoadedObservable: Observable<Scene>;
  33409. /**
  33410. * An event triggered when a camera is created
  33411. */
  33412. onNewCameraAddedObservable: Observable<Camera>;
  33413. /**
  33414. * An event triggered when a camera is removed
  33415. */
  33416. onCameraRemovedObservable: Observable<Camera>;
  33417. /**
  33418. * An event triggered when a light is created
  33419. */
  33420. onNewLightAddedObservable: Observable<Light>;
  33421. /**
  33422. * An event triggered when a light is removed
  33423. */
  33424. onLightRemovedObservable: Observable<Light>;
  33425. /**
  33426. * An event triggered when a geometry is created
  33427. */
  33428. onNewGeometryAddedObservable: Observable<Geometry>;
  33429. /**
  33430. * An event triggered when a geometry is removed
  33431. */
  33432. onGeometryRemovedObservable: Observable<Geometry>;
  33433. /**
  33434. * An event triggered when a transform node is created
  33435. */
  33436. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33437. /**
  33438. * An event triggered when a transform node is removed
  33439. */
  33440. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33441. /**
  33442. * An event triggered when a mesh is created
  33443. */
  33444. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33445. /**
  33446. * An event triggered when a mesh is removed
  33447. */
  33448. onMeshRemovedObservable: Observable<AbstractMesh>;
  33449. /**
  33450. * An event triggered when a skeleton is created
  33451. */
  33452. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33453. /**
  33454. * An event triggered when a skeleton is removed
  33455. */
  33456. onSkeletonRemovedObservable: Observable<Skeleton>;
  33457. /**
  33458. * An event triggered when a material is created
  33459. */
  33460. onNewMaterialAddedObservable: Observable<Material>;
  33461. /**
  33462. * An event triggered when a material is removed
  33463. */
  33464. onMaterialRemovedObservable: Observable<Material>;
  33465. /**
  33466. * An event triggered when a texture is created
  33467. */
  33468. onNewTextureAddedObservable: Observable<BaseTexture>;
  33469. /**
  33470. * An event triggered when a texture is removed
  33471. */
  33472. onTextureRemovedObservable: Observable<BaseTexture>;
  33473. /**
  33474. * An event triggered when render targets are about to be rendered
  33475. * Can happen multiple times per frame.
  33476. */
  33477. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33478. /**
  33479. * An event triggered when render targets were rendered.
  33480. * Can happen multiple times per frame.
  33481. */
  33482. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33483. /**
  33484. * An event triggered before calculating deterministic simulation step
  33485. */
  33486. onBeforeStepObservable: Observable<Scene>;
  33487. /**
  33488. * An event triggered after calculating deterministic simulation step
  33489. */
  33490. onAfterStepObservable: Observable<Scene>;
  33491. /**
  33492. * An event triggered when the activeCamera property is updated
  33493. */
  33494. onActiveCameraChanged: Observable<Scene>;
  33495. /**
  33496. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33497. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33498. * 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)
  33499. */
  33500. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33501. /**
  33502. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33503. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33504. * 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)
  33505. */
  33506. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33507. /**
  33508. * This Observable will when a mesh has been imported into the scene.
  33509. */
  33510. onMeshImportedObservable: Observable<AbstractMesh>;
  33511. /**
  33512. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33513. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33514. */
  33515. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33516. /** @hidden */
  33517. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33518. /**
  33519. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33520. */
  33521. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33522. /**
  33523. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33524. */
  33525. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33526. /**
  33527. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33528. */
  33529. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33530. /** Callback called when a pointer move is detected */
  33531. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33532. /** Callback called when a pointer down is detected */
  33533. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33534. /** Callback called when a pointer up is detected */
  33535. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33536. /** Callback called when a pointer pick is detected */
  33537. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33538. /**
  33539. * 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).
  33540. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33541. */
  33542. onPrePointerObservable: Observable<PointerInfoPre>;
  33543. /**
  33544. * Observable event triggered each time an input event is received from the rendering canvas
  33545. */
  33546. onPointerObservable: Observable<PointerInfo>;
  33547. /**
  33548. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33549. */
  33550. readonly unTranslatedPointer: Vector2;
  33551. /**
  33552. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33553. */
  33554. static DragMovementThreshold: number;
  33555. /**
  33556. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33557. */
  33558. static LongPressDelay: number;
  33559. /**
  33560. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33561. */
  33562. static DoubleClickDelay: number;
  33563. /** If you need to check double click without raising a single click at first click, enable this flag */
  33564. static ExclusiveDoubleClickMode: boolean;
  33565. /** @hidden */
  33566. _mirroredCameraPosition: Nullable<Vector3>;
  33567. /**
  33568. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33569. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33570. */
  33571. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33572. /**
  33573. * Observable event triggered each time an keyboard event is received from the hosting window
  33574. */
  33575. onKeyboardObservable: Observable<KeyboardInfo>;
  33576. private _useRightHandedSystem;
  33577. /**
  33578. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33579. */
  33580. useRightHandedSystem: boolean;
  33581. private _timeAccumulator;
  33582. private _currentStepId;
  33583. private _currentInternalStep;
  33584. /**
  33585. * Sets the step Id used by deterministic lock step
  33586. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33587. * @param newStepId defines the step Id
  33588. */
  33589. setStepId(newStepId: number): void;
  33590. /**
  33591. * Gets the step Id used by deterministic lock step
  33592. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33593. * @returns the step Id
  33594. */
  33595. getStepId(): number;
  33596. /**
  33597. * Gets the internal step used by deterministic lock step
  33598. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33599. * @returns the internal step
  33600. */
  33601. getInternalStep(): number;
  33602. private _fogEnabled;
  33603. /**
  33604. * Gets or sets a boolean indicating if fog is enabled on this scene
  33605. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33606. * (Default is true)
  33607. */
  33608. fogEnabled: boolean;
  33609. private _fogMode;
  33610. /**
  33611. * Gets or sets the fog mode to use
  33612. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33613. * | mode | value |
  33614. * | --- | --- |
  33615. * | FOGMODE_NONE | 0 |
  33616. * | FOGMODE_EXP | 1 |
  33617. * | FOGMODE_EXP2 | 2 |
  33618. * | FOGMODE_LINEAR | 3 |
  33619. */
  33620. fogMode: number;
  33621. /**
  33622. * Gets or sets the fog color to use
  33623. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33624. * (Default is Color3(0.2, 0.2, 0.3))
  33625. */
  33626. fogColor: Color3;
  33627. /**
  33628. * Gets or sets the fog density to use
  33629. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33630. * (Default is 0.1)
  33631. */
  33632. fogDensity: number;
  33633. /**
  33634. * Gets or sets the fog start distance to use
  33635. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33636. * (Default is 0)
  33637. */
  33638. fogStart: number;
  33639. /**
  33640. * Gets or sets the fog end distance to use
  33641. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33642. * (Default is 1000)
  33643. */
  33644. fogEnd: number;
  33645. private _shadowsEnabled;
  33646. /**
  33647. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33648. */
  33649. shadowsEnabled: boolean;
  33650. private _lightsEnabled;
  33651. /**
  33652. * Gets or sets a boolean indicating if lights are enabled on this scene
  33653. */
  33654. lightsEnabled: boolean;
  33655. /** All of the active cameras added to this scene. */
  33656. activeCameras: Camera[];
  33657. /** @hidden */
  33658. _activeCamera: Nullable<Camera>;
  33659. /** Gets or sets the current active camera */
  33660. activeCamera: Nullable<Camera>;
  33661. private _defaultMaterial;
  33662. /** The default material used on meshes when no material is affected */
  33663. /** The default material used on meshes when no material is affected */
  33664. defaultMaterial: Material;
  33665. private _texturesEnabled;
  33666. /**
  33667. * Gets or sets a boolean indicating if textures are enabled on this scene
  33668. */
  33669. texturesEnabled: boolean;
  33670. /**
  33671. * Gets or sets a boolean indicating if particles are enabled on this scene
  33672. */
  33673. particlesEnabled: boolean;
  33674. /**
  33675. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33676. */
  33677. spritesEnabled: boolean;
  33678. private _skeletonsEnabled;
  33679. /**
  33680. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33681. */
  33682. skeletonsEnabled: boolean;
  33683. /**
  33684. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33685. */
  33686. lensFlaresEnabled: boolean;
  33687. /**
  33688. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33689. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33690. */
  33691. collisionsEnabled: boolean;
  33692. private _collisionCoordinator;
  33693. /** @hidden */
  33694. readonly collisionCoordinator: ICollisionCoordinator;
  33695. /**
  33696. * Defines the gravity applied to this scene (used only for collisions)
  33697. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33698. */
  33699. gravity: Vector3;
  33700. /**
  33701. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33702. */
  33703. postProcessesEnabled: boolean;
  33704. /**
  33705. * The list of postprocesses added to the scene
  33706. */
  33707. postProcesses: PostProcess[];
  33708. /**
  33709. * Gets the current postprocess manager
  33710. */
  33711. postProcessManager: PostProcessManager;
  33712. /**
  33713. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33714. */
  33715. renderTargetsEnabled: boolean;
  33716. /**
  33717. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33718. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33719. */
  33720. dumpNextRenderTargets: boolean;
  33721. /**
  33722. * The list of user defined render targets added to the scene
  33723. */
  33724. customRenderTargets: RenderTargetTexture[];
  33725. /**
  33726. * Defines if texture loading must be delayed
  33727. * If true, textures will only be loaded when they need to be rendered
  33728. */
  33729. useDelayedTextureLoading: boolean;
  33730. /**
  33731. * Gets the list of meshes imported to the scene through SceneLoader
  33732. */
  33733. importedMeshesFiles: String[];
  33734. /**
  33735. * Gets or sets a boolean indicating if probes are enabled on this scene
  33736. */
  33737. probesEnabled: boolean;
  33738. /**
  33739. * Gets or sets the current offline provider to use to store scene data
  33740. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33741. */
  33742. offlineProvider: IOfflineProvider;
  33743. /**
  33744. * Gets or sets the action manager associated with the scene
  33745. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33746. */
  33747. actionManager: AbstractActionManager;
  33748. private _meshesForIntersections;
  33749. /**
  33750. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33751. */
  33752. proceduralTexturesEnabled: boolean;
  33753. private _engine;
  33754. private _totalVertices;
  33755. /** @hidden */
  33756. _activeIndices: PerfCounter;
  33757. /** @hidden */
  33758. _activeParticles: PerfCounter;
  33759. /** @hidden */
  33760. _activeBones: PerfCounter;
  33761. private _animationRatio;
  33762. /** @hidden */
  33763. _animationTimeLast: number;
  33764. /** @hidden */
  33765. _animationTime: number;
  33766. /**
  33767. * Gets or sets a general scale for animation speed
  33768. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33769. */
  33770. animationTimeScale: number;
  33771. /** @hidden */
  33772. _cachedMaterial: Nullable<Material>;
  33773. /** @hidden */
  33774. _cachedEffect: Nullable<Effect>;
  33775. /** @hidden */
  33776. _cachedVisibility: Nullable<number>;
  33777. private _renderId;
  33778. private _frameId;
  33779. private _executeWhenReadyTimeoutId;
  33780. private _intermediateRendering;
  33781. private _viewUpdateFlag;
  33782. private _projectionUpdateFlag;
  33783. /** @hidden */
  33784. _toBeDisposed: Nullable<IDisposable>[];
  33785. private _activeRequests;
  33786. /** @hidden */
  33787. _pendingData: any[];
  33788. private _isDisposed;
  33789. /**
  33790. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33791. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33792. */
  33793. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33794. private _activeMeshes;
  33795. private _processedMaterials;
  33796. private _renderTargets;
  33797. /** @hidden */
  33798. _activeParticleSystems: SmartArray<IParticleSystem>;
  33799. private _activeSkeletons;
  33800. private _softwareSkinnedMeshes;
  33801. private _renderingManager;
  33802. /** @hidden */
  33803. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33804. private _transformMatrix;
  33805. private _sceneUbo;
  33806. /** @hidden */
  33807. _viewMatrix: Matrix;
  33808. private _projectionMatrix;
  33809. /** @hidden */
  33810. _forcedViewPosition: Nullable<Vector3>;
  33811. /** @hidden */
  33812. _frustumPlanes: Plane[];
  33813. /**
  33814. * Gets the list of frustum planes (built from the active camera)
  33815. */
  33816. readonly frustumPlanes: Plane[];
  33817. /**
  33818. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33819. * This is useful if there are more lights that the maximum simulteanous authorized
  33820. */
  33821. requireLightSorting: boolean;
  33822. /** @hidden */
  33823. readonly useMaterialMeshMap: boolean;
  33824. /** @hidden */
  33825. readonly useClonedMeshhMap: boolean;
  33826. private _externalData;
  33827. private _uid;
  33828. /**
  33829. * @hidden
  33830. * Backing store of defined scene components.
  33831. */
  33832. _components: ISceneComponent[];
  33833. /**
  33834. * @hidden
  33835. * Backing store of defined scene components.
  33836. */
  33837. _serializableComponents: ISceneSerializableComponent[];
  33838. /**
  33839. * List of components to register on the next registration step.
  33840. */
  33841. private _transientComponents;
  33842. /**
  33843. * Registers the transient components if needed.
  33844. */
  33845. private _registerTransientComponents;
  33846. /**
  33847. * @hidden
  33848. * Add a component to the scene.
  33849. * Note that the ccomponent could be registered on th next frame if this is called after
  33850. * the register component stage.
  33851. * @param component Defines the component to add to the scene
  33852. */
  33853. _addComponent(component: ISceneComponent): void;
  33854. /**
  33855. * @hidden
  33856. * Gets a component from the scene.
  33857. * @param name defines the name of the component to retrieve
  33858. * @returns the component or null if not present
  33859. */
  33860. _getComponent(name: string): Nullable<ISceneComponent>;
  33861. /**
  33862. * @hidden
  33863. * Defines the actions happening before camera updates.
  33864. */
  33865. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33866. /**
  33867. * @hidden
  33868. * Defines the actions happening before clear the canvas.
  33869. */
  33870. _beforeClearStage: Stage<SimpleStageAction>;
  33871. /**
  33872. * @hidden
  33873. * Defines the actions when collecting render targets for the frame.
  33874. */
  33875. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33876. /**
  33877. * @hidden
  33878. * Defines the actions happening for one camera in the frame.
  33879. */
  33880. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33881. /**
  33882. * @hidden
  33883. * Defines the actions happening during the per mesh ready checks.
  33884. */
  33885. _isReadyForMeshStage: Stage<MeshStageAction>;
  33886. /**
  33887. * @hidden
  33888. * Defines the actions happening before evaluate active mesh checks.
  33889. */
  33890. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33891. /**
  33892. * @hidden
  33893. * Defines the actions happening during the evaluate sub mesh checks.
  33894. */
  33895. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33896. /**
  33897. * @hidden
  33898. * Defines the actions happening during the active mesh stage.
  33899. */
  33900. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33901. /**
  33902. * @hidden
  33903. * Defines the actions happening during the per camera render target step.
  33904. */
  33905. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33906. /**
  33907. * @hidden
  33908. * Defines the actions happening just before the active camera is drawing.
  33909. */
  33910. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33911. /**
  33912. * @hidden
  33913. * Defines the actions happening just before a render target is drawing.
  33914. */
  33915. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33916. /**
  33917. * @hidden
  33918. * Defines the actions happening just before a rendering group is drawing.
  33919. */
  33920. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33921. /**
  33922. * @hidden
  33923. * Defines the actions happening just before a mesh is drawing.
  33924. */
  33925. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33926. /**
  33927. * @hidden
  33928. * Defines the actions happening just after a mesh has been drawn.
  33929. */
  33930. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33931. /**
  33932. * @hidden
  33933. * Defines the actions happening just after a rendering group has been drawn.
  33934. */
  33935. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33936. /**
  33937. * @hidden
  33938. * Defines the actions happening just after the active camera has been drawn.
  33939. */
  33940. _afterCameraDrawStage: Stage<CameraStageAction>;
  33941. /**
  33942. * @hidden
  33943. * Defines the actions happening just after a render target has been drawn.
  33944. */
  33945. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33946. /**
  33947. * @hidden
  33948. * Defines the actions happening just after rendering all cameras and computing intersections.
  33949. */
  33950. _afterRenderStage: Stage<SimpleStageAction>;
  33951. /**
  33952. * @hidden
  33953. * Defines the actions happening when a pointer move event happens.
  33954. */
  33955. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33956. /**
  33957. * @hidden
  33958. * Defines the actions happening when a pointer down event happens.
  33959. */
  33960. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33961. /**
  33962. * @hidden
  33963. * Defines the actions happening when a pointer up event happens.
  33964. */
  33965. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33966. /**
  33967. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33968. */
  33969. private geometriesByUniqueId;
  33970. /**
  33971. * Creates a new Scene
  33972. * @param engine defines the engine to use to render this scene
  33973. * @param options defines the scene options
  33974. */
  33975. constructor(engine: Engine, options?: SceneOptions);
  33976. /**
  33977. * Gets a string idenfifying the name of the class
  33978. * @returns "Scene" string
  33979. */
  33980. getClassName(): string;
  33981. private _defaultMeshCandidates;
  33982. /**
  33983. * @hidden
  33984. */
  33985. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33986. private _defaultSubMeshCandidates;
  33987. /**
  33988. * @hidden
  33989. */
  33990. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33991. /**
  33992. * Sets the default candidate providers for the scene.
  33993. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33994. * and getCollidingSubMeshCandidates to their default function
  33995. */
  33996. setDefaultCandidateProviders(): void;
  33997. /**
  33998. * Gets the mesh that is currently under the pointer
  33999. */
  34000. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34001. /**
  34002. * Gets or sets the current on-screen X position of the pointer
  34003. */
  34004. pointerX: number;
  34005. /**
  34006. * Gets or sets the current on-screen Y position of the pointer
  34007. */
  34008. pointerY: number;
  34009. /**
  34010. * Gets the cached material (ie. the latest rendered one)
  34011. * @returns the cached material
  34012. */
  34013. getCachedMaterial(): Nullable<Material>;
  34014. /**
  34015. * Gets the cached effect (ie. the latest rendered one)
  34016. * @returns the cached effect
  34017. */
  34018. getCachedEffect(): Nullable<Effect>;
  34019. /**
  34020. * Gets the cached visibility state (ie. the latest rendered one)
  34021. * @returns the cached visibility state
  34022. */
  34023. getCachedVisibility(): Nullable<number>;
  34024. /**
  34025. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34026. * @param material defines the current material
  34027. * @param effect defines the current effect
  34028. * @param visibility defines the current visibility state
  34029. * @returns true if one parameter is not cached
  34030. */
  34031. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34032. /**
  34033. * Gets the engine associated with the scene
  34034. * @returns an Engine
  34035. */
  34036. getEngine(): Engine;
  34037. /**
  34038. * Gets the total number of vertices rendered per frame
  34039. * @returns the total number of vertices rendered per frame
  34040. */
  34041. getTotalVertices(): number;
  34042. /**
  34043. * Gets the performance counter for total vertices
  34044. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34045. */
  34046. readonly totalVerticesPerfCounter: PerfCounter;
  34047. /**
  34048. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34049. * @returns the total number of active indices rendered per frame
  34050. */
  34051. getActiveIndices(): number;
  34052. /**
  34053. * Gets the performance counter for active indices
  34054. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34055. */
  34056. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34057. /**
  34058. * Gets the total number of active particles rendered per frame
  34059. * @returns the total number of active particles rendered per frame
  34060. */
  34061. getActiveParticles(): number;
  34062. /**
  34063. * Gets the performance counter for active particles
  34064. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34065. */
  34066. readonly activeParticlesPerfCounter: PerfCounter;
  34067. /**
  34068. * Gets the total number of active bones rendered per frame
  34069. * @returns the total number of active bones rendered per frame
  34070. */
  34071. getActiveBones(): number;
  34072. /**
  34073. * Gets the performance counter for active bones
  34074. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34075. */
  34076. readonly activeBonesPerfCounter: PerfCounter;
  34077. /**
  34078. * Gets the array of active meshes
  34079. * @returns an array of AbstractMesh
  34080. */
  34081. getActiveMeshes(): SmartArray<AbstractMesh>;
  34082. /**
  34083. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34084. * @returns a number
  34085. */
  34086. getAnimationRatio(): number;
  34087. /**
  34088. * Gets an unique Id for the current render phase
  34089. * @returns a number
  34090. */
  34091. getRenderId(): number;
  34092. /**
  34093. * Gets an unique Id for the current frame
  34094. * @returns a number
  34095. */
  34096. getFrameId(): number;
  34097. /** Call this function if you want to manually increment the render Id*/
  34098. incrementRenderId(): void;
  34099. private _createUbo;
  34100. /**
  34101. * Use this method to simulate a pointer move on a mesh
  34102. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34103. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34104. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34105. * @returns the current scene
  34106. */
  34107. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34108. /**
  34109. * Use this method to simulate a pointer down on a mesh
  34110. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34111. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34112. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34113. * @returns the current scene
  34114. */
  34115. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34116. /**
  34117. * Use this method to simulate a pointer up on a mesh
  34118. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34119. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34120. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34121. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34122. * @returns the current scene
  34123. */
  34124. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34125. /**
  34126. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34127. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34128. * @returns true if the pointer was captured
  34129. */
  34130. isPointerCaptured(pointerId?: number): boolean;
  34131. /**
  34132. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34133. * @param attachUp defines if you want to attach events to pointerup
  34134. * @param attachDown defines if you want to attach events to pointerdown
  34135. * @param attachMove defines if you want to attach events to pointermove
  34136. */
  34137. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34138. /** Detaches all event handlers*/
  34139. detachControl(): void;
  34140. /**
  34141. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34142. * Delay loaded resources are not taking in account
  34143. * @return true if all required resources are ready
  34144. */
  34145. isReady(): boolean;
  34146. /** Resets all cached information relative to material (including effect and visibility) */
  34147. resetCachedMaterial(): void;
  34148. /**
  34149. * Registers a function to be called before every frame render
  34150. * @param func defines the function to register
  34151. */
  34152. registerBeforeRender(func: () => void): void;
  34153. /**
  34154. * Unregisters a function called before every frame render
  34155. * @param func defines the function to unregister
  34156. */
  34157. unregisterBeforeRender(func: () => void): void;
  34158. /**
  34159. * Registers a function to be called after every frame render
  34160. * @param func defines the function to register
  34161. */
  34162. registerAfterRender(func: () => void): void;
  34163. /**
  34164. * Unregisters a function called after every frame render
  34165. * @param func defines the function to unregister
  34166. */
  34167. unregisterAfterRender(func: () => void): void;
  34168. private _executeOnceBeforeRender;
  34169. /**
  34170. * The provided function will run before render once and will be disposed afterwards.
  34171. * A timeout delay can be provided so that the function will be executed in N ms.
  34172. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34173. * @param func The function to be executed.
  34174. * @param timeout optional delay in ms
  34175. */
  34176. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34177. /** @hidden */
  34178. _addPendingData(data: any): void;
  34179. /** @hidden */
  34180. _removePendingData(data: any): void;
  34181. /**
  34182. * Returns the number of items waiting to be loaded
  34183. * @returns the number of items waiting to be loaded
  34184. */
  34185. getWaitingItemsCount(): number;
  34186. /**
  34187. * Returns a boolean indicating if the scene is still loading data
  34188. */
  34189. readonly isLoading: boolean;
  34190. /**
  34191. * Registers a function to be executed when the scene is ready
  34192. * @param {Function} func - the function to be executed
  34193. */
  34194. executeWhenReady(func: () => void): void;
  34195. /**
  34196. * Returns a promise that resolves when the scene is ready
  34197. * @returns A promise that resolves when the scene is ready
  34198. */
  34199. whenReadyAsync(): Promise<void>;
  34200. /** @hidden */
  34201. _checkIsReady(): void;
  34202. /**
  34203. * Gets all animatable attached to the scene
  34204. */
  34205. readonly animatables: Animatable[];
  34206. /**
  34207. * Resets the last animation time frame.
  34208. * Useful to override when animations start running when loading a scene for the first time.
  34209. */
  34210. resetLastAnimationTimeFrame(): void;
  34211. /**
  34212. * Gets the current view matrix
  34213. * @returns a Matrix
  34214. */
  34215. getViewMatrix(): Matrix;
  34216. /**
  34217. * Gets the current projection matrix
  34218. * @returns a Matrix
  34219. */
  34220. getProjectionMatrix(): Matrix;
  34221. /**
  34222. * Gets the current transform matrix
  34223. * @returns a Matrix made of View * Projection
  34224. */
  34225. getTransformMatrix(): Matrix;
  34226. /**
  34227. * Sets the current transform matrix
  34228. * @param viewL defines the View matrix to use
  34229. * @param projectionL defines the Projection matrix to use
  34230. * @param viewR defines the right View matrix to use (if provided)
  34231. * @param projectionR defines the right Projection matrix to use (if provided)
  34232. */
  34233. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34234. /**
  34235. * Gets the uniform buffer used to store scene data
  34236. * @returns a UniformBuffer
  34237. */
  34238. getSceneUniformBuffer(): UniformBuffer;
  34239. /**
  34240. * Gets an unique (relatively to the current scene) Id
  34241. * @returns an unique number for the scene
  34242. */
  34243. getUniqueId(): number;
  34244. /**
  34245. * Add a mesh to the list of scene's meshes
  34246. * @param newMesh defines the mesh to add
  34247. * @param recursive if all child meshes should also be added to the scene
  34248. */
  34249. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34250. /**
  34251. * Remove a mesh for the list of scene's meshes
  34252. * @param toRemove defines the mesh to remove
  34253. * @param recursive if all child meshes should also be removed from the scene
  34254. * @returns the index where the mesh was in the mesh list
  34255. */
  34256. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34257. /**
  34258. * Add a transform node to the list of scene's transform nodes
  34259. * @param newTransformNode defines the transform node to add
  34260. */
  34261. addTransformNode(newTransformNode: TransformNode): void;
  34262. /**
  34263. * Remove a transform node for the list of scene's transform nodes
  34264. * @param toRemove defines the transform node to remove
  34265. * @returns the index where the transform node was in the transform node list
  34266. */
  34267. removeTransformNode(toRemove: TransformNode): number;
  34268. /**
  34269. * Remove a skeleton for the list of scene's skeletons
  34270. * @param toRemove defines the skeleton to remove
  34271. * @returns the index where the skeleton was in the skeleton list
  34272. */
  34273. removeSkeleton(toRemove: Skeleton): number;
  34274. /**
  34275. * Remove a morph target for the list of scene's morph targets
  34276. * @param toRemove defines the morph target to remove
  34277. * @returns the index where the morph target was in the morph target list
  34278. */
  34279. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34280. /**
  34281. * Remove a light for the list of scene's lights
  34282. * @param toRemove defines the light to remove
  34283. * @returns the index where the light was in the light list
  34284. */
  34285. removeLight(toRemove: Light): number;
  34286. /**
  34287. * Remove a camera for the list of scene's cameras
  34288. * @param toRemove defines the camera to remove
  34289. * @returns the index where the camera was in the camera list
  34290. */
  34291. removeCamera(toRemove: Camera): number;
  34292. /**
  34293. * Remove a particle system for the list of scene's particle systems
  34294. * @param toRemove defines the particle system to remove
  34295. * @returns the index where the particle system was in the particle system list
  34296. */
  34297. removeParticleSystem(toRemove: IParticleSystem): number;
  34298. /**
  34299. * Remove a animation for the list of scene's animations
  34300. * @param toRemove defines the animation to remove
  34301. * @returns the index where the animation was in the animation list
  34302. */
  34303. removeAnimation(toRemove: Animation): number;
  34304. /**
  34305. * Will stop the animation of the given target
  34306. * @param target - the target
  34307. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34308. * @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)
  34309. */
  34310. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34311. /**
  34312. * Removes the given animation group from this scene.
  34313. * @param toRemove The animation group to remove
  34314. * @returns The index of the removed animation group
  34315. */
  34316. removeAnimationGroup(toRemove: AnimationGroup): number;
  34317. /**
  34318. * Removes the given multi-material from this scene.
  34319. * @param toRemove The multi-material to remove
  34320. * @returns The index of the removed multi-material
  34321. */
  34322. removeMultiMaterial(toRemove: MultiMaterial): number;
  34323. /**
  34324. * Removes the given material from this scene.
  34325. * @param toRemove The material to remove
  34326. * @returns The index of the removed material
  34327. */
  34328. removeMaterial(toRemove: Material): number;
  34329. /**
  34330. * Removes the given action manager from this scene.
  34331. * @param toRemove The action manager to remove
  34332. * @returns The index of the removed action manager
  34333. */
  34334. removeActionManager(toRemove: AbstractActionManager): number;
  34335. /**
  34336. * Removes the given texture from this scene.
  34337. * @param toRemove The texture to remove
  34338. * @returns The index of the removed texture
  34339. */
  34340. removeTexture(toRemove: BaseTexture): number;
  34341. /**
  34342. * Adds the given light to this scene
  34343. * @param newLight The light to add
  34344. */
  34345. addLight(newLight: Light): void;
  34346. /**
  34347. * Sorts the list list based on light priorities
  34348. */
  34349. sortLightsByPriority(): void;
  34350. /**
  34351. * Adds the given camera to this scene
  34352. * @param newCamera The camera to add
  34353. */
  34354. addCamera(newCamera: Camera): void;
  34355. /**
  34356. * Adds the given skeleton to this scene
  34357. * @param newSkeleton The skeleton to add
  34358. */
  34359. addSkeleton(newSkeleton: Skeleton): void;
  34360. /**
  34361. * Adds the given particle system to this scene
  34362. * @param newParticleSystem The particle system to add
  34363. */
  34364. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34365. /**
  34366. * Adds the given animation to this scene
  34367. * @param newAnimation The animation to add
  34368. */
  34369. addAnimation(newAnimation: Animation): void;
  34370. /**
  34371. * Adds the given animation group to this scene.
  34372. * @param newAnimationGroup The animation group to add
  34373. */
  34374. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34375. /**
  34376. * Adds the given multi-material to this scene
  34377. * @param newMultiMaterial The multi-material to add
  34378. */
  34379. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34380. /**
  34381. * Adds the given material to this scene
  34382. * @param newMaterial The material to add
  34383. */
  34384. addMaterial(newMaterial: Material): void;
  34385. /**
  34386. * Adds the given morph target to this scene
  34387. * @param newMorphTargetManager The morph target to add
  34388. */
  34389. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34390. /**
  34391. * Adds the given geometry to this scene
  34392. * @param newGeometry The geometry to add
  34393. */
  34394. addGeometry(newGeometry: Geometry): void;
  34395. /**
  34396. * Adds the given action manager to this scene
  34397. * @param newActionManager The action manager to add
  34398. */
  34399. addActionManager(newActionManager: AbstractActionManager): void;
  34400. /**
  34401. * Adds the given texture to this scene.
  34402. * @param newTexture The texture to add
  34403. */
  34404. addTexture(newTexture: BaseTexture): void;
  34405. /**
  34406. * Switch active camera
  34407. * @param newCamera defines the new active camera
  34408. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34409. */
  34410. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34411. /**
  34412. * sets the active camera of the scene using its ID
  34413. * @param id defines the camera's ID
  34414. * @return the new active camera or null if none found.
  34415. */
  34416. setActiveCameraByID(id: string): Nullable<Camera>;
  34417. /**
  34418. * sets the active camera of the scene using its name
  34419. * @param name defines the camera's name
  34420. * @returns the new active camera or null if none found.
  34421. */
  34422. setActiveCameraByName(name: string): Nullable<Camera>;
  34423. /**
  34424. * get an animation group using its name
  34425. * @param name defines the material's name
  34426. * @return the animation group or null if none found.
  34427. */
  34428. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34429. /**
  34430. * Get a material using its unique id
  34431. * @param uniqueId defines the material's unique id
  34432. * @return the material or null if none found.
  34433. */
  34434. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34435. /**
  34436. * get a material using its id
  34437. * @param id defines the material's ID
  34438. * @return the material or null if none found.
  34439. */
  34440. getMaterialByID(id: string): Nullable<Material>;
  34441. /**
  34442. * Gets a the last added material using a given id
  34443. * @param id defines the material's ID
  34444. * @return the last material with the given id or null if none found.
  34445. */
  34446. getLastMaterialByID(id: string): Nullable<Material>;
  34447. /**
  34448. * Gets a material using its name
  34449. * @param name defines the material's name
  34450. * @return the material or null if none found.
  34451. */
  34452. getMaterialByName(name: string): Nullable<Material>;
  34453. /**
  34454. * Gets a camera using its id
  34455. * @param id defines the id to look for
  34456. * @returns the camera or null if not found
  34457. */
  34458. getCameraByID(id: string): Nullable<Camera>;
  34459. /**
  34460. * Gets a camera using its unique id
  34461. * @param uniqueId defines the unique id to look for
  34462. * @returns the camera or null if not found
  34463. */
  34464. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34465. /**
  34466. * Gets a camera using its name
  34467. * @param name defines the camera's name
  34468. * @return the camera or null if none found.
  34469. */
  34470. getCameraByName(name: string): Nullable<Camera>;
  34471. /**
  34472. * Gets a bone using its id
  34473. * @param id defines the bone's id
  34474. * @return the bone or null if not found
  34475. */
  34476. getBoneByID(id: string): Nullable<Bone>;
  34477. /**
  34478. * Gets a bone using its id
  34479. * @param name defines the bone's name
  34480. * @return the bone or null if not found
  34481. */
  34482. getBoneByName(name: string): Nullable<Bone>;
  34483. /**
  34484. * Gets a light node using its name
  34485. * @param name defines the the light's name
  34486. * @return the light or null if none found.
  34487. */
  34488. getLightByName(name: string): Nullable<Light>;
  34489. /**
  34490. * Gets a light node using its id
  34491. * @param id defines the light's id
  34492. * @return the light or null if none found.
  34493. */
  34494. getLightByID(id: string): Nullable<Light>;
  34495. /**
  34496. * Gets a light node using its scene-generated unique ID
  34497. * @param uniqueId defines the light's unique id
  34498. * @return the light or null if none found.
  34499. */
  34500. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34501. /**
  34502. * Gets a particle system by id
  34503. * @param id defines the particle system id
  34504. * @return the corresponding system or null if none found
  34505. */
  34506. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34507. /**
  34508. * Gets a geometry using its ID
  34509. * @param id defines the geometry's id
  34510. * @return the geometry or null if none found.
  34511. */
  34512. getGeometryByID(id: string): Nullable<Geometry>;
  34513. private _getGeometryByUniqueID;
  34514. /**
  34515. * Add a new geometry to this scene
  34516. * @param geometry defines the geometry to be added to the scene.
  34517. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34518. * @return a boolean defining if the geometry was added or not
  34519. */
  34520. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34521. /**
  34522. * Removes an existing geometry
  34523. * @param geometry defines the geometry to be removed from the scene
  34524. * @return a boolean defining if the geometry was removed or not
  34525. */
  34526. removeGeometry(geometry: Geometry): boolean;
  34527. /**
  34528. * Gets the list of geometries attached to the scene
  34529. * @returns an array of Geometry
  34530. */
  34531. getGeometries(): Geometry[];
  34532. /**
  34533. * Gets the first added mesh found of a given ID
  34534. * @param id defines the id to search for
  34535. * @return the mesh found or null if not found at all
  34536. */
  34537. getMeshByID(id: string): Nullable<AbstractMesh>;
  34538. /**
  34539. * Gets a list of meshes using their id
  34540. * @param id defines the id to search for
  34541. * @returns a list of meshes
  34542. */
  34543. getMeshesByID(id: string): Array<AbstractMesh>;
  34544. /**
  34545. * Gets the first added transform node found of a given ID
  34546. * @param id defines the id to search for
  34547. * @return the found transform node or null if not found at all.
  34548. */
  34549. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34550. /**
  34551. * Gets a transform node with its auto-generated unique id
  34552. * @param uniqueId efines the unique id to search for
  34553. * @return the found transform node or null if not found at all.
  34554. */
  34555. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34556. /**
  34557. * Gets a list of transform nodes using their id
  34558. * @param id defines the id to search for
  34559. * @returns a list of transform nodes
  34560. */
  34561. getTransformNodesByID(id: string): Array<TransformNode>;
  34562. /**
  34563. * Gets a mesh with its auto-generated unique id
  34564. * @param uniqueId defines the unique id to search for
  34565. * @return the found mesh or null if not found at all.
  34566. */
  34567. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34568. /**
  34569. * Gets a the last added mesh using a given id
  34570. * @param id defines the id to search for
  34571. * @return the found mesh or null if not found at all.
  34572. */
  34573. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34574. /**
  34575. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34576. * @param id defines the id to search for
  34577. * @return the found node or null if not found at all
  34578. */
  34579. getLastEntryByID(id: string): Nullable<Node>;
  34580. /**
  34581. * Gets a node (Mesh, Camera, Light) using a given id
  34582. * @param id defines the id to search for
  34583. * @return the found node or null if not found at all
  34584. */
  34585. getNodeByID(id: string): Nullable<Node>;
  34586. /**
  34587. * Gets a node (Mesh, Camera, Light) using a given name
  34588. * @param name defines the name to search for
  34589. * @return the found node or null if not found at all.
  34590. */
  34591. getNodeByName(name: string): Nullable<Node>;
  34592. /**
  34593. * Gets a mesh using a given name
  34594. * @param name defines the name to search for
  34595. * @return the found mesh or null if not found at all.
  34596. */
  34597. getMeshByName(name: string): Nullable<AbstractMesh>;
  34598. /**
  34599. * Gets a transform node using a given name
  34600. * @param name defines the name to search for
  34601. * @return the found transform node or null if not found at all.
  34602. */
  34603. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34604. /**
  34605. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34606. * @param id defines the id to search for
  34607. * @return the found skeleton or null if not found at all.
  34608. */
  34609. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34610. /**
  34611. * Gets a skeleton using a given auto generated unique id
  34612. * @param uniqueId defines the unique id to search for
  34613. * @return the found skeleton or null if not found at all.
  34614. */
  34615. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34616. /**
  34617. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34618. * @param id defines the id to search for
  34619. * @return the found skeleton or null if not found at all.
  34620. */
  34621. getSkeletonById(id: string): Nullable<Skeleton>;
  34622. /**
  34623. * Gets a skeleton using a given name
  34624. * @param name defines the name to search for
  34625. * @return the found skeleton or null if not found at all.
  34626. */
  34627. getSkeletonByName(name: string): Nullable<Skeleton>;
  34628. /**
  34629. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34630. * @param id defines the id to search for
  34631. * @return the found morph target manager or null if not found at all.
  34632. */
  34633. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34634. /**
  34635. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34636. * @param id defines the id to search for
  34637. * @return the found morph target or null if not found at all.
  34638. */
  34639. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34640. /**
  34641. * Gets a boolean indicating if the given mesh is active
  34642. * @param mesh defines the mesh to look for
  34643. * @returns true if the mesh is in the active list
  34644. */
  34645. isActiveMesh(mesh: AbstractMesh): boolean;
  34646. /**
  34647. * Return a unique id as a string which can serve as an identifier for the scene
  34648. */
  34649. readonly uid: string;
  34650. /**
  34651. * Add an externaly attached data from its key.
  34652. * This method call will fail and return false, if such key already exists.
  34653. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34654. * @param key the unique key that identifies the data
  34655. * @param data the data object to associate to the key for this Engine instance
  34656. * @return true if no such key were already present and the data was added successfully, false otherwise
  34657. */
  34658. addExternalData<T>(key: string, data: T): boolean;
  34659. /**
  34660. * Get an externaly attached data from its key
  34661. * @param key the unique key that identifies the data
  34662. * @return the associated data, if present (can be null), or undefined if not present
  34663. */
  34664. getExternalData<T>(key: string): Nullable<T>;
  34665. /**
  34666. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34667. * @param key the unique key that identifies the data
  34668. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34669. * @return the associated data, can be null if the factory returned null.
  34670. */
  34671. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34672. /**
  34673. * Remove an externaly attached data from the Engine instance
  34674. * @param key the unique key that identifies the data
  34675. * @return true if the data was successfully removed, false if it doesn't exist
  34676. */
  34677. removeExternalData(key: string): boolean;
  34678. private _evaluateSubMesh;
  34679. /**
  34680. * Clear the processed materials smart array preventing retention point in material dispose.
  34681. */
  34682. freeProcessedMaterials(): void;
  34683. private _preventFreeActiveMeshesAndRenderingGroups;
  34684. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34685. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34686. * when disposing several meshes in a row or a hierarchy of meshes.
  34687. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34688. */
  34689. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34690. /**
  34691. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34692. */
  34693. freeActiveMeshes(): void;
  34694. /**
  34695. * Clear the info related to rendering groups preventing retention points during dispose.
  34696. */
  34697. freeRenderingGroups(): void;
  34698. /** @hidden */
  34699. _isInIntermediateRendering(): boolean;
  34700. /**
  34701. * Lambda returning the list of potentially active meshes.
  34702. */
  34703. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34704. /**
  34705. * Lambda returning the list of potentially active sub meshes.
  34706. */
  34707. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34708. /**
  34709. * Lambda returning the list of potentially intersecting sub meshes.
  34710. */
  34711. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34712. /**
  34713. * Lambda returning the list of potentially colliding sub meshes.
  34714. */
  34715. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34716. private _activeMeshesFrozen;
  34717. /**
  34718. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34719. * @returns the current scene
  34720. */
  34721. freezeActiveMeshes(): Scene;
  34722. /**
  34723. * Use this function to restart evaluating active meshes on every frame
  34724. * @returns the current scene
  34725. */
  34726. unfreezeActiveMeshes(): Scene;
  34727. private _evaluateActiveMeshes;
  34728. private _activeMesh;
  34729. /**
  34730. * Update the transform matrix to update from the current active camera
  34731. * @param force defines a boolean used to force the update even if cache is up to date
  34732. */
  34733. updateTransformMatrix(force?: boolean): void;
  34734. private _bindFrameBuffer;
  34735. /** @hidden */
  34736. _allowPostProcessClearColor: boolean;
  34737. /** @hidden */
  34738. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34739. private _processSubCameras;
  34740. private _checkIntersections;
  34741. /** @hidden */
  34742. _advancePhysicsEngineStep(step: number): void;
  34743. /**
  34744. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34745. */
  34746. getDeterministicFrameTime: () => number;
  34747. /** @hidden */
  34748. _animate(): void;
  34749. /** Execute all animations (for a frame) */
  34750. animate(): void;
  34751. /**
  34752. * Render the scene
  34753. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34754. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34755. */
  34756. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34757. /**
  34758. * Freeze all materials
  34759. * A frozen material will not be updatable but should be faster to render
  34760. */
  34761. freezeMaterials(): void;
  34762. /**
  34763. * Unfreeze all materials
  34764. * A frozen material will not be updatable but should be faster to render
  34765. */
  34766. unfreezeMaterials(): void;
  34767. /**
  34768. * Releases all held ressources
  34769. */
  34770. dispose(): void;
  34771. /**
  34772. * Gets if the scene is already disposed
  34773. */
  34774. readonly isDisposed: boolean;
  34775. /**
  34776. * Call this function to reduce memory footprint of the scene.
  34777. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34778. */
  34779. clearCachedVertexData(): void;
  34780. /**
  34781. * This function will remove the local cached buffer data from texture.
  34782. * It will save memory but will prevent the texture from being rebuilt
  34783. */
  34784. cleanCachedTextureBuffer(): void;
  34785. /**
  34786. * Get the world extend vectors with an optional filter
  34787. *
  34788. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34789. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34790. */
  34791. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34792. min: Vector3;
  34793. max: Vector3;
  34794. };
  34795. /**
  34796. * Creates a ray that can be used to pick in the scene
  34797. * @param x defines the x coordinate of the origin (on-screen)
  34798. * @param y defines the y coordinate of the origin (on-screen)
  34799. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34800. * @param camera defines the camera to use for the picking
  34801. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34802. * @returns a Ray
  34803. */
  34804. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34805. /**
  34806. * Creates a ray that can be used to pick in the scene
  34807. * @param x defines the x coordinate of the origin (on-screen)
  34808. * @param y defines the y coordinate of the origin (on-screen)
  34809. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34810. * @param result defines the ray where to store the picking ray
  34811. * @param camera defines the camera to use for the picking
  34812. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34813. * @returns the current scene
  34814. */
  34815. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34816. /**
  34817. * Creates a ray that can be used to pick in the scene
  34818. * @param x defines the x coordinate of the origin (on-screen)
  34819. * @param y defines the y coordinate of the origin (on-screen)
  34820. * @param camera defines the camera to use for the picking
  34821. * @returns a Ray
  34822. */
  34823. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34824. /**
  34825. * Creates a ray that can be used to pick in the scene
  34826. * @param x defines the x coordinate of the origin (on-screen)
  34827. * @param y defines the y coordinate of the origin (on-screen)
  34828. * @param result defines the ray where to store the picking ray
  34829. * @param camera defines the camera to use for the picking
  34830. * @returns the current scene
  34831. */
  34832. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34833. /** Launch a ray to try to pick a mesh in the scene
  34834. * @param x position on screen
  34835. * @param y position on screen
  34836. * @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
  34837. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34838. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34839. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34840. * @returns a PickingInfo
  34841. */
  34842. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34843. /** Use the given ray to pick a mesh in the scene
  34844. * @param ray The ray to use to pick meshes
  34845. * @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
  34846. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34847. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34848. * @returns a PickingInfo
  34849. */
  34850. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34851. /**
  34852. * Launch a ray to try to pick a mesh in the scene
  34853. * @param x X position on screen
  34854. * @param y Y position on screen
  34855. * @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
  34856. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34857. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34858. * @returns an array of PickingInfo
  34859. */
  34860. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34861. /**
  34862. * Launch a ray to try to pick a mesh in the scene
  34863. * @param ray Ray to use
  34864. * @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
  34865. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34866. * @returns an array of PickingInfo
  34867. */
  34868. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34869. /**
  34870. * Force the value of meshUnderPointer
  34871. * @param mesh defines the mesh to use
  34872. */
  34873. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34874. /**
  34875. * Gets the mesh under the pointer
  34876. * @returns a Mesh or null if no mesh is under the pointer
  34877. */
  34878. getPointerOverMesh(): Nullable<AbstractMesh>;
  34879. /** @hidden */
  34880. _rebuildGeometries(): void;
  34881. /** @hidden */
  34882. _rebuildTextures(): void;
  34883. private _getByTags;
  34884. /**
  34885. * Get a list of meshes by tags
  34886. * @param tagsQuery defines the tags query to use
  34887. * @param forEach defines a predicate used to filter results
  34888. * @returns an array of Mesh
  34889. */
  34890. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34891. /**
  34892. * Get a list of cameras by tags
  34893. * @param tagsQuery defines the tags query to use
  34894. * @param forEach defines a predicate used to filter results
  34895. * @returns an array of Camera
  34896. */
  34897. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34898. /**
  34899. * Get a list of lights by tags
  34900. * @param tagsQuery defines the tags query to use
  34901. * @param forEach defines a predicate used to filter results
  34902. * @returns an array of Light
  34903. */
  34904. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34905. /**
  34906. * Get a list of materials by tags
  34907. * @param tagsQuery defines the tags query to use
  34908. * @param forEach defines a predicate used to filter results
  34909. * @returns an array of Material
  34910. */
  34911. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34912. /**
  34913. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34914. * This allowed control for front to back rendering or reversly depending of the special needs.
  34915. *
  34916. * @param renderingGroupId The rendering group id corresponding to its index
  34917. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34918. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34919. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34920. */
  34921. 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;
  34922. /**
  34923. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34924. *
  34925. * @param renderingGroupId The rendering group id corresponding to its index
  34926. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34927. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34928. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34929. */
  34930. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34931. /**
  34932. * Gets the current auto clear configuration for one rendering group of the rendering
  34933. * manager.
  34934. * @param index the rendering group index to get the information for
  34935. * @returns The auto clear setup for the requested rendering group
  34936. */
  34937. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34938. private _blockMaterialDirtyMechanism;
  34939. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34940. blockMaterialDirtyMechanism: boolean;
  34941. /**
  34942. * Will flag all materials as dirty to trigger new shader compilation
  34943. * @param flag defines the flag used to specify which material part must be marked as dirty
  34944. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34945. */
  34946. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34947. /** @hidden */
  34948. _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;
  34949. /** @hidden */
  34950. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34951. }
  34952. }
  34953. declare module "babylonjs/assetContainer" {
  34954. import { AbstractScene } from "babylonjs/abstractScene";
  34955. import { Scene } from "babylonjs/scene";
  34956. import { Mesh } from "babylonjs/Meshes/mesh";
  34957. /**
  34958. * Set of assets to keep when moving a scene into an asset container.
  34959. */
  34960. export class KeepAssets extends AbstractScene {
  34961. }
  34962. /**
  34963. * Container with a set of assets that can be added or removed from a scene.
  34964. */
  34965. export class AssetContainer extends AbstractScene {
  34966. /**
  34967. * The scene the AssetContainer belongs to.
  34968. */
  34969. scene: Scene;
  34970. /**
  34971. * Instantiates an AssetContainer.
  34972. * @param scene The scene the AssetContainer belongs to.
  34973. */
  34974. constructor(scene: Scene);
  34975. /**
  34976. * Adds all the assets from the container to the scene.
  34977. */
  34978. addAllToScene(): void;
  34979. /**
  34980. * Removes all the assets in the container from the scene
  34981. */
  34982. removeAllFromScene(): void;
  34983. /**
  34984. * Disposes all the assets in the container
  34985. */
  34986. dispose(): void;
  34987. private _moveAssets;
  34988. /**
  34989. * Removes all the assets contained in the scene and adds them to the container.
  34990. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34991. */
  34992. moveAllFromScene(keepAssets?: KeepAssets): void;
  34993. /**
  34994. * 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.
  34995. * @returns the root mesh
  34996. */
  34997. createRootMesh(): Mesh;
  34998. }
  34999. }
  35000. declare module "babylonjs/abstractScene" {
  35001. import { Scene } from "babylonjs/scene";
  35002. import { Nullable } from "babylonjs/types";
  35003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35004. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35005. import { Geometry } from "babylonjs/Meshes/geometry";
  35006. import { Skeleton } from "babylonjs/Bones/skeleton";
  35007. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35008. import { AssetContainer } from "babylonjs/assetContainer";
  35009. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35010. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35011. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35012. import { Material } from "babylonjs/Materials/material";
  35013. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35014. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35015. import { Camera } from "babylonjs/Cameras/camera";
  35016. import { Light } from "babylonjs/Lights/light";
  35017. import { Node } from "babylonjs/node";
  35018. import { Animation } from "babylonjs/Animations/animation";
  35019. /**
  35020. * Defines how the parser contract is defined.
  35021. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35022. */
  35023. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35024. /**
  35025. * Defines how the individual parser contract is defined.
  35026. * These parser can parse an individual asset
  35027. */
  35028. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35029. /**
  35030. * Base class of the scene acting as a container for the different elements composing a scene.
  35031. * This class is dynamically extended by the different components of the scene increasing
  35032. * flexibility and reducing coupling
  35033. */
  35034. export abstract class AbstractScene {
  35035. /**
  35036. * Stores the list of available parsers in the application.
  35037. */
  35038. private static _BabylonFileParsers;
  35039. /**
  35040. * Stores the list of available individual parsers in the application.
  35041. */
  35042. private static _IndividualBabylonFileParsers;
  35043. /**
  35044. * Adds a parser in the list of available ones
  35045. * @param name Defines the name of the parser
  35046. * @param parser Defines the parser to add
  35047. */
  35048. static AddParser(name: string, parser: BabylonFileParser): void;
  35049. /**
  35050. * Gets a general parser from the list of avaialble ones
  35051. * @param name Defines the name of the parser
  35052. * @returns the requested parser or null
  35053. */
  35054. static GetParser(name: string): Nullable<BabylonFileParser>;
  35055. /**
  35056. * Adds n individual parser in the list of available ones
  35057. * @param name Defines the name of the parser
  35058. * @param parser Defines the parser to add
  35059. */
  35060. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35061. /**
  35062. * Gets an individual parser from the list of avaialble ones
  35063. * @param name Defines the name of the parser
  35064. * @returns the requested parser or null
  35065. */
  35066. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35067. /**
  35068. * Parser json data and populate both a scene and its associated container object
  35069. * @param jsonData Defines the data to parse
  35070. * @param scene Defines the scene to parse the data for
  35071. * @param container Defines the container attached to the parsing sequence
  35072. * @param rootUrl Defines the root url of the data
  35073. */
  35074. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35075. /**
  35076. * Gets the list of root nodes (ie. nodes with no parent)
  35077. */
  35078. rootNodes: Node[];
  35079. /** All of the cameras added to this scene
  35080. * @see http://doc.babylonjs.com/babylon101/cameras
  35081. */
  35082. cameras: Camera[];
  35083. /**
  35084. * All of the lights added to this scene
  35085. * @see http://doc.babylonjs.com/babylon101/lights
  35086. */
  35087. lights: Light[];
  35088. /**
  35089. * All of the (abstract) meshes added to this scene
  35090. */
  35091. meshes: AbstractMesh[];
  35092. /**
  35093. * The list of skeletons added to the scene
  35094. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35095. */
  35096. skeletons: Skeleton[];
  35097. /**
  35098. * All of the particle systems added to this scene
  35099. * @see http://doc.babylonjs.com/babylon101/particles
  35100. */
  35101. particleSystems: IParticleSystem[];
  35102. /**
  35103. * Gets a list of Animations associated with the scene
  35104. */
  35105. animations: Animation[];
  35106. /**
  35107. * All of the animation groups added to this scene
  35108. * @see http://doc.babylonjs.com/how_to/group
  35109. */
  35110. animationGroups: AnimationGroup[];
  35111. /**
  35112. * All of the multi-materials added to this scene
  35113. * @see http://doc.babylonjs.com/how_to/multi_materials
  35114. */
  35115. multiMaterials: MultiMaterial[];
  35116. /**
  35117. * All of the materials added to this scene
  35118. * In the context of a Scene, it is not supposed to be modified manually.
  35119. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35120. * Note also that the order of the Material wihin the array is not significant and might change.
  35121. * @see http://doc.babylonjs.com/babylon101/materials
  35122. */
  35123. materials: Material[];
  35124. /**
  35125. * The list of morph target managers added to the scene
  35126. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35127. */
  35128. morphTargetManagers: MorphTargetManager[];
  35129. /**
  35130. * The list of geometries used in the scene.
  35131. */
  35132. geometries: Geometry[];
  35133. /**
  35134. * All of the tranform nodes added to this scene
  35135. * In the context of a Scene, it is not supposed to be modified manually.
  35136. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35137. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35138. * @see http://doc.babylonjs.com/how_to/transformnode
  35139. */
  35140. transformNodes: TransformNode[];
  35141. /**
  35142. * ActionManagers available on the scene.
  35143. */
  35144. actionManagers: AbstractActionManager[];
  35145. /**
  35146. * Textures to keep.
  35147. */
  35148. textures: BaseTexture[];
  35149. /**
  35150. * Environment texture for the scene
  35151. */
  35152. environmentTexture: Nullable<BaseTexture>;
  35153. }
  35154. }
  35155. declare module "babylonjs/Audio/sound" {
  35156. import { Observable } from "babylonjs/Misc/observable";
  35157. import { Vector3 } from "babylonjs/Maths/math";
  35158. import { Nullable } from "babylonjs/types";
  35159. import { Scene } from "babylonjs/scene";
  35160. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35161. /**
  35162. * Interface used to define options for Sound class
  35163. */
  35164. export interface ISoundOptions {
  35165. /**
  35166. * Does the sound autoplay once loaded.
  35167. */
  35168. autoplay?: boolean;
  35169. /**
  35170. * Does the sound loop after it finishes playing once.
  35171. */
  35172. loop?: boolean;
  35173. /**
  35174. * Sound's volume
  35175. */
  35176. volume?: number;
  35177. /**
  35178. * Is it a spatial sound?
  35179. */
  35180. spatialSound?: boolean;
  35181. /**
  35182. * Maximum distance to hear that sound
  35183. */
  35184. maxDistance?: number;
  35185. /**
  35186. * Uses user defined attenuation function
  35187. */
  35188. useCustomAttenuation?: boolean;
  35189. /**
  35190. * Define the roll off factor of spatial sounds.
  35191. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35192. */
  35193. rolloffFactor?: number;
  35194. /**
  35195. * Define the reference distance the sound should be heard perfectly.
  35196. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35197. */
  35198. refDistance?: number;
  35199. /**
  35200. * Define the distance attenuation model the sound will follow.
  35201. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35202. */
  35203. distanceModel?: string;
  35204. /**
  35205. * Defines the playback speed (1 by default)
  35206. */
  35207. playbackRate?: number;
  35208. /**
  35209. * Defines if the sound is from a streaming source
  35210. */
  35211. streaming?: boolean;
  35212. /**
  35213. * Defines an optional length (in seconds) inside the sound file
  35214. */
  35215. length?: number;
  35216. /**
  35217. * Defines an optional offset (in seconds) inside the sound file
  35218. */
  35219. offset?: number;
  35220. /**
  35221. * If true, URLs will not be required to state the audio file codec to use.
  35222. */
  35223. skipCodecCheck?: boolean;
  35224. }
  35225. /**
  35226. * Defines a sound that can be played in the application.
  35227. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35228. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35229. */
  35230. export class Sound {
  35231. /**
  35232. * The name of the sound in the scene.
  35233. */
  35234. name: string;
  35235. /**
  35236. * Does the sound autoplay once loaded.
  35237. */
  35238. autoplay: boolean;
  35239. /**
  35240. * Does the sound loop after it finishes playing once.
  35241. */
  35242. loop: boolean;
  35243. /**
  35244. * Does the sound use a custom attenuation curve to simulate the falloff
  35245. * happening when the source gets further away from the camera.
  35246. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35247. */
  35248. useCustomAttenuation: boolean;
  35249. /**
  35250. * The sound track id this sound belongs to.
  35251. */
  35252. soundTrackId: number;
  35253. /**
  35254. * Is this sound currently played.
  35255. */
  35256. isPlaying: boolean;
  35257. /**
  35258. * Is this sound currently paused.
  35259. */
  35260. isPaused: boolean;
  35261. /**
  35262. * Does this sound enables spatial sound.
  35263. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35264. */
  35265. spatialSound: boolean;
  35266. /**
  35267. * Define the reference distance the sound should be heard perfectly.
  35268. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35269. */
  35270. refDistance: number;
  35271. /**
  35272. * Define the roll off factor of spatial sounds.
  35273. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35274. */
  35275. rolloffFactor: number;
  35276. /**
  35277. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35278. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35279. */
  35280. maxDistance: number;
  35281. /**
  35282. * Define the distance attenuation model the sound will follow.
  35283. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35284. */
  35285. distanceModel: string;
  35286. /**
  35287. * @hidden
  35288. * Back Compat
  35289. **/
  35290. onended: () => any;
  35291. /**
  35292. * Observable event when the current playing sound finishes.
  35293. */
  35294. onEndedObservable: Observable<Sound>;
  35295. private _panningModel;
  35296. private _playbackRate;
  35297. private _streaming;
  35298. private _startTime;
  35299. private _startOffset;
  35300. private _position;
  35301. /** @hidden */
  35302. _positionInEmitterSpace: boolean;
  35303. private _localDirection;
  35304. private _volume;
  35305. private _isReadyToPlay;
  35306. private _isDirectional;
  35307. private _readyToPlayCallback;
  35308. private _audioBuffer;
  35309. private _soundSource;
  35310. private _streamingSource;
  35311. private _soundPanner;
  35312. private _soundGain;
  35313. private _inputAudioNode;
  35314. private _outputAudioNode;
  35315. private _coneInnerAngle;
  35316. private _coneOuterAngle;
  35317. private _coneOuterGain;
  35318. private _scene;
  35319. private _connectedTransformNode;
  35320. private _customAttenuationFunction;
  35321. private _registerFunc;
  35322. private _isOutputConnected;
  35323. private _htmlAudioElement;
  35324. private _urlType;
  35325. private _length?;
  35326. private _offset?;
  35327. /** @hidden */
  35328. static _SceneComponentInitialization: (scene: Scene) => void;
  35329. /**
  35330. * Create a sound and attach it to a scene
  35331. * @param name Name of your sound
  35332. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35333. * @param scene defines the scene the sound belongs to
  35334. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35335. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35336. */
  35337. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35338. /**
  35339. * Release the sound and its associated resources
  35340. */
  35341. dispose(): void;
  35342. /**
  35343. * Gets if the sounds is ready to be played or not.
  35344. * @returns true if ready, otherwise false
  35345. */
  35346. isReady(): boolean;
  35347. private _soundLoaded;
  35348. /**
  35349. * Sets the data of the sound from an audiobuffer
  35350. * @param audioBuffer The audioBuffer containing the data
  35351. */
  35352. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35353. /**
  35354. * Updates the current sounds options such as maxdistance, loop...
  35355. * @param options A JSON object containing values named as the object properties
  35356. */
  35357. updateOptions(options: ISoundOptions): void;
  35358. private _createSpatialParameters;
  35359. private _updateSpatialParameters;
  35360. /**
  35361. * Switch the panning model to HRTF:
  35362. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35363. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35364. */
  35365. switchPanningModelToHRTF(): void;
  35366. /**
  35367. * Switch the panning model to Equal Power:
  35368. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35369. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35370. */
  35371. switchPanningModelToEqualPower(): void;
  35372. private _switchPanningModel;
  35373. /**
  35374. * Connect this sound to a sound track audio node like gain...
  35375. * @param soundTrackAudioNode the sound track audio node to connect to
  35376. */
  35377. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35378. /**
  35379. * Transform this sound into a directional source
  35380. * @param coneInnerAngle Size of the inner cone in degree
  35381. * @param coneOuterAngle Size of the outer cone in degree
  35382. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35383. */
  35384. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35385. /**
  35386. * Gets or sets the inner angle for the directional cone.
  35387. */
  35388. /**
  35389. * Gets or sets the inner angle for the directional cone.
  35390. */
  35391. directionalConeInnerAngle: number;
  35392. /**
  35393. * Gets or sets the outer angle for the directional cone.
  35394. */
  35395. /**
  35396. * Gets or sets the outer angle for the directional cone.
  35397. */
  35398. directionalConeOuterAngle: number;
  35399. /**
  35400. * Sets the position of the emitter if spatial sound is enabled
  35401. * @param newPosition Defines the new posisiton
  35402. */
  35403. setPosition(newPosition: Vector3): void;
  35404. /**
  35405. * Sets the local direction of the emitter if spatial sound is enabled
  35406. * @param newLocalDirection Defines the new local direction
  35407. */
  35408. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35409. private _updateDirection;
  35410. /** @hidden */
  35411. updateDistanceFromListener(): void;
  35412. /**
  35413. * Sets a new custom attenuation function for the sound.
  35414. * @param callback Defines the function used for the attenuation
  35415. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35416. */
  35417. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35418. /**
  35419. * Play the sound
  35420. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35421. * @param offset (optional) Start the sound at a specific time in seconds
  35422. * @param length (optional) Sound duration (in seconds)
  35423. */
  35424. play(time?: number, offset?: number, length?: number): void;
  35425. private _onended;
  35426. /**
  35427. * Stop the sound
  35428. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35429. */
  35430. stop(time?: number): void;
  35431. /**
  35432. * Put the sound in pause
  35433. */
  35434. pause(): void;
  35435. /**
  35436. * Sets a dedicated volume for this sounds
  35437. * @param newVolume Define the new volume of the sound
  35438. * @param time Define time for gradual change to new volume
  35439. */
  35440. setVolume(newVolume: number, time?: number): void;
  35441. /**
  35442. * Set the sound play back rate
  35443. * @param newPlaybackRate Define the playback rate the sound should be played at
  35444. */
  35445. setPlaybackRate(newPlaybackRate: number): void;
  35446. /**
  35447. * Gets the volume of the sound.
  35448. * @returns the volume of the sound
  35449. */
  35450. getVolume(): number;
  35451. /**
  35452. * Attach the sound to a dedicated mesh
  35453. * @param transformNode The transform node to connect the sound with
  35454. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35455. */
  35456. attachToMesh(transformNode: TransformNode): void;
  35457. /**
  35458. * Detach the sound from the previously attached mesh
  35459. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35460. */
  35461. detachFromMesh(): void;
  35462. private _onRegisterAfterWorldMatrixUpdate;
  35463. /**
  35464. * Clone the current sound in the scene.
  35465. * @returns the new sound clone
  35466. */
  35467. clone(): Nullable<Sound>;
  35468. /**
  35469. * Gets the current underlying audio buffer containing the data
  35470. * @returns the audio buffer
  35471. */
  35472. getAudioBuffer(): Nullable<AudioBuffer>;
  35473. /**
  35474. * Serializes the Sound in a JSON representation
  35475. * @returns the JSON representation of the sound
  35476. */
  35477. serialize(): any;
  35478. /**
  35479. * Parse a JSON representation of a sound to innstantiate in a given scene
  35480. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35481. * @param scene Define the scene the new parsed sound should be created in
  35482. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35483. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35484. * @returns the newly parsed sound
  35485. */
  35486. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35487. }
  35488. }
  35489. declare module "babylonjs/Actions/directAudioActions" {
  35490. import { Action } from "babylonjs/Actions/action";
  35491. import { Condition } from "babylonjs/Actions/condition";
  35492. import { Sound } from "babylonjs/Audio/sound";
  35493. /**
  35494. * This defines an action helpful to play a defined sound on a triggered action.
  35495. */
  35496. export class PlaySoundAction extends Action {
  35497. private _sound;
  35498. /**
  35499. * Instantiate the action
  35500. * @param triggerOptions defines the trigger options
  35501. * @param sound defines the sound to play
  35502. * @param condition defines the trigger related conditions
  35503. */
  35504. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35505. /** @hidden */
  35506. _prepare(): void;
  35507. /**
  35508. * Execute the action and play the sound.
  35509. */
  35510. execute(): void;
  35511. /**
  35512. * Serializes the actions and its related information.
  35513. * @param parent defines the object to serialize in
  35514. * @returns the serialized object
  35515. */
  35516. serialize(parent: any): any;
  35517. }
  35518. /**
  35519. * This defines an action helpful to stop a defined sound on a triggered action.
  35520. */
  35521. export class StopSoundAction extends Action {
  35522. private _sound;
  35523. /**
  35524. * Instantiate the action
  35525. * @param triggerOptions defines the trigger options
  35526. * @param sound defines the sound to stop
  35527. * @param condition defines the trigger related conditions
  35528. */
  35529. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35530. /** @hidden */
  35531. _prepare(): void;
  35532. /**
  35533. * Execute the action and stop the sound.
  35534. */
  35535. execute(): void;
  35536. /**
  35537. * Serializes the actions and its related information.
  35538. * @param parent defines the object to serialize in
  35539. * @returns the serialized object
  35540. */
  35541. serialize(parent: any): any;
  35542. }
  35543. }
  35544. declare module "babylonjs/Actions/interpolateValueAction" {
  35545. import { Action } from "babylonjs/Actions/action";
  35546. import { Condition } from "babylonjs/Actions/condition";
  35547. import { Observable } from "babylonjs/Misc/observable";
  35548. /**
  35549. * This defines an action responsible to change the value of a property
  35550. * by interpolating between its current value and the newly set one once triggered.
  35551. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35552. */
  35553. export class InterpolateValueAction extends Action {
  35554. /**
  35555. * Defines the path of the property where the value should be interpolated
  35556. */
  35557. propertyPath: string;
  35558. /**
  35559. * Defines the target value at the end of the interpolation.
  35560. */
  35561. value: any;
  35562. /**
  35563. * Defines the time it will take for the property to interpolate to the value.
  35564. */
  35565. duration: number;
  35566. /**
  35567. * Defines if the other scene animations should be stopped when the action has been triggered
  35568. */
  35569. stopOtherAnimations?: boolean;
  35570. /**
  35571. * Defines a callback raised once the interpolation animation has been done.
  35572. */
  35573. onInterpolationDone?: () => void;
  35574. /**
  35575. * Observable triggered once the interpolation animation has been done.
  35576. */
  35577. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35578. private _target;
  35579. private _effectiveTarget;
  35580. private _property;
  35581. /**
  35582. * Instantiate the action
  35583. * @param triggerOptions defines the trigger options
  35584. * @param target defines the object containing the value to interpolate
  35585. * @param propertyPath defines the path to the property in the target object
  35586. * @param value defines the target value at the end of the interpolation
  35587. * @param duration deines the time it will take for the property to interpolate to the value.
  35588. * @param condition defines the trigger related conditions
  35589. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35590. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35591. */
  35592. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35593. /** @hidden */
  35594. _prepare(): void;
  35595. /**
  35596. * Execute the action starts the value interpolation.
  35597. */
  35598. execute(): void;
  35599. /**
  35600. * Serializes the actions and its related information.
  35601. * @param parent defines the object to serialize in
  35602. * @returns the serialized object
  35603. */
  35604. serialize(parent: any): any;
  35605. }
  35606. }
  35607. declare module "babylonjs/Actions/index" {
  35608. export * from "babylonjs/Actions/action";
  35609. export * from "babylonjs/Actions/actionEvent";
  35610. export * from "babylonjs/Actions/actionManager";
  35611. export * from "babylonjs/Actions/condition";
  35612. export * from "babylonjs/Actions/directActions";
  35613. export * from "babylonjs/Actions/directAudioActions";
  35614. export * from "babylonjs/Actions/interpolateValueAction";
  35615. }
  35616. declare module "babylonjs/Animations/index" {
  35617. export * from "babylonjs/Animations/animatable";
  35618. export * from "babylonjs/Animations/animation";
  35619. export * from "babylonjs/Animations/animationGroup";
  35620. export * from "babylonjs/Animations/animationPropertiesOverride";
  35621. export * from "babylonjs/Animations/easing";
  35622. export * from "babylonjs/Animations/runtimeAnimation";
  35623. export * from "babylonjs/Animations/animationEvent";
  35624. export * from "babylonjs/Animations/animationGroup";
  35625. export * from "babylonjs/Animations/animationKey";
  35626. export * from "babylonjs/Animations/animationRange";
  35627. }
  35628. declare module "babylonjs/Audio/soundTrack" {
  35629. import { Sound } from "babylonjs/Audio/sound";
  35630. import { Analyser } from "babylonjs/Audio/analyser";
  35631. import { Scene } from "babylonjs/scene";
  35632. /**
  35633. * Options allowed during the creation of a sound track.
  35634. */
  35635. export interface ISoundTrackOptions {
  35636. /**
  35637. * The volume the sound track should take during creation
  35638. */
  35639. volume?: number;
  35640. /**
  35641. * Define if the sound track is the main sound track of the scene
  35642. */
  35643. mainTrack?: boolean;
  35644. }
  35645. /**
  35646. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35647. * It will be also used in a future release to apply effects on a specific track.
  35648. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35649. */
  35650. export class SoundTrack {
  35651. /**
  35652. * The unique identifier of the sound track in the scene.
  35653. */
  35654. id: number;
  35655. /**
  35656. * The list of sounds included in the sound track.
  35657. */
  35658. soundCollection: Array<Sound>;
  35659. private _outputAudioNode;
  35660. private _scene;
  35661. private _isMainTrack;
  35662. private _connectedAnalyser;
  35663. private _options;
  35664. private _isInitialized;
  35665. /**
  35666. * Creates a new sound track.
  35667. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35668. * @param scene Define the scene the sound track belongs to
  35669. * @param options
  35670. */
  35671. constructor(scene: Scene, options?: ISoundTrackOptions);
  35672. private _initializeSoundTrackAudioGraph;
  35673. /**
  35674. * Release the sound track and its associated resources
  35675. */
  35676. dispose(): void;
  35677. /**
  35678. * Adds a sound to this sound track
  35679. * @param sound define the cound to add
  35680. * @ignoreNaming
  35681. */
  35682. AddSound(sound: Sound): void;
  35683. /**
  35684. * Removes a sound to this sound track
  35685. * @param sound define the cound to remove
  35686. * @ignoreNaming
  35687. */
  35688. RemoveSound(sound: Sound): void;
  35689. /**
  35690. * Set a global volume for the full sound track.
  35691. * @param newVolume Define the new volume of the sound track
  35692. */
  35693. setVolume(newVolume: number): void;
  35694. /**
  35695. * Switch the panning model to HRTF:
  35696. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35697. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35698. */
  35699. switchPanningModelToHRTF(): void;
  35700. /**
  35701. * Switch the panning model to Equal Power:
  35702. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35703. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35704. */
  35705. switchPanningModelToEqualPower(): void;
  35706. /**
  35707. * Connect the sound track to an audio analyser allowing some amazing
  35708. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35709. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35710. * @param analyser The analyser to connect to the engine
  35711. */
  35712. connectToAnalyser(analyser: Analyser): void;
  35713. }
  35714. }
  35715. declare module "babylonjs/Audio/audioSceneComponent" {
  35716. import { Sound } from "babylonjs/Audio/sound";
  35717. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  35718. import { Nullable } from "babylonjs/types";
  35719. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  35720. import { Scene } from "babylonjs/scene";
  35721. import { AbstractScene } from "babylonjs/abstractScene";
  35722. module "babylonjs/abstractScene" {
  35723. interface AbstractScene {
  35724. /**
  35725. * The list of sounds used in the scene.
  35726. */
  35727. sounds: Nullable<Array<Sound>>;
  35728. }
  35729. }
  35730. module "babylonjs/scene" {
  35731. interface Scene {
  35732. /**
  35733. * @hidden
  35734. * Backing field
  35735. */
  35736. _mainSoundTrack: SoundTrack;
  35737. /**
  35738. * The main sound track played by the scene.
  35739. * It cotains your primary collection of sounds.
  35740. */
  35741. mainSoundTrack: SoundTrack;
  35742. /**
  35743. * The list of sound tracks added to the scene
  35744. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35745. */
  35746. soundTracks: Nullable<Array<SoundTrack>>;
  35747. /**
  35748. * Gets a sound using a given name
  35749. * @param name defines the name to search for
  35750. * @return the found sound or null if not found at all.
  35751. */
  35752. getSoundByName(name: string): Nullable<Sound>;
  35753. /**
  35754. * Gets or sets if audio support is enabled
  35755. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35756. */
  35757. audioEnabled: boolean;
  35758. /**
  35759. * Gets or sets if audio will be output to headphones
  35760. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35761. */
  35762. headphone: boolean;
  35763. }
  35764. }
  35765. /**
  35766. * Defines the sound scene component responsible to manage any sounds
  35767. * in a given scene.
  35768. */
  35769. export class AudioSceneComponent implements ISceneSerializableComponent {
  35770. /**
  35771. * The component name helpfull to identify the component in the list of scene components.
  35772. */
  35773. readonly name: string;
  35774. /**
  35775. * The scene the component belongs to.
  35776. */
  35777. scene: Scene;
  35778. private _audioEnabled;
  35779. /**
  35780. * Gets whether audio is enabled or not.
  35781. * Please use related enable/disable method to switch state.
  35782. */
  35783. readonly audioEnabled: boolean;
  35784. private _headphone;
  35785. /**
  35786. * Gets whether audio is outputing to headphone or not.
  35787. * Please use the according Switch methods to change output.
  35788. */
  35789. readonly headphone: boolean;
  35790. /**
  35791. * Creates a new instance of the component for the given scene
  35792. * @param scene Defines the scene to register the component in
  35793. */
  35794. constructor(scene: Scene);
  35795. /**
  35796. * Registers the component in a given scene
  35797. */
  35798. register(): void;
  35799. /**
  35800. * Rebuilds the elements related to this component in case of
  35801. * context lost for instance.
  35802. */
  35803. rebuild(): void;
  35804. /**
  35805. * Serializes the component data to the specified json object
  35806. * @param serializationObject The object to serialize to
  35807. */
  35808. serialize(serializationObject: any): void;
  35809. /**
  35810. * Adds all the elements from the container to the scene
  35811. * @param container the container holding the elements
  35812. */
  35813. addFromContainer(container: AbstractScene): void;
  35814. /**
  35815. * Removes all the elements in the container from the scene
  35816. * @param container contains the elements to remove
  35817. * @param dispose if the removed element should be disposed (default: false)
  35818. */
  35819. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35820. /**
  35821. * Disposes the component and the associated ressources.
  35822. */
  35823. dispose(): void;
  35824. /**
  35825. * Disables audio in the associated scene.
  35826. */
  35827. disableAudio(): void;
  35828. /**
  35829. * Enables audio in the associated scene.
  35830. */
  35831. enableAudio(): void;
  35832. /**
  35833. * Switch audio to headphone output.
  35834. */
  35835. switchAudioModeForHeadphones(): void;
  35836. /**
  35837. * Switch audio to normal speakers.
  35838. */
  35839. switchAudioModeForNormalSpeakers(): void;
  35840. private _afterRender;
  35841. }
  35842. }
  35843. declare module "babylonjs/Audio/weightedsound" {
  35844. import { Sound } from "babylonjs/Audio/sound";
  35845. /**
  35846. * Wraps one or more Sound objects and selects one with random weight for playback.
  35847. */
  35848. export class WeightedSound {
  35849. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35850. loop: boolean;
  35851. private _coneInnerAngle;
  35852. private _coneOuterAngle;
  35853. private _volume;
  35854. /** A Sound is currently playing. */
  35855. isPlaying: boolean;
  35856. /** A Sound is currently paused. */
  35857. isPaused: boolean;
  35858. private _sounds;
  35859. private _weights;
  35860. private _currentIndex?;
  35861. /**
  35862. * Creates a new WeightedSound from the list of sounds given.
  35863. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35864. * @param sounds Array of Sounds that will be selected from.
  35865. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35866. */
  35867. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35868. /**
  35869. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35870. */
  35871. /**
  35872. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35873. */
  35874. directionalConeInnerAngle: number;
  35875. /**
  35876. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35877. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35878. */
  35879. /**
  35880. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35881. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35882. */
  35883. directionalConeOuterAngle: number;
  35884. /**
  35885. * Playback volume.
  35886. */
  35887. /**
  35888. * Playback volume.
  35889. */
  35890. volume: number;
  35891. private _onended;
  35892. /**
  35893. * Suspend playback
  35894. */
  35895. pause(): void;
  35896. /**
  35897. * Stop playback
  35898. */
  35899. stop(): void;
  35900. /**
  35901. * Start playback.
  35902. * @param startOffset Position the clip head at a specific time in seconds.
  35903. */
  35904. play(startOffset?: number): void;
  35905. }
  35906. }
  35907. declare module "babylonjs/Audio/index" {
  35908. export * from "babylonjs/Audio/analyser";
  35909. export * from "babylonjs/Audio/audioEngine";
  35910. export * from "babylonjs/Audio/audioSceneComponent";
  35911. export * from "babylonjs/Audio/sound";
  35912. export * from "babylonjs/Audio/soundTrack";
  35913. export * from "babylonjs/Audio/weightedsound";
  35914. }
  35915. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35916. import { Behavior } from "babylonjs/Behaviors/behavior";
  35917. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35918. import { BackEase } from "babylonjs/Animations/easing";
  35919. /**
  35920. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35921. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35922. */
  35923. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35924. /**
  35925. * Gets the name of the behavior.
  35926. */
  35927. readonly name: string;
  35928. /**
  35929. * The easing function used by animations
  35930. */
  35931. static EasingFunction: BackEase;
  35932. /**
  35933. * The easing mode used by animations
  35934. */
  35935. static EasingMode: number;
  35936. /**
  35937. * The duration of the animation, in milliseconds
  35938. */
  35939. transitionDuration: number;
  35940. /**
  35941. * Length of the distance animated by the transition when lower radius is reached
  35942. */
  35943. lowerRadiusTransitionRange: number;
  35944. /**
  35945. * Length of the distance animated by the transition when upper radius is reached
  35946. */
  35947. upperRadiusTransitionRange: number;
  35948. private _autoTransitionRange;
  35949. /**
  35950. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35951. */
  35952. /**
  35953. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35954. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35955. */
  35956. autoTransitionRange: boolean;
  35957. private _attachedCamera;
  35958. private _onAfterCheckInputsObserver;
  35959. private _onMeshTargetChangedObserver;
  35960. /**
  35961. * Initializes the behavior.
  35962. */
  35963. init(): void;
  35964. /**
  35965. * Attaches the behavior to its arc rotate camera.
  35966. * @param camera Defines the camera to attach the behavior to
  35967. */
  35968. attach(camera: ArcRotateCamera): void;
  35969. /**
  35970. * Detaches the behavior from its current arc rotate camera.
  35971. */
  35972. detach(): void;
  35973. private _radiusIsAnimating;
  35974. private _radiusBounceTransition;
  35975. private _animatables;
  35976. private _cachedWheelPrecision;
  35977. /**
  35978. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35979. * @param radiusLimit The limit to check against.
  35980. * @return Bool to indicate if at limit.
  35981. */
  35982. private _isRadiusAtLimit;
  35983. /**
  35984. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35985. * @param radiusDelta The delta by which to animate to. Can be negative.
  35986. */
  35987. private _applyBoundRadiusAnimation;
  35988. /**
  35989. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35990. */
  35991. protected _clearAnimationLocks(): void;
  35992. /**
  35993. * Stops and removes all animations that have been applied to the camera
  35994. */
  35995. stopAllAnimations(): void;
  35996. }
  35997. }
  35998. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35999. import { Behavior } from "babylonjs/Behaviors/behavior";
  36000. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36001. import { ExponentialEase } from "babylonjs/Animations/easing";
  36002. import { Nullable } from "babylonjs/types";
  36003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36004. import { Vector3 } from "babylonjs/Maths/math";
  36005. /**
  36006. * 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.
  36007. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36008. */
  36009. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36010. /**
  36011. * Gets the name of the behavior.
  36012. */
  36013. readonly name: string;
  36014. private _mode;
  36015. private _radiusScale;
  36016. private _positionScale;
  36017. private _defaultElevation;
  36018. private _elevationReturnTime;
  36019. private _elevationReturnWaitTime;
  36020. private _zoomStopsAnimation;
  36021. private _framingTime;
  36022. /**
  36023. * The easing function used by animations
  36024. */
  36025. static EasingFunction: ExponentialEase;
  36026. /**
  36027. * The easing mode used by animations
  36028. */
  36029. static EasingMode: number;
  36030. /**
  36031. * Sets the current mode used by the behavior
  36032. */
  36033. /**
  36034. * Gets current mode used by the behavior.
  36035. */
  36036. mode: number;
  36037. /**
  36038. * Sets the scale applied to the radius (1 by default)
  36039. */
  36040. /**
  36041. * Gets the scale applied to the radius
  36042. */
  36043. radiusScale: number;
  36044. /**
  36045. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36046. */
  36047. /**
  36048. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36049. */
  36050. positionScale: number;
  36051. /**
  36052. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36053. * behaviour is triggered, in radians.
  36054. */
  36055. /**
  36056. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36057. * behaviour is triggered, in radians.
  36058. */
  36059. defaultElevation: number;
  36060. /**
  36061. * Sets the time (in milliseconds) taken to return to the default beta position.
  36062. * Negative value indicates camera should not return to default.
  36063. */
  36064. /**
  36065. * Gets the time (in milliseconds) taken to return to the default beta position.
  36066. * Negative value indicates camera should not return to default.
  36067. */
  36068. elevationReturnTime: number;
  36069. /**
  36070. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36071. */
  36072. /**
  36073. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36074. */
  36075. elevationReturnWaitTime: number;
  36076. /**
  36077. * Sets the flag that indicates if user zooming should stop animation.
  36078. */
  36079. /**
  36080. * Gets the flag that indicates if user zooming should stop animation.
  36081. */
  36082. zoomStopsAnimation: boolean;
  36083. /**
  36084. * Sets the transition time when framing the mesh, in milliseconds
  36085. */
  36086. /**
  36087. * Gets the transition time when framing the mesh, in milliseconds
  36088. */
  36089. framingTime: number;
  36090. /**
  36091. * Define if the behavior should automatically change the configured
  36092. * camera limits and sensibilities.
  36093. */
  36094. autoCorrectCameraLimitsAndSensibility: boolean;
  36095. private _onPrePointerObservableObserver;
  36096. private _onAfterCheckInputsObserver;
  36097. private _onMeshTargetChangedObserver;
  36098. private _attachedCamera;
  36099. private _isPointerDown;
  36100. private _lastInteractionTime;
  36101. /**
  36102. * Initializes the behavior.
  36103. */
  36104. init(): void;
  36105. /**
  36106. * Attaches the behavior to its arc rotate camera.
  36107. * @param camera Defines the camera to attach the behavior to
  36108. */
  36109. attach(camera: ArcRotateCamera): void;
  36110. /**
  36111. * Detaches the behavior from its current arc rotate camera.
  36112. */
  36113. detach(): void;
  36114. private _animatables;
  36115. private _betaIsAnimating;
  36116. private _betaTransition;
  36117. private _radiusTransition;
  36118. private _vectorTransition;
  36119. /**
  36120. * Targets the given mesh and updates zoom level accordingly.
  36121. * @param mesh The mesh to target.
  36122. * @param radius Optional. If a cached radius position already exists, overrides default.
  36123. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36124. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36125. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36126. */
  36127. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36128. /**
  36129. * Targets the given mesh with its children and updates zoom level accordingly.
  36130. * @param mesh The mesh to target.
  36131. * @param radius Optional. If a cached radius position already exists, overrides default.
  36132. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36133. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36134. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36135. */
  36136. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36137. /**
  36138. * Targets the given meshes with their children and updates zoom level accordingly.
  36139. * @param meshes The mesh to target.
  36140. * @param radius Optional. If a cached radius position already exists, overrides default.
  36141. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36142. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36143. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36144. */
  36145. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36146. /**
  36147. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36148. * @param minimumWorld Determines the smaller position of the bounding box extend
  36149. * @param maximumWorld Determines the bigger position of the bounding box extend
  36150. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36151. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36152. */
  36153. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36154. /**
  36155. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36156. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36157. * frustum width.
  36158. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36159. * to fully enclose the mesh in the viewing frustum.
  36160. */
  36161. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36162. /**
  36163. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36164. * is automatically returned to its default position (expected to be above ground plane).
  36165. */
  36166. private _maintainCameraAboveGround;
  36167. /**
  36168. * Returns the frustum slope based on the canvas ratio and camera FOV
  36169. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36170. */
  36171. private _getFrustumSlope;
  36172. /**
  36173. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36174. */
  36175. private _clearAnimationLocks;
  36176. /**
  36177. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36178. */
  36179. private _applyUserInteraction;
  36180. /**
  36181. * Stops and removes all animations that have been applied to the camera
  36182. */
  36183. stopAllAnimations(): void;
  36184. /**
  36185. * Gets a value indicating if the user is moving the camera
  36186. */
  36187. readonly isUserIsMoving: boolean;
  36188. /**
  36189. * The camera can move all the way towards the mesh.
  36190. */
  36191. static IgnoreBoundsSizeMode: number;
  36192. /**
  36193. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36194. */
  36195. static FitFrustumSidesMode: number;
  36196. }
  36197. }
  36198. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36199. import { Nullable } from "babylonjs/types";
  36200. import { Camera } from "babylonjs/Cameras/camera";
  36201. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36202. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36203. /**
  36204. * Base class for Camera Pointer Inputs.
  36205. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36206. * for example usage.
  36207. */
  36208. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36209. /**
  36210. * Defines the camera the input is attached to.
  36211. */
  36212. abstract camera: Camera;
  36213. /**
  36214. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36215. */
  36216. protected _altKey: boolean;
  36217. protected _ctrlKey: boolean;
  36218. protected _metaKey: boolean;
  36219. protected _shiftKey: boolean;
  36220. /**
  36221. * Which mouse buttons were pressed at time of last mouse event.
  36222. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36223. */
  36224. protected _buttonsPressed: number;
  36225. /**
  36226. * Defines the buttons associated with the input to handle camera move.
  36227. */
  36228. buttons: number[];
  36229. /**
  36230. * Attach the input controls to a specific dom element to get the input from.
  36231. * @param element Defines the element the controls should be listened from
  36232. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36233. */
  36234. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36235. /**
  36236. * Detach the current controls from the specified dom element.
  36237. * @param element Defines the element to stop listening the inputs from
  36238. */
  36239. detachControl(element: Nullable<HTMLElement>): void;
  36240. /**
  36241. * Gets the class name of the current input.
  36242. * @returns the class name
  36243. */
  36244. getClassName(): string;
  36245. /**
  36246. * Get the friendly name associated with the input class.
  36247. * @returns the input friendly name
  36248. */
  36249. getSimpleName(): string;
  36250. /**
  36251. * Called on pointer POINTERDOUBLETAP event.
  36252. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36253. */
  36254. protected onDoubleTap(type: string): void;
  36255. /**
  36256. * Called on pointer POINTERMOVE event if only a single touch is active.
  36257. * Override this method to provide functionality.
  36258. */
  36259. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36260. /**
  36261. * Called on pointer POINTERMOVE event if multiple touches are active.
  36262. * Override this method to provide functionality.
  36263. */
  36264. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36265. /**
  36266. * Called on JS contextmenu event.
  36267. * Override this method to provide functionality.
  36268. */
  36269. protected onContextMenu(evt: PointerEvent): void;
  36270. /**
  36271. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36272. * press.
  36273. * Override this method to provide functionality.
  36274. */
  36275. protected onButtonDown(evt: PointerEvent): void;
  36276. /**
  36277. * Called each time a new POINTERUP event occurs. Ie, for each button
  36278. * release.
  36279. * Override this method to provide functionality.
  36280. */
  36281. protected onButtonUp(evt: PointerEvent): void;
  36282. /**
  36283. * Called when window becomes inactive.
  36284. * Override this method to provide functionality.
  36285. */
  36286. protected onLostFocus(): void;
  36287. private _pointerInput;
  36288. private _observer;
  36289. private _onLostFocus;
  36290. private pointA;
  36291. private pointB;
  36292. }
  36293. }
  36294. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36295. import { Nullable } from "babylonjs/types";
  36296. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36297. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36298. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36299. /**
  36300. * Manage the pointers inputs to control an arc rotate camera.
  36301. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36302. */
  36303. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36304. /**
  36305. * Defines the camera the input is attached to.
  36306. */
  36307. camera: ArcRotateCamera;
  36308. /**
  36309. * Gets the class name of the current input.
  36310. * @returns the class name
  36311. */
  36312. getClassName(): string;
  36313. /**
  36314. * Defines the buttons associated with the input to handle camera move.
  36315. */
  36316. buttons: number[];
  36317. /**
  36318. * Defines the pointer angular sensibility along the X axis or how fast is
  36319. * the camera rotating.
  36320. */
  36321. angularSensibilityX: number;
  36322. /**
  36323. * Defines the pointer angular sensibility along the Y axis or how fast is
  36324. * the camera rotating.
  36325. */
  36326. angularSensibilityY: number;
  36327. /**
  36328. * Defines the pointer pinch precision or how fast is the camera zooming.
  36329. */
  36330. pinchPrecision: number;
  36331. /**
  36332. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36333. * from 0.
  36334. * It defines the percentage of current camera.radius to use as delta when
  36335. * pinch zoom is used.
  36336. */
  36337. pinchDeltaPercentage: number;
  36338. /**
  36339. * Defines the pointer panning sensibility or how fast is the camera moving.
  36340. */
  36341. panningSensibility: number;
  36342. /**
  36343. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36344. */
  36345. multiTouchPanning: boolean;
  36346. /**
  36347. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36348. * zoom (pinch) through multitouch.
  36349. */
  36350. multiTouchPanAndZoom: boolean;
  36351. /**
  36352. * Revers pinch action direction.
  36353. */
  36354. pinchInwards: boolean;
  36355. private _isPanClick;
  36356. private _twoFingerActivityCount;
  36357. private _isPinching;
  36358. /**
  36359. * Called on pointer POINTERMOVE event if only a single touch is active.
  36360. */
  36361. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36362. /**
  36363. * Called on pointer POINTERDOUBLETAP event.
  36364. */
  36365. protected onDoubleTap(type: string): void;
  36366. /**
  36367. * Called on pointer POINTERMOVE event if multiple touches are active.
  36368. */
  36369. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36370. /**
  36371. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36372. * press.
  36373. */
  36374. protected onButtonDown(evt: PointerEvent): void;
  36375. /**
  36376. * Called each time a new POINTERUP event occurs. Ie, for each button
  36377. * release.
  36378. */
  36379. protected onButtonUp(evt: PointerEvent): void;
  36380. /**
  36381. * Called when window becomes inactive.
  36382. */
  36383. protected onLostFocus(): void;
  36384. }
  36385. }
  36386. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36387. import { Nullable } from "babylonjs/types";
  36388. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36389. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36390. /**
  36391. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36392. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36393. */
  36394. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36395. /**
  36396. * Defines the camera the input is attached to.
  36397. */
  36398. camera: ArcRotateCamera;
  36399. /**
  36400. * Defines the list of key codes associated with the up action (increase alpha)
  36401. */
  36402. keysUp: number[];
  36403. /**
  36404. * Defines the list of key codes associated with the down action (decrease alpha)
  36405. */
  36406. keysDown: number[];
  36407. /**
  36408. * Defines the list of key codes associated with the left action (increase beta)
  36409. */
  36410. keysLeft: number[];
  36411. /**
  36412. * Defines the list of key codes associated with the right action (decrease beta)
  36413. */
  36414. keysRight: number[];
  36415. /**
  36416. * Defines the list of key codes associated with the reset action.
  36417. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36418. */
  36419. keysReset: number[];
  36420. /**
  36421. * Defines the panning sensibility of the inputs.
  36422. * (How fast is the camera paning)
  36423. */
  36424. panningSensibility: number;
  36425. /**
  36426. * Defines the zooming sensibility of the inputs.
  36427. * (How fast is the camera zooming)
  36428. */
  36429. zoomingSensibility: number;
  36430. /**
  36431. * Defines wether maintaining the alt key down switch the movement mode from
  36432. * orientation to zoom.
  36433. */
  36434. useAltToZoom: boolean;
  36435. /**
  36436. * Rotation speed of the camera
  36437. */
  36438. angularSpeed: number;
  36439. private _keys;
  36440. private _ctrlPressed;
  36441. private _altPressed;
  36442. private _onCanvasBlurObserver;
  36443. private _onKeyboardObserver;
  36444. private _engine;
  36445. private _scene;
  36446. /**
  36447. * Attach the input controls to a specific dom element to get the input from.
  36448. * @param element Defines the element the controls should be listened from
  36449. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36450. */
  36451. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36452. /**
  36453. * Detach the current controls from the specified dom element.
  36454. * @param element Defines the element to stop listening the inputs from
  36455. */
  36456. detachControl(element: Nullable<HTMLElement>): void;
  36457. /**
  36458. * Update the current camera state depending on the inputs that have been used this frame.
  36459. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36460. */
  36461. checkInputs(): void;
  36462. /**
  36463. * Gets the class name of the current intput.
  36464. * @returns the class name
  36465. */
  36466. getClassName(): string;
  36467. /**
  36468. * Get the friendly name associated with the input class.
  36469. * @returns the input friendly name
  36470. */
  36471. getSimpleName(): string;
  36472. }
  36473. }
  36474. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36475. import { Nullable } from "babylonjs/types";
  36476. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36477. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36478. /**
  36479. * Manage the mouse wheel inputs to control an arc rotate camera.
  36480. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36481. */
  36482. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36483. /**
  36484. * Defines the camera the input is attached to.
  36485. */
  36486. camera: ArcRotateCamera;
  36487. /**
  36488. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36489. */
  36490. wheelPrecision: number;
  36491. /**
  36492. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36493. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36494. */
  36495. wheelDeltaPercentage: number;
  36496. private _wheel;
  36497. private _observer;
  36498. private computeDeltaFromMouseWheelLegacyEvent;
  36499. /**
  36500. * Attach the input controls to a specific dom element to get the input from.
  36501. * @param element Defines the element the controls should be listened from
  36502. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36503. */
  36504. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36505. /**
  36506. * Detach the current controls from the specified dom element.
  36507. * @param element Defines the element to stop listening the inputs from
  36508. */
  36509. detachControl(element: Nullable<HTMLElement>): void;
  36510. /**
  36511. * Gets the class name of the current intput.
  36512. * @returns the class name
  36513. */
  36514. getClassName(): string;
  36515. /**
  36516. * Get the friendly name associated with the input class.
  36517. * @returns the input friendly name
  36518. */
  36519. getSimpleName(): string;
  36520. }
  36521. }
  36522. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36523. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36524. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36525. /**
  36526. * Default Inputs manager for the ArcRotateCamera.
  36527. * It groups all the default supported inputs for ease of use.
  36528. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36529. */
  36530. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36531. /**
  36532. * Instantiates a new ArcRotateCameraInputsManager.
  36533. * @param camera Defines the camera the inputs belong to
  36534. */
  36535. constructor(camera: ArcRotateCamera);
  36536. /**
  36537. * Add mouse wheel input support to the input manager.
  36538. * @returns the current input manager
  36539. */
  36540. addMouseWheel(): ArcRotateCameraInputsManager;
  36541. /**
  36542. * Add pointers input support to the input manager.
  36543. * @returns the current input manager
  36544. */
  36545. addPointers(): ArcRotateCameraInputsManager;
  36546. /**
  36547. * Add keyboard input support to the input manager.
  36548. * @returns the current input manager
  36549. */
  36550. addKeyboard(): ArcRotateCameraInputsManager;
  36551. }
  36552. }
  36553. declare module "babylonjs/Cameras/arcRotateCamera" {
  36554. import { Observable } from "babylonjs/Misc/observable";
  36555. import { Nullable } from "babylonjs/types";
  36556. import { Scene } from "babylonjs/scene";
  36557. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  36558. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36559. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36560. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36561. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36562. import { Camera } from "babylonjs/Cameras/camera";
  36563. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36564. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36565. import { Collider } from "babylonjs/Collisions/collider";
  36566. /**
  36567. * This represents an orbital type of camera.
  36568. *
  36569. * 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.
  36570. * 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.
  36571. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36572. */
  36573. export class ArcRotateCamera extends TargetCamera {
  36574. /**
  36575. * Defines the rotation angle of the camera along the longitudinal axis.
  36576. */
  36577. alpha: number;
  36578. /**
  36579. * Defines the rotation angle of the camera along the latitudinal axis.
  36580. */
  36581. beta: number;
  36582. /**
  36583. * Defines the radius of the camera from it s target point.
  36584. */
  36585. radius: number;
  36586. protected _target: Vector3;
  36587. protected _targetHost: Nullable<AbstractMesh>;
  36588. /**
  36589. * Defines the target point of the camera.
  36590. * The camera looks towards it form the radius distance.
  36591. */
  36592. target: Vector3;
  36593. /**
  36594. * Define the current local position of the camera in the scene
  36595. */
  36596. position: Vector3;
  36597. protected _upVector: Vector3;
  36598. protected _upToYMatrix: Matrix;
  36599. protected _YToUpMatrix: Matrix;
  36600. /**
  36601. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36602. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36603. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36604. */
  36605. upVector: Vector3;
  36606. /**
  36607. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36608. */
  36609. setMatUp(): void;
  36610. /**
  36611. * Current inertia value on the longitudinal axis.
  36612. * The bigger this number the longer it will take for the camera to stop.
  36613. */
  36614. inertialAlphaOffset: number;
  36615. /**
  36616. * Current inertia value on the latitudinal axis.
  36617. * The bigger this number the longer it will take for the camera to stop.
  36618. */
  36619. inertialBetaOffset: number;
  36620. /**
  36621. * Current inertia value on the radius axis.
  36622. * The bigger this number the longer it will take for the camera to stop.
  36623. */
  36624. inertialRadiusOffset: number;
  36625. /**
  36626. * Minimum allowed angle on the longitudinal axis.
  36627. * This can help limiting how the Camera is able to move in the scene.
  36628. */
  36629. lowerAlphaLimit: Nullable<number>;
  36630. /**
  36631. * Maximum allowed angle on the longitudinal axis.
  36632. * This can help limiting how the Camera is able to move in the scene.
  36633. */
  36634. upperAlphaLimit: Nullable<number>;
  36635. /**
  36636. * Minimum allowed angle on the latitudinal axis.
  36637. * This can help limiting how the Camera is able to move in the scene.
  36638. */
  36639. lowerBetaLimit: number;
  36640. /**
  36641. * Maximum allowed angle on the latitudinal axis.
  36642. * This can help limiting how the Camera is able to move in the scene.
  36643. */
  36644. upperBetaLimit: number;
  36645. /**
  36646. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36647. * This can help limiting how the Camera is able to move in the scene.
  36648. */
  36649. lowerRadiusLimit: Nullable<number>;
  36650. /**
  36651. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36652. * This can help limiting how the Camera is able to move in the scene.
  36653. */
  36654. upperRadiusLimit: Nullable<number>;
  36655. /**
  36656. * Defines the current inertia value used during panning of the camera along the X axis.
  36657. */
  36658. inertialPanningX: number;
  36659. /**
  36660. * Defines the current inertia value used during panning of the camera along the Y axis.
  36661. */
  36662. inertialPanningY: number;
  36663. /**
  36664. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36665. * Basically if your fingers moves away from more than this distance you will be considered
  36666. * in pinch mode.
  36667. */
  36668. pinchToPanMaxDistance: number;
  36669. /**
  36670. * Defines the maximum distance the camera can pan.
  36671. * This could help keeping the cammera always in your scene.
  36672. */
  36673. panningDistanceLimit: Nullable<number>;
  36674. /**
  36675. * Defines the target of the camera before paning.
  36676. */
  36677. panningOriginTarget: Vector3;
  36678. /**
  36679. * Defines the value of the inertia used during panning.
  36680. * 0 would mean stop inertia and one would mean no decelleration at all.
  36681. */
  36682. panningInertia: number;
  36683. /**
  36684. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36685. */
  36686. angularSensibilityX: number;
  36687. /**
  36688. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36689. */
  36690. angularSensibilityY: number;
  36691. /**
  36692. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36693. */
  36694. pinchPrecision: number;
  36695. /**
  36696. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36697. * It will be used instead of pinchDeltaPrecision if different from 0.
  36698. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36699. */
  36700. pinchDeltaPercentage: number;
  36701. /**
  36702. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36703. */
  36704. panningSensibility: number;
  36705. /**
  36706. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36707. */
  36708. keysUp: number[];
  36709. /**
  36710. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36711. */
  36712. keysDown: number[];
  36713. /**
  36714. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36715. */
  36716. keysLeft: number[];
  36717. /**
  36718. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36719. */
  36720. keysRight: number[];
  36721. /**
  36722. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36723. */
  36724. wheelPrecision: number;
  36725. /**
  36726. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36727. * It will be used instead of pinchDeltaPrecision if different from 0.
  36728. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36729. */
  36730. wheelDeltaPercentage: number;
  36731. /**
  36732. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36733. */
  36734. zoomOnFactor: number;
  36735. /**
  36736. * Defines a screen offset for the camera position.
  36737. */
  36738. targetScreenOffset: Vector2;
  36739. /**
  36740. * Allows the camera to be completely reversed.
  36741. * If false the camera can not arrive upside down.
  36742. */
  36743. allowUpsideDown: boolean;
  36744. /**
  36745. * Define if double tap/click is used to restore the previously saved state of the camera.
  36746. */
  36747. useInputToRestoreState: boolean;
  36748. /** @hidden */
  36749. _viewMatrix: Matrix;
  36750. /** @hidden */
  36751. _useCtrlForPanning: boolean;
  36752. /** @hidden */
  36753. _panningMouseButton: number;
  36754. /**
  36755. * Defines the input associated to the camera.
  36756. */
  36757. inputs: ArcRotateCameraInputsManager;
  36758. /** @hidden */
  36759. _reset: () => void;
  36760. /**
  36761. * Defines the allowed panning axis.
  36762. */
  36763. panningAxis: Vector3;
  36764. protected _localDirection: Vector3;
  36765. protected _transformedDirection: Vector3;
  36766. private _bouncingBehavior;
  36767. /**
  36768. * Gets the bouncing behavior of the camera if it has been enabled.
  36769. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36770. */
  36771. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36772. /**
  36773. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36774. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36775. */
  36776. useBouncingBehavior: boolean;
  36777. private _framingBehavior;
  36778. /**
  36779. * Gets the framing behavior of the camera if it has been enabled.
  36780. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36781. */
  36782. readonly framingBehavior: Nullable<FramingBehavior>;
  36783. /**
  36784. * Defines if the framing behavior of the camera is enabled on the camera.
  36785. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36786. */
  36787. useFramingBehavior: boolean;
  36788. private _autoRotationBehavior;
  36789. /**
  36790. * Gets the auto rotation behavior of the camera if it has been enabled.
  36791. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36792. */
  36793. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36794. /**
  36795. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36796. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36797. */
  36798. useAutoRotationBehavior: boolean;
  36799. /**
  36800. * Observable triggered when the mesh target has been changed on the camera.
  36801. */
  36802. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36803. /**
  36804. * Event raised when the camera is colliding with a mesh.
  36805. */
  36806. onCollide: (collidedMesh: AbstractMesh) => void;
  36807. /**
  36808. * Defines whether the camera should check collision with the objects oh the scene.
  36809. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36810. */
  36811. checkCollisions: boolean;
  36812. /**
  36813. * Defines the collision radius of the camera.
  36814. * This simulates a sphere around the camera.
  36815. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36816. */
  36817. collisionRadius: Vector3;
  36818. protected _collider: Collider;
  36819. protected _previousPosition: Vector3;
  36820. protected _collisionVelocity: Vector3;
  36821. protected _newPosition: Vector3;
  36822. protected _previousAlpha: number;
  36823. protected _previousBeta: number;
  36824. protected _previousRadius: number;
  36825. protected _collisionTriggered: boolean;
  36826. protected _targetBoundingCenter: Nullable<Vector3>;
  36827. private _computationVector;
  36828. /**
  36829. * Instantiates a new ArcRotateCamera in a given scene
  36830. * @param name Defines the name of the camera
  36831. * @param alpha Defines the camera rotation along the logitudinal axis
  36832. * @param beta Defines the camera rotation along the latitudinal axis
  36833. * @param radius Defines the camera distance from its target
  36834. * @param target Defines the camera target
  36835. * @param scene Defines the scene the camera belongs to
  36836. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36837. */
  36838. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36839. /** @hidden */
  36840. _initCache(): void;
  36841. /** @hidden */
  36842. _updateCache(ignoreParentClass?: boolean): void;
  36843. protected _getTargetPosition(): Vector3;
  36844. private _storedAlpha;
  36845. private _storedBeta;
  36846. private _storedRadius;
  36847. private _storedTarget;
  36848. /**
  36849. * Stores the current state of the camera (alpha, beta, radius and target)
  36850. * @returns the camera itself
  36851. */
  36852. storeState(): Camera;
  36853. /**
  36854. * @hidden
  36855. * Restored camera state. You must call storeState() first
  36856. */
  36857. _restoreStateValues(): boolean;
  36858. /** @hidden */
  36859. _isSynchronizedViewMatrix(): boolean;
  36860. /**
  36861. * Attached controls to the current camera.
  36862. * @param element Defines the element the controls should be listened from
  36863. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36864. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36865. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36866. */
  36867. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36868. /**
  36869. * Detach the current controls from the camera.
  36870. * The camera will stop reacting to inputs.
  36871. * @param element Defines the element to stop listening the inputs from
  36872. */
  36873. detachControl(element: HTMLElement): void;
  36874. /** @hidden */
  36875. _checkInputs(): void;
  36876. protected _checkLimits(): void;
  36877. /**
  36878. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36879. */
  36880. rebuildAnglesAndRadius(): void;
  36881. /**
  36882. * Use a position to define the current camera related information like aplha, beta and radius
  36883. * @param position Defines the position to set the camera at
  36884. */
  36885. setPosition(position: Vector3): void;
  36886. /**
  36887. * Defines the target the camera should look at.
  36888. * This will automatically adapt alpha beta and radius to fit within the new target.
  36889. * @param target Defines the new target as a Vector or a mesh
  36890. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36891. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36892. */
  36893. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36894. /** @hidden */
  36895. _getViewMatrix(): Matrix;
  36896. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36897. /**
  36898. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36899. * @param meshes Defines the mesh to zoom on
  36900. * @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)
  36901. */
  36902. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36903. /**
  36904. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36905. * The target will be changed but the radius
  36906. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36907. * @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)
  36908. */
  36909. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36910. min: Vector3;
  36911. max: Vector3;
  36912. distance: number;
  36913. }, doNotUpdateMaxZ?: boolean): void;
  36914. /**
  36915. * @override
  36916. * Override Camera.createRigCamera
  36917. */
  36918. createRigCamera(name: string, cameraIndex: number): Camera;
  36919. /**
  36920. * @hidden
  36921. * @override
  36922. * Override Camera._updateRigCameras
  36923. */
  36924. _updateRigCameras(): void;
  36925. /**
  36926. * Destroy the camera and release the current resources hold by it.
  36927. */
  36928. dispose(): void;
  36929. /**
  36930. * Gets the current object class name.
  36931. * @return the class name
  36932. */
  36933. getClassName(): string;
  36934. }
  36935. }
  36936. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36937. import { Behavior } from "babylonjs/Behaviors/behavior";
  36938. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36939. /**
  36940. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36941. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36942. */
  36943. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36944. /**
  36945. * Gets the name of the behavior.
  36946. */
  36947. readonly name: string;
  36948. private _zoomStopsAnimation;
  36949. private _idleRotationSpeed;
  36950. private _idleRotationWaitTime;
  36951. private _idleRotationSpinupTime;
  36952. /**
  36953. * Sets the flag that indicates if user zooming should stop animation.
  36954. */
  36955. /**
  36956. * Gets the flag that indicates if user zooming should stop animation.
  36957. */
  36958. zoomStopsAnimation: boolean;
  36959. /**
  36960. * Sets the default speed at which the camera rotates around the model.
  36961. */
  36962. /**
  36963. * Gets the default speed at which the camera rotates around the model.
  36964. */
  36965. idleRotationSpeed: number;
  36966. /**
  36967. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36968. */
  36969. /**
  36970. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36971. */
  36972. idleRotationWaitTime: number;
  36973. /**
  36974. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36975. */
  36976. /**
  36977. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36978. */
  36979. idleRotationSpinupTime: number;
  36980. /**
  36981. * Gets a value indicating if the camera is currently rotating because of this behavior
  36982. */
  36983. readonly rotationInProgress: boolean;
  36984. private _onPrePointerObservableObserver;
  36985. private _onAfterCheckInputsObserver;
  36986. private _attachedCamera;
  36987. private _isPointerDown;
  36988. private _lastFrameTime;
  36989. private _lastInteractionTime;
  36990. private _cameraRotationSpeed;
  36991. /**
  36992. * Initializes the behavior.
  36993. */
  36994. init(): void;
  36995. /**
  36996. * Attaches the behavior to its arc rotate camera.
  36997. * @param camera Defines the camera to attach the behavior to
  36998. */
  36999. attach(camera: ArcRotateCamera): void;
  37000. /**
  37001. * Detaches the behavior from its current arc rotate camera.
  37002. */
  37003. detach(): void;
  37004. /**
  37005. * Returns true if user is scrolling.
  37006. * @return true if user is scrolling.
  37007. */
  37008. private _userIsZooming;
  37009. private _lastFrameRadius;
  37010. private _shouldAnimationStopForInteraction;
  37011. /**
  37012. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37013. */
  37014. private _applyUserInteraction;
  37015. private _userIsMoving;
  37016. }
  37017. }
  37018. declare module "babylonjs/Behaviors/Cameras/index" {
  37019. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37020. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37021. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37022. }
  37023. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37024. import { Mesh } from "babylonjs/Meshes/mesh";
  37025. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37026. import { Behavior } from "babylonjs/Behaviors/behavior";
  37027. /**
  37028. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37029. */
  37030. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37031. private ui;
  37032. /**
  37033. * The name of the behavior
  37034. */
  37035. name: string;
  37036. /**
  37037. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37038. */
  37039. distanceAwayFromFace: number;
  37040. /**
  37041. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37042. */
  37043. distanceAwayFromBottomOfFace: number;
  37044. private _faceVectors;
  37045. private _target;
  37046. private _scene;
  37047. private _onRenderObserver;
  37048. private _tmpMatrix;
  37049. private _tmpVector;
  37050. /**
  37051. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37052. * @param ui The transform node that should be attched to the mesh
  37053. */
  37054. constructor(ui: TransformNode);
  37055. /**
  37056. * Initializes the behavior
  37057. */
  37058. init(): void;
  37059. private _closestFace;
  37060. private _zeroVector;
  37061. private _lookAtTmpMatrix;
  37062. private _lookAtToRef;
  37063. /**
  37064. * Attaches the AttachToBoxBehavior to the passed in mesh
  37065. * @param target The mesh that the specified node will be attached to
  37066. */
  37067. attach(target: Mesh): void;
  37068. /**
  37069. * Detaches the behavior from the mesh
  37070. */
  37071. detach(): void;
  37072. }
  37073. }
  37074. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37075. import { Behavior } from "babylonjs/Behaviors/behavior";
  37076. import { Mesh } from "babylonjs/Meshes/mesh";
  37077. /**
  37078. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37079. */
  37080. export class FadeInOutBehavior implements Behavior<Mesh> {
  37081. /**
  37082. * Time in milliseconds to delay before fading in (Default: 0)
  37083. */
  37084. delay: number;
  37085. /**
  37086. * Time in milliseconds for the mesh to fade in (Default: 300)
  37087. */
  37088. fadeInTime: number;
  37089. private _millisecondsPerFrame;
  37090. private _hovered;
  37091. private _hoverValue;
  37092. private _ownerNode;
  37093. /**
  37094. * Instatiates the FadeInOutBehavior
  37095. */
  37096. constructor();
  37097. /**
  37098. * The name of the behavior
  37099. */
  37100. readonly name: string;
  37101. /**
  37102. * Initializes the behavior
  37103. */
  37104. init(): void;
  37105. /**
  37106. * Attaches the fade behavior on the passed in mesh
  37107. * @param ownerNode The mesh that will be faded in/out once attached
  37108. */
  37109. attach(ownerNode: Mesh): void;
  37110. /**
  37111. * Detaches the behavior from the mesh
  37112. */
  37113. detach(): void;
  37114. /**
  37115. * Triggers the mesh to begin fading in or out
  37116. * @param value if the object should fade in or out (true to fade in)
  37117. */
  37118. fadeIn(value: boolean): void;
  37119. private _update;
  37120. private _setAllVisibility;
  37121. }
  37122. }
  37123. declare module "babylonjs/Misc/pivotTools" {
  37124. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37125. /**
  37126. * Class containing a set of static utilities functions for managing Pivots
  37127. * @hidden
  37128. */
  37129. export class PivotTools {
  37130. private static _PivotCached;
  37131. private static _OldPivotPoint;
  37132. private static _PivotTranslation;
  37133. private static _PivotTmpVector;
  37134. /** @hidden */
  37135. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37136. /** @hidden */
  37137. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37138. }
  37139. }
  37140. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37141. import { Scene } from "babylonjs/scene";
  37142. import { Vector4, Plane } from "babylonjs/Maths/math";
  37143. import { Mesh } from "babylonjs/Meshes/mesh";
  37144. import { Nullable } from "babylonjs/types";
  37145. /**
  37146. * Class containing static functions to help procedurally build meshes
  37147. */
  37148. export class PlaneBuilder {
  37149. /**
  37150. * Creates a plane mesh
  37151. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37152. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37153. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37154. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37155. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37157. * @param name defines the name of the mesh
  37158. * @param options defines the options used to create the mesh
  37159. * @param scene defines the hosting scene
  37160. * @returns the plane mesh
  37161. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37162. */
  37163. static CreatePlane(name: string, options: {
  37164. size?: number;
  37165. width?: number;
  37166. height?: number;
  37167. sideOrientation?: number;
  37168. frontUVs?: Vector4;
  37169. backUVs?: Vector4;
  37170. updatable?: boolean;
  37171. sourcePlane?: Plane;
  37172. }, scene?: Nullable<Scene>): Mesh;
  37173. }
  37174. }
  37175. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37176. import { Behavior } from "babylonjs/Behaviors/behavior";
  37177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37178. import { Observable } from "babylonjs/Misc/observable";
  37179. import { Vector3 } from "babylonjs/Maths/math";
  37180. import { Ray } from "babylonjs/Culling/ray";
  37181. import "babylonjs/Meshes/Builders/planeBuilder";
  37182. /**
  37183. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37184. */
  37185. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37186. private static _AnyMouseID;
  37187. /**
  37188. * Abstract mesh the behavior is set on
  37189. */
  37190. attachedNode: AbstractMesh;
  37191. private _dragPlane;
  37192. private _scene;
  37193. private _pointerObserver;
  37194. private _beforeRenderObserver;
  37195. private static _planeScene;
  37196. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37197. /**
  37198. * 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)
  37199. */
  37200. maxDragAngle: number;
  37201. /**
  37202. * @hidden
  37203. */
  37204. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37205. /**
  37206. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37207. */
  37208. currentDraggingPointerID: number;
  37209. /**
  37210. * The last position where the pointer hit the drag plane in world space
  37211. */
  37212. lastDragPosition: Vector3;
  37213. /**
  37214. * If the behavior is currently in a dragging state
  37215. */
  37216. dragging: boolean;
  37217. /**
  37218. * 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)
  37219. */
  37220. dragDeltaRatio: number;
  37221. /**
  37222. * If the drag plane orientation should be updated during the dragging (Default: true)
  37223. */
  37224. updateDragPlane: boolean;
  37225. private _debugMode;
  37226. private _moving;
  37227. /**
  37228. * Fires each time the attached mesh is dragged with the pointer
  37229. * * delta between last drag position and current drag position in world space
  37230. * * dragDistance along the drag axis
  37231. * * dragPlaneNormal normal of the current drag plane used during the drag
  37232. * * dragPlanePoint in world space where the drag intersects the drag plane
  37233. */
  37234. onDragObservable: Observable<{
  37235. delta: Vector3;
  37236. dragPlanePoint: Vector3;
  37237. dragPlaneNormal: Vector3;
  37238. dragDistance: number;
  37239. pointerId: number;
  37240. }>;
  37241. /**
  37242. * Fires each time a drag begins (eg. mouse down on mesh)
  37243. */
  37244. onDragStartObservable: Observable<{
  37245. dragPlanePoint: Vector3;
  37246. pointerId: number;
  37247. }>;
  37248. /**
  37249. * Fires each time a drag ends (eg. mouse release after drag)
  37250. */
  37251. onDragEndObservable: Observable<{
  37252. dragPlanePoint: Vector3;
  37253. pointerId: number;
  37254. }>;
  37255. /**
  37256. * If the attached mesh should be moved when dragged
  37257. */
  37258. moveAttached: boolean;
  37259. /**
  37260. * If the drag behavior will react to drag events (Default: true)
  37261. */
  37262. enabled: boolean;
  37263. /**
  37264. * If pointer events should start and release the drag (Default: true)
  37265. */
  37266. startAndReleaseDragOnPointerEvents: boolean;
  37267. /**
  37268. * If camera controls should be detached during the drag
  37269. */
  37270. detachCameraControls: boolean;
  37271. /**
  37272. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37273. */
  37274. useObjectOrienationForDragging: boolean;
  37275. private _options;
  37276. /**
  37277. * Creates a pointer drag behavior that can be attached to a mesh
  37278. * @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)
  37279. */
  37280. constructor(options?: {
  37281. dragAxis?: Vector3;
  37282. dragPlaneNormal?: Vector3;
  37283. });
  37284. /**
  37285. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37286. */
  37287. validateDrag: (targetPosition: Vector3) => boolean;
  37288. /**
  37289. * The name of the behavior
  37290. */
  37291. readonly name: string;
  37292. /**
  37293. * Initializes the behavior
  37294. */
  37295. init(): void;
  37296. private _tmpVector;
  37297. private _alternatePickedPoint;
  37298. private _worldDragAxis;
  37299. private _targetPosition;
  37300. private _attachedElement;
  37301. /**
  37302. * Attaches the drag behavior the passed in mesh
  37303. * @param ownerNode The mesh that will be dragged around once attached
  37304. */
  37305. attach(ownerNode: AbstractMesh): void;
  37306. /**
  37307. * Force relase the drag action by code.
  37308. */
  37309. releaseDrag(): void;
  37310. private _startDragRay;
  37311. private _lastPointerRay;
  37312. /**
  37313. * Simulates the start of a pointer drag event on the behavior
  37314. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37315. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37316. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37317. */
  37318. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37319. private _startDrag;
  37320. private _dragDelta;
  37321. private _moveDrag;
  37322. private _pickWithRayOnDragPlane;
  37323. private _pointA;
  37324. private _pointB;
  37325. private _pointC;
  37326. private _lineA;
  37327. private _lineB;
  37328. private _localAxis;
  37329. private _lookAt;
  37330. private _updateDragPlanePosition;
  37331. /**
  37332. * Detaches the behavior from the mesh
  37333. */
  37334. detach(): void;
  37335. }
  37336. }
  37337. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37338. import { Mesh } from "babylonjs/Meshes/mesh";
  37339. import { Behavior } from "babylonjs/Behaviors/behavior";
  37340. /**
  37341. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37342. */
  37343. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37344. private _dragBehaviorA;
  37345. private _dragBehaviorB;
  37346. private _startDistance;
  37347. private _initialScale;
  37348. private _targetScale;
  37349. private _ownerNode;
  37350. private _sceneRenderObserver;
  37351. /**
  37352. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37353. */
  37354. constructor();
  37355. /**
  37356. * The name of the behavior
  37357. */
  37358. readonly name: string;
  37359. /**
  37360. * Initializes the behavior
  37361. */
  37362. init(): void;
  37363. private _getCurrentDistance;
  37364. /**
  37365. * Attaches the scale behavior the passed in mesh
  37366. * @param ownerNode The mesh that will be scaled around once attached
  37367. */
  37368. attach(ownerNode: Mesh): void;
  37369. /**
  37370. * Detaches the behavior from the mesh
  37371. */
  37372. detach(): void;
  37373. }
  37374. }
  37375. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37376. import { Behavior } from "babylonjs/Behaviors/behavior";
  37377. import { Mesh } from "babylonjs/Meshes/mesh";
  37378. import { Observable } from "babylonjs/Misc/observable";
  37379. /**
  37380. * 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
  37381. */
  37382. export class SixDofDragBehavior implements Behavior<Mesh> {
  37383. private static _virtualScene;
  37384. private _ownerNode;
  37385. private _sceneRenderObserver;
  37386. private _scene;
  37387. private _targetPosition;
  37388. private _virtualOriginMesh;
  37389. private _virtualDragMesh;
  37390. private _pointerObserver;
  37391. private _moving;
  37392. private _startingOrientation;
  37393. /**
  37394. * 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)
  37395. */
  37396. private zDragFactor;
  37397. /**
  37398. * If the object should rotate to face the drag origin
  37399. */
  37400. rotateDraggedObject: boolean;
  37401. /**
  37402. * If the behavior is currently in a dragging state
  37403. */
  37404. dragging: boolean;
  37405. /**
  37406. * 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)
  37407. */
  37408. dragDeltaRatio: number;
  37409. /**
  37410. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37411. */
  37412. currentDraggingPointerID: number;
  37413. /**
  37414. * If camera controls should be detached during the drag
  37415. */
  37416. detachCameraControls: boolean;
  37417. /**
  37418. * Fires each time a drag starts
  37419. */
  37420. onDragStartObservable: Observable<{}>;
  37421. /**
  37422. * Fires each time a drag ends (eg. mouse release after drag)
  37423. */
  37424. onDragEndObservable: Observable<{}>;
  37425. /**
  37426. * 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
  37427. */
  37428. constructor();
  37429. /**
  37430. * The name of the behavior
  37431. */
  37432. readonly name: string;
  37433. /**
  37434. * Initializes the behavior
  37435. */
  37436. init(): void;
  37437. /**
  37438. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37439. */
  37440. private readonly _pointerCamera;
  37441. /**
  37442. * Attaches the scale behavior the passed in mesh
  37443. * @param ownerNode The mesh that will be scaled around once attached
  37444. */
  37445. attach(ownerNode: Mesh): void;
  37446. /**
  37447. * Detaches the behavior from the mesh
  37448. */
  37449. detach(): void;
  37450. }
  37451. }
  37452. declare module "babylonjs/Behaviors/Meshes/index" {
  37453. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37454. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37455. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37456. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37457. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37458. }
  37459. declare module "babylonjs/Behaviors/index" {
  37460. export * from "babylonjs/Behaviors/behavior";
  37461. export * from "babylonjs/Behaviors/Cameras/index";
  37462. export * from "babylonjs/Behaviors/Meshes/index";
  37463. }
  37464. declare module "babylonjs/Bones/boneIKController" {
  37465. import { Bone } from "babylonjs/Bones/bone";
  37466. import { Vector3 } from "babylonjs/Maths/math";
  37467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37468. import { Nullable } from "babylonjs/types";
  37469. /**
  37470. * Class used to apply inverse kinematics to bones
  37471. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37472. */
  37473. export class BoneIKController {
  37474. private static _tmpVecs;
  37475. private static _tmpQuat;
  37476. private static _tmpMats;
  37477. /**
  37478. * Gets or sets the target mesh
  37479. */
  37480. targetMesh: AbstractMesh;
  37481. /** Gets or sets the mesh used as pole */
  37482. poleTargetMesh: AbstractMesh;
  37483. /**
  37484. * Gets or sets the bone used as pole
  37485. */
  37486. poleTargetBone: Nullable<Bone>;
  37487. /**
  37488. * Gets or sets the target position
  37489. */
  37490. targetPosition: Vector3;
  37491. /**
  37492. * Gets or sets the pole target position
  37493. */
  37494. poleTargetPosition: Vector3;
  37495. /**
  37496. * Gets or sets the pole target local offset
  37497. */
  37498. poleTargetLocalOffset: Vector3;
  37499. /**
  37500. * Gets or sets the pole angle
  37501. */
  37502. poleAngle: number;
  37503. /**
  37504. * Gets or sets the mesh associated with the controller
  37505. */
  37506. mesh: AbstractMesh;
  37507. /**
  37508. * 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)
  37509. */
  37510. slerpAmount: number;
  37511. private _bone1Quat;
  37512. private _bone1Mat;
  37513. private _bone2Ang;
  37514. private _bone1;
  37515. private _bone2;
  37516. private _bone1Length;
  37517. private _bone2Length;
  37518. private _maxAngle;
  37519. private _maxReach;
  37520. private _rightHandedSystem;
  37521. private _bendAxis;
  37522. private _slerping;
  37523. private _adjustRoll;
  37524. /**
  37525. * Gets or sets maximum allowed angle
  37526. */
  37527. maxAngle: number;
  37528. /**
  37529. * Creates a new BoneIKController
  37530. * @param mesh defines the mesh to control
  37531. * @param bone defines the bone to control
  37532. * @param options defines options to set up the controller
  37533. */
  37534. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37535. targetMesh?: AbstractMesh;
  37536. poleTargetMesh?: AbstractMesh;
  37537. poleTargetBone?: Bone;
  37538. poleTargetLocalOffset?: Vector3;
  37539. poleAngle?: number;
  37540. bendAxis?: Vector3;
  37541. maxAngle?: number;
  37542. slerpAmount?: number;
  37543. });
  37544. private _setMaxAngle;
  37545. /**
  37546. * Force the controller to update the bones
  37547. */
  37548. update(): void;
  37549. }
  37550. }
  37551. declare module "babylonjs/Bones/boneLookController" {
  37552. import { Vector3, Space } from "babylonjs/Maths/math";
  37553. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37554. import { Bone } from "babylonjs/Bones/bone";
  37555. /**
  37556. * Class used to make a bone look toward a point in space
  37557. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37558. */
  37559. export class BoneLookController {
  37560. private static _tmpVecs;
  37561. private static _tmpQuat;
  37562. private static _tmpMats;
  37563. /**
  37564. * The target Vector3 that the bone will look at
  37565. */
  37566. target: Vector3;
  37567. /**
  37568. * The mesh that the bone is attached to
  37569. */
  37570. mesh: AbstractMesh;
  37571. /**
  37572. * The bone that will be looking to the target
  37573. */
  37574. bone: Bone;
  37575. /**
  37576. * The up axis of the coordinate system that is used when the bone is rotated
  37577. */
  37578. upAxis: Vector3;
  37579. /**
  37580. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37581. */
  37582. upAxisSpace: Space;
  37583. /**
  37584. * Used to make an adjustment to the yaw of the bone
  37585. */
  37586. adjustYaw: number;
  37587. /**
  37588. * Used to make an adjustment to the pitch of the bone
  37589. */
  37590. adjustPitch: number;
  37591. /**
  37592. * Used to make an adjustment to the roll of the bone
  37593. */
  37594. adjustRoll: number;
  37595. /**
  37596. * 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)
  37597. */
  37598. slerpAmount: number;
  37599. private _minYaw;
  37600. private _maxYaw;
  37601. private _minPitch;
  37602. private _maxPitch;
  37603. private _minYawSin;
  37604. private _minYawCos;
  37605. private _maxYawSin;
  37606. private _maxYawCos;
  37607. private _midYawConstraint;
  37608. private _minPitchTan;
  37609. private _maxPitchTan;
  37610. private _boneQuat;
  37611. private _slerping;
  37612. private _transformYawPitch;
  37613. private _transformYawPitchInv;
  37614. private _firstFrameSkipped;
  37615. private _yawRange;
  37616. private _fowardAxis;
  37617. /**
  37618. * Gets or sets the minimum yaw angle that the bone can look to
  37619. */
  37620. minYaw: number;
  37621. /**
  37622. * Gets or sets the maximum yaw angle that the bone can look to
  37623. */
  37624. maxYaw: number;
  37625. /**
  37626. * Gets or sets the minimum pitch angle that the bone can look to
  37627. */
  37628. minPitch: number;
  37629. /**
  37630. * Gets or sets the maximum pitch angle that the bone can look to
  37631. */
  37632. maxPitch: number;
  37633. /**
  37634. * Create a BoneLookController
  37635. * @param mesh the mesh that the bone belongs to
  37636. * @param bone the bone that will be looking to the target
  37637. * @param target the target Vector3 to look at
  37638. * @param options optional settings:
  37639. * * maxYaw: the maximum angle the bone will yaw to
  37640. * * minYaw: the minimum angle the bone will yaw to
  37641. * * maxPitch: the maximum angle the bone will pitch to
  37642. * * minPitch: the minimum angle the bone will yaw to
  37643. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37644. * * upAxis: the up axis of the coordinate system
  37645. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37646. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37647. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37648. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37649. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37650. * * adjustRoll: used to make an adjustment to the roll of the bone
  37651. **/
  37652. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37653. maxYaw?: number;
  37654. minYaw?: number;
  37655. maxPitch?: number;
  37656. minPitch?: number;
  37657. slerpAmount?: number;
  37658. upAxis?: Vector3;
  37659. upAxisSpace?: Space;
  37660. yawAxis?: Vector3;
  37661. pitchAxis?: Vector3;
  37662. adjustYaw?: number;
  37663. adjustPitch?: number;
  37664. adjustRoll?: number;
  37665. });
  37666. /**
  37667. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37668. */
  37669. update(): void;
  37670. private _getAngleDiff;
  37671. private _getAngleBetween;
  37672. private _isAngleBetween;
  37673. }
  37674. }
  37675. declare module "babylonjs/Bones/index" {
  37676. export * from "babylonjs/Bones/bone";
  37677. export * from "babylonjs/Bones/boneIKController";
  37678. export * from "babylonjs/Bones/boneLookController";
  37679. export * from "babylonjs/Bones/skeleton";
  37680. }
  37681. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37682. import { Nullable } from "babylonjs/types";
  37683. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37684. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37685. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37686. /**
  37687. * Manage the gamepad inputs to control an arc rotate camera.
  37688. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37689. */
  37690. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37691. /**
  37692. * Defines the camera the input is attached to.
  37693. */
  37694. camera: ArcRotateCamera;
  37695. /**
  37696. * Defines the gamepad the input is gathering event from.
  37697. */
  37698. gamepad: Nullable<Gamepad>;
  37699. /**
  37700. * Defines the gamepad rotation sensiblity.
  37701. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37702. */
  37703. gamepadRotationSensibility: number;
  37704. /**
  37705. * Defines the gamepad move sensiblity.
  37706. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37707. */
  37708. gamepadMoveSensibility: number;
  37709. private _onGamepadConnectedObserver;
  37710. private _onGamepadDisconnectedObserver;
  37711. /**
  37712. * Attach the input controls to a specific dom element to get the input from.
  37713. * @param element Defines the element the controls should be listened from
  37714. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37715. */
  37716. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37717. /**
  37718. * Detach the current controls from the specified dom element.
  37719. * @param element Defines the element to stop listening the inputs from
  37720. */
  37721. detachControl(element: Nullable<HTMLElement>): void;
  37722. /**
  37723. * Update the current camera state depending on the inputs that have been used this frame.
  37724. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37725. */
  37726. checkInputs(): void;
  37727. /**
  37728. * Gets the class name of the current intput.
  37729. * @returns the class name
  37730. */
  37731. getClassName(): string;
  37732. /**
  37733. * Get the friendly name associated with the input class.
  37734. * @returns the input friendly name
  37735. */
  37736. getSimpleName(): string;
  37737. }
  37738. }
  37739. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  37740. import { Nullable } from "babylonjs/types";
  37741. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37742. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37743. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37744. interface ArcRotateCameraInputsManager {
  37745. /**
  37746. * Add orientation input support to the input manager.
  37747. * @returns the current input manager
  37748. */
  37749. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37750. }
  37751. }
  37752. /**
  37753. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37754. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37755. */
  37756. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37757. /**
  37758. * Defines the camera the input is attached to.
  37759. */
  37760. camera: ArcRotateCamera;
  37761. /**
  37762. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37763. */
  37764. alphaCorrection: number;
  37765. /**
  37766. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37767. */
  37768. gammaCorrection: number;
  37769. private _alpha;
  37770. private _gamma;
  37771. private _dirty;
  37772. private _deviceOrientationHandler;
  37773. /**
  37774. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37775. */
  37776. constructor();
  37777. /**
  37778. * Attach the input controls to a specific dom element to get the input from.
  37779. * @param element Defines the element the controls should be listened from
  37780. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37781. */
  37782. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37783. /** @hidden */
  37784. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37785. /**
  37786. * Update the current camera state depending on the inputs that have been used this frame.
  37787. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37788. */
  37789. checkInputs(): void;
  37790. /**
  37791. * Detach the current controls from the specified dom element.
  37792. * @param element Defines the element to stop listening the inputs from
  37793. */
  37794. detachControl(element: Nullable<HTMLElement>): void;
  37795. /**
  37796. * Gets the class name of the current intput.
  37797. * @returns the class name
  37798. */
  37799. getClassName(): string;
  37800. /**
  37801. * Get the friendly name associated with the input class.
  37802. * @returns the input friendly name
  37803. */
  37804. getSimpleName(): string;
  37805. }
  37806. }
  37807. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37808. import { Nullable } from "babylonjs/types";
  37809. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37810. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37811. /**
  37812. * Listen to mouse events to control the camera.
  37813. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37814. */
  37815. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37816. /**
  37817. * Defines the camera the input is attached to.
  37818. */
  37819. camera: FlyCamera;
  37820. /**
  37821. * Defines if touch is enabled. (Default is true.)
  37822. */
  37823. touchEnabled: boolean;
  37824. /**
  37825. * Defines the buttons associated with the input to handle camera rotation.
  37826. */
  37827. buttons: number[];
  37828. /**
  37829. * Assign buttons for Yaw control.
  37830. */
  37831. buttonsYaw: number[];
  37832. /**
  37833. * Assign buttons for Pitch control.
  37834. */
  37835. buttonsPitch: number[];
  37836. /**
  37837. * Assign buttons for Roll control.
  37838. */
  37839. buttonsRoll: number[];
  37840. /**
  37841. * Detect if any button is being pressed while mouse is moved.
  37842. * -1 = Mouse locked.
  37843. * 0 = Left button.
  37844. * 1 = Middle Button.
  37845. * 2 = Right Button.
  37846. */
  37847. activeButton: number;
  37848. /**
  37849. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37850. * Higher values reduce its sensitivity.
  37851. */
  37852. angularSensibility: number;
  37853. private _mousemoveCallback;
  37854. private _observer;
  37855. private _rollObserver;
  37856. private previousPosition;
  37857. private noPreventDefault;
  37858. private element;
  37859. /**
  37860. * Listen to mouse events to control the camera.
  37861. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37862. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37863. */
  37864. constructor(touchEnabled?: boolean);
  37865. /**
  37866. * Attach the mouse control to the HTML DOM element.
  37867. * @param element Defines the element that listens to the input events.
  37868. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37869. */
  37870. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37871. /**
  37872. * Detach the current controls from the specified dom element.
  37873. * @param element Defines the element to stop listening the inputs from
  37874. */
  37875. detachControl(element: Nullable<HTMLElement>): void;
  37876. /**
  37877. * Gets the class name of the current input.
  37878. * @returns the class name.
  37879. */
  37880. getClassName(): string;
  37881. /**
  37882. * Get the friendly name associated with the input class.
  37883. * @returns the input's friendly name.
  37884. */
  37885. getSimpleName(): string;
  37886. private _pointerInput;
  37887. private _onMouseMove;
  37888. /**
  37889. * Rotate camera by mouse offset.
  37890. */
  37891. private rotateCamera;
  37892. }
  37893. }
  37894. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37895. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37896. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37897. /**
  37898. * Default Inputs manager for the FlyCamera.
  37899. * It groups all the default supported inputs for ease of use.
  37900. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37901. */
  37902. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37903. /**
  37904. * Instantiates a new FlyCameraInputsManager.
  37905. * @param camera Defines the camera the inputs belong to.
  37906. */
  37907. constructor(camera: FlyCamera);
  37908. /**
  37909. * Add keyboard input support to the input manager.
  37910. * @returns the new FlyCameraKeyboardMoveInput().
  37911. */
  37912. addKeyboard(): FlyCameraInputsManager;
  37913. /**
  37914. * Add mouse input support to the input manager.
  37915. * @param touchEnabled Enable touch screen support.
  37916. * @returns the new FlyCameraMouseInput().
  37917. */
  37918. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37919. }
  37920. }
  37921. declare module "babylonjs/Cameras/flyCamera" {
  37922. import { Scene } from "babylonjs/scene";
  37923. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37924. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37925. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37926. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37927. /**
  37928. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37929. * such as in a 3D Space Shooter or a Flight Simulator.
  37930. */
  37931. export class FlyCamera extends TargetCamera {
  37932. /**
  37933. * Define the collision ellipsoid of the camera.
  37934. * This is helpful for simulating a camera body, like a player's body.
  37935. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37936. */
  37937. ellipsoid: Vector3;
  37938. /**
  37939. * Define an offset for the position of the ellipsoid around the camera.
  37940. * This can be helpful if the camera is attached away from the player's body center,
  37941. * such as at its head.
  37942. */
  37943. ellipsoidOffset: Vector3;
  37944. /**
  37945. * Enable or disable collisions of the camera with the rest of the scene objects.
  37946. */
  37947. checkCollisions: boolean;
  37948. /**
  37949. * Enable or disable gravity on the camera.
  37950. */
  37951. applyGravity: boolean;
  37952. /**
  37953. * Define the current direction the camera is moving to.
  37954. */
  37955. cameraDirection: Vector3;
  37956. /**
  37957. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37958. * This overrides and empties cameraRotation.
  37959. */
  37960. rotationQuaternion: Quaternion;
  37961. /**
  37962. * Track Roll to maintain the wanted Rolling when looking around.
  37963. */
  37964. _trackRoll: number;
  37965. /**
  37966. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37967. */
  37968. rollCorrect: number;
  37969. /**
  37970. * Mimic a banked turn, Rolling the camera when Yawing.
  37971. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37972. */
  37973. bankedTurn: boolean;
  37974. /**
  37975. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37976. */
  37977. bankedTurnLimit: number;
  37978. /**
  37979. * Value of 0 disables the banked Roll.
  37980. * Value of 1 is equal to the Yaw angle in radians.
  37981. */
  37982. bankedTurnMultiplier: number;
  37983. /**
  37984. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37985. */
  37986. inputs: FlyCameraInputsManager;
  37987. /**
  37988. * Gets the input sensibility for mouse input.
  37989. * Higher values reduce sensitivity.
  37990. */
  37991. /**
  37992. * Sets the input sensibility for a mouse input.
  37993. * Higher values reduce sensitivity.
  37994. */
  37995. angularSensibility: number;
  37996. /**
  37997. * Get the keys for camera movement forward.
  37998. */
  37999. /**
  38000. * Set the keys for camera movement forward.
  38001. */
  38002. keysForward: number[];
  38003. /**
  38004. * Get the keys for camera movement backward.
  38005. */
  38006. keysBackward: number[];
  38007. /**
  38008. * Get the keys for camera movement up.
  38009. */
  38010. /**
  38011. * Set the keys for camera movement up.
  38012. */
  38013. keysUp: number[];
  38014. /**
  38015. * Get the keys for camera movement down.
  38016. */
  38017. /**
  38018. * Set the keys for camera movement down.
  38019. */
  38020. keysDown: number[];
  38021. /**
  38022. * Get the keys for camera movement left.
  38023. */
  38024. /**
  38025. * Set the keys for camera movement left.
  38026. */
  38027. keysLeft: number[];
  38028. /**
  38029. * Set the keys for camera movement right.
  38030. */
  38031. /**
  38032. * Set the keys for camera movement right.
  38033. */
  38034. keysRight: number[];
  38035. /**
  38036. * Event raised when the camera collides with a mesh in the scene.
  38037. */
  38038. onCollide: (collidedMesh: AbstractMesh) => void;
  38039. private _collider;
  38040. private _needMoveForGravity;
  38041. private _oldPosition;
  38042. private _diffPosition;
  38043. private _newPosition;
  38044. /** @hidden */
  38045. _localDirection: Vector3;
  38046. /** @hidden */
  38047. _transformedDirection: Vector3;
  38048. /**
  38049. * Instantiates a FlyCamera.
  38050. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38051. * such as in a 3D Space Shooter or a Flight Simulator.
  38052. * @param name Define the name of the camera in the scene.
  38053. * @param position Define the starting position of the camera in the scene.
  38054. * @param scene Define the scene the camera belongs to.
  38055. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38056. */
  38057. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38058. /**
  38059. * Attach a control to the HTML DOM element.
  38060. * @param element Defines the element that listens to the input events.
  38061. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38062. */
  38063. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38064. /**
  38065. * Detach a control from the HTML DOM element.
  38066. * The camera will stop reacting to that input.
  38067. * @param element Defines the element that listens to the input events.
  38068. */
  38069. detachControl(element: HTMLElement): void;
  38070. private _collisionMask;
  38071. /**
  38072. * Get the mask that the camera ignores in collision events.
  38073. */
  38074. /**
  38075. * Set the mask that the camera ignores in collision events.
  38076. */
  38077. collisionMask: number;
  38078. /** @hidden */
  38079. _collideWithWorld(displacement: Vector3): void;
  38080. /** @hidden */
  38081. private _onCollisionPositionChange;
  38082. /** @hidden */
  38083. _checkInputs(): void;
  38084. /** @hidden */
  38085. _decideIfNeedsToMove(): boolean;
  38086. /** @hidden */
  38087. _updatePosition(): void;
  38088. /**
  38089. * Restore the Roll to its target value at the rate specified.
  38090. * @param rate - Higher means slower restoring.
  38091. * @hidden
  38092. */
  38093. restoreRoll(rate: number): void;
  38094. /**
  38095. * Destroy the camera and release the current resources held by it.
  38096. */
  38097. dispose(): void;
  38098. /**
  38099. * Get the current object class name.
  38100. * @returns the class name.
  38101. */
  38102. getClassName(): string;
  38103. }
  38104. }
  38105. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38106. import { Nullable } from "babylonjs/types";
  38107. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38108. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38109. /**
  38110. * Listen to keyboard events to control the camera.
  38111. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38112. */
  38113. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38114. /**
  38115. * Defines the camera the input is attached to.
  38116. */
  38117. camera: FlyCamera;
  38118. /**
  38119. * The list of keyboard keys used to control the forward move of the camera.
  38120. */
  38121. keysForward: number[];
  38122. /**
  38123. * The list of keyboard keys used to control the backward move of the camera.
  38124. */
  38125. keysBackward: number[];
  38126. /**
  38127. * The list of keyboard keys used to control the forward move of the camera.
  38128. */
  38129. keysUp: number[];
  38130. /**
  38131. * The list of keyboard keys used to control the backward move of the camera.
  38132. */
  38133. keysDown: number[];
  38134. /**
  38135. * The list of keyboard keys used to control the right strafe move of the camera.
  38136. */
  38137. keysRight: number[];
  38138. /**
  38139. * The list of keyboard keys used to control the left strafe move of the camera.
  38140. */
  38141. keysLeft: number[];
  38142. private _keys;
  38143. private _onCanvasBlurObserver;
  38144. private _onKeyboardObserver;
  38145. private _engine;
  38146. private _scene;
  38147. /**
  38148. * Attach the input controls to a specific dom element to get the input from.
  38149. * @param element Defines the element the controls should be listened from
  38150. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38151. */
  38152. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38153. /**
  38154. * Detach the current controls from the specified dom element.
  38155. * @param element Defines the element to stop listening the inputs from
  38156. */
  38157. detachControl(element: Nullable<HTMLElement>): void;
  38158. /**
  38159. * Gets the class name of the current intput.
  38160. * @returns the class name
  38161. */
  38162. getClassName(): string;
  38163. /** @hidden */
  38164. _onLostFocus(e: FocusEvent): void;
  38165. /**
  38166. * Get the friendly name associated with the input class.
  38167. * @returns the input friendly name
  38168. */
  38169. getSimpleName(): string;
  38170. /**
  38171. * Update the current camera state depending on the inputs that have been used this frame.
  38172. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38173. */
  38174. checkInputs(): void;
  38175. }
  38176. }
  38177. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38178. import { Nullable } from "babylonjs/types";
  38179. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38180. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38181. /**
  38182. * Manage the mouse wheel inputs to control a follow camera.
  38183. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38184. */
  38185. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38186. /**
  38187. * Defines the camera the input is attached to.
  38188. */
  38189. camera: FollowCamera;
  38190. /**
  38191. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38192. */
  38193. axisControlRadius: boolean;
  38194. /**
  38195. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38196. */
  38197. axisControlHeight: boolean;
  38198. /**
  38199. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38200. */
  38201. axisControlRotation: boolean;
  38202. /**
  38203. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38204. * relation to mouseWheel events.
  38205. */
  38206. wheelPrecision: number;
  38207. /**
  38208. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38209. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38210. */
  38211. wheelDeltaPercentage: number;
  38212. private _wheel;
  38213. private _observer;
  38214. /**
  38215. * Attach the input controls to a specific dom element to get the input from.
  38216. * @param element Defines the element the controls should be listened from
  38217. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38218. */
  38219. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38220. /**
  38221. * Detach the current controls from the specified dom element.
  38222. * @param element Defines the element to stop listening the inputs from
  38223. */
  38224. detachControl(element: Nullable<HTMLElement>): void;
  38225. /**
  38226. * Gets the class name of the current intput.
  38227. * @returns the class name
  38228. */
  38229. getClassName(): string;
  38230. /**
  38231. * Get the friendly name associated with the input class.
  38232. * @returns the input friendly name
  38233. */
  38234. getSimpleName(): string;
  38235. }
  38236. }
  38237. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38238. import { Nullable } from "babylonjs/types";
  38239. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38240. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38241. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38242. /**
  38243. * Manage the pointers inputs to control an follow camera.
  38244. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38245. */
  38246. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38247. /**
  38248. * Defines the camera the input is attached to.
  38249. */
  38250. camera: FollowCamera;
  38251. /**
  38252. * Gets the class name of the current input.
  38253. * @returns the class name
  38254. */
  38255. getClassName(): string;
  38256. /**
  38257. * Defines the pointer angular sensibility along the X axis or how fast is
  38258. * the camera rotating.
  38259. * A negative number will reverse the axis direction.
  38260. */
  38261. angularSensibilityX: number;
  38262. /**
  38263. * Defines the pointer angular sensibility along the Y axis or how fast is
  38264. * the camera rotating.
  38265. * A negative number will reverse the axis direction.
  38266. */
  38267. angularSensibilityY: number;
  38268. /**
  38269. * Defines the pointer pinch precision or how fast is the camera zooming.
  38270. * A negative number will reverse the axis direction.
  38271. */
  38272. pinchPrecision: number;
  38273. /**
  38274. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38275. * from 0.
  38276. * It defines the percentage of current camera.radius to use as delta when
  38277. * pinch zoom is used.
  38278. */
  38279. pinchDeltaPercentage: number;
  38280. /**
  38281. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38282. */
  38283. axisXControlRadius: boolean;
  38284. /**
  38285. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38286. */
  38287. axisXControlHeight: boolean;
  38288. /**
  38289. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38290. */
  38291. axisXControlRotation: boolean;
  38292. /**
  38293. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38294. */
  38295. axisYControlRadius: boolean;
  38296. /**
  38297. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38298. */
  38299. axisYControlHeight: boolean;
  38300. /**
  38301. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38302. */
  38303. axisYControlRotation: boolean;
  38304. /**
  38305. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38306. */
  38307. axisPinchControlRadius: boolean;
  38308. /**
  38309. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38310. */
  38311. axisPinchControlHeight: boolean;
  38312. /**
  38313. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38314. */
  38315. axisPinchControlRotation: boolean;
  38316. /**
  38317. * Log error messages if basic misconfiguration has occurred.
  38318. */
  38319. warningEnable: boolean;
  38320. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38321. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38322. private _warningCounter;
  38323. private _warning;
  38324. }
  38325. }
  38326. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38327. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38328. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38329. /**
  38330. * Default Inputs manager for the FollowCamera.
  38331. * It groups all the default supported inputs for ease of use.
  38332. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38333. */
  38334. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38335. /**
  38336. * Instantiates a new FollowCameraInputsManager.
  38337. * @param camera Defines the camera the inputs belong to
  38338. */
  38339. constructor(camera: FollowCamera);
  38340. /**
  38341. * Add keyboard input support to the input manager.
  38342. * @returns the current input manager
  38343. */
  38344. addKeyboard(): FollowCameraInputsManager;
  38345. /**
  38346. * Add mouse wheel input support to the input manager.
  38347. * @returns the current input manager
  38348. */
  38349. addMouseWheel(): FollowCameraInputsManager;
  38350. /**
  38351. * Add pointers input support to the input manager.
  38352. * @returns the current input manager
  38353. */
  38354. addPointers(): FollowCameraInputsManager;
  38355. /**
  38356. * Add orientation input support to the input manager.
  38357. * @returns the current input manager
  38358. */
  38359. addVRDeviceOrientation(): FollowCameraInputsManager;
  38360. }
  38361. }
  38362. declare module "babylonjs/Cameras/followCamera" {
  38363. import { Nullable } from "babylonjs/types";
  38364. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38365. import { Scene } from "babylonjs/scene";
  38366. import { Vector3 } from "babylonjs/Maths/math";
  38367. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38368. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38369. /**
  38370. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38371. * an arc rotate version arcFollowCamera are available.
  38372. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38373. */
  38374. export class FollowCamera extends TargetCamera {
  38375. /**
  38376. * Distance the follow camera should follow an object at
  38377. */
  38378. radius: number;
  38379. /**
  38380. * Minimum allowed distance of the camera to the axis of rotation
  38381. * (The camera can not get closer).
  38382. * This can help limiting how the Camera is able to move in the scene.
  38383. */
  38384. lowerRadiusLimit: Nullable<number>;
  38385. /**
  38386. * Maximum allowed distance of the camera to the axis of rotation
  38387. * (The camera can not get further).
  38388. * This can help limiting how the Camera is able to move in the scene.
  38389. */
  38390. upperRadiusLimit: Nullable<number>;
  38391. /**
  38392. * Define a rotation offset between the camera and the object it follows
  38393. */
  38394. rotationOffset: number;
  38395. /**
  38396. * Minimum allowed angle to camera position relative to target object.
  38397. * This can help limiting how the Camera is able to move in the scene.
  38398. */
  38399. lowerRotationOffsetLimit: Nullable<number>;
  38400. /**
  38401. * Maximum allowed angle to camera position relative to target object.
  38402. * This can help limiting how the Camera is able to move in the scene.
  38403. */
  38404. upperRotationOffsetLimit: Nullable<number>;
  38405. /**
  38406. * Define a height offset between the camera and the object it follows.
  38407. * It can help following an object from the top (like a car chaing a plane)
  38408. */
  38409. heightOffset: number;
  38410. /**
  38411. * Minimum allowed height of camera position relative to target object.
  38412. * This can help limiting how the Camera is able to move in the scene.
  38413. */
  38414. lowerHeightOffsetLimit: Nullable<number>;
  38415. /**
  38416. * Maximum allowed height of camera position relative to target object.
  38417. * This can help limiting how the Camera is able to move in the scene.
  38418. */
  38419. upperHeightOffsetLimit: Nullable<number>;
  38420. /**
  38421. * Define how fast the camera can accelerate to follow it s target.
  38422. */
  38423. cameraAcceleration: number;
  38424. /**
  38425. * Define the speed limit of the camera following an object.
  38426. */
  38427. maxCameraSpeed: number;
  38428. /**
  38429. * Define the target of the camera.
  38430. */
  38431. lockedTarget: Nullable<AbstractMesh>;
  38432. /**
  38433. * Defines the input associated with the camera.
  38434. */
  38435. inputs: FollowCameraInputsManager;
  38436. /**
  38437. * Instantiates the follow camera.
  38438. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38439. * @param name Define the name of the camera in the scene
  38440. * @param position Define the position of the camera
  38441. * @param scene Define the scene the camera belong to
  38442. * @param lockedTarget Define the target of the camera
  38443. */
  38444. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38445. private _follow;
  38446. /**
  38447. * Attached controls to the current camera.
  38448. * @param element Defines the element the controls should be listened from
  38449. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38450. */
  38451. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38452. /**
  38453. * Detach the current controls from the camera.
  38454. * The camera will stop reacting to inputs.
  38455. * @param element Defines the element to stop listening the inputs from
  38456. */
  38457. detachControl(element: HTMLElement): void;
  38458. /** @hidden */
  38459. _checkInputs(): void;
  38460. private _checkLimits;
  38461. /**
  38462. * Gets the camera class name.
  38463. * @returns the class name
  38464. */
  38465. getClassName(): string;
  38466. }
  38467. /**
  38468. * Arc Rotate version of the follow camera.
  38469. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38470. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38471. */
  38472. export class ArcFollowCamera extends TargetCamera {
  38473. /** The longitudinal angle of the camera */
  38474. alpha: number;
  38475. /** The latitudinal angle of the camera */
  38476. beta: number;
  38477. /** The radius of the camera from its target */
  38478. radius: number;
  38479. /** Define the camera target (the messh it should follow) */
  38480. target: Nullable<AbstractMesh>;
  38481. private _cartesianCoordinates;
  38482. /**
  38483. * Instantiates a new ArcFollowCamera
  38484. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38485. * @param name Define the name of the camera
  38486. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38487. * @param beta Define the rotation angle of the camera around the elevation axis
  38488. * @param radius Define the radius of the camera from its target point
  38489. * @param target Define the target of the camera
  38490. * @param scene Define the scene the camera belongs to
  38491. */
  38492. constructor(name: string,
  38493. /** The longitudinal angle of the camera */
  38494. alpha: number,
  38495. /** The latitudinal angle of the camera */
  38496. beta: number,
  38497. /** The radius of the camera from its target */
  38498. radius: number,
  38499. /** Define the camera target (the messh it should follow) */
  38500. target: Nullable<AbstractMesh>, scene: Scene);
  38501. private _follow;
  38502. /** @hidden */
  38503. _checkInputs(): void;
  38504. /**
  38505. * Returns the class name of the object.
  38506. * It is mostly used internally for serialization purposes.
  38507. */
  38508. getClassName(): string;
  38509. }
  38510. }
  38511. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38512. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38513. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38514. import { Nullable } from "babylonjs/types";
  38515. /**
  38516. * Manage the keyboard inputs to control the movement of a follow camera.
  38517. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38518. */
  38519. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38520. /**
  38521. * Defines the camera the input is attached to.
  38522. */
  38523. camera: FollowCamera;
  38524. /**
  38525. * Defines the list of key codes associated with the up action (increase heightOffset)
  38526. */
  38527. keysHeightOffsetIncr: number[];
  38528. /**
  38529. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38530. */
  38531. keysHeightOffsetDecr: number[];
  38532. /**
  38533. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38534. */
  38535. keysHeightOffsetModifierAlt: boolean;
  38536. /**
  38537. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38538. */
  38539. keysHeightOffsetModifierCtrl: boolean;
  38540. /**
  38541. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38542. */
  38543. keysHeightOffsetModifierShift: boolean;
  38544. /**
  38545. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38546. */
  38547. keysRotationOffsetIncr: number[];
  38548. /**
  38549. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38550. */
  38551. keysRotationOffsetDecr: number[];
  38552. /**
  38553. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38554. */
  38555. keysRotationOffsetModifierAlt: boolean;
  38556. /**
  38557. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38558. */
  38559. keysRotationOffsetModifierCtrl: boolean;
  38560. /**
  38561. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38562. */
  38563. keysRotationOffsetModifierShift: boolean;
  38564. /**
  38565. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38566. */
  38567. keysRadiusIncr: number[];
  38568. /**
  38569. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38570. */
  38571. keysRadiusDecr: number[];
  38572. /**
  38573. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38574. */
  38575. keysRadiusModifierAlt: boolean;
  38576. /**
  38577. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38578. */
  38579. keysRadiusModifierCtrl: boolean;
  38580. /**
  38581. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38582. */
  38583. keysRadiusModifierShift: boolean;
  38584. /**
  38585. * Defines the rate of change of heightOffset.
  38586. */
  38587. heightSensibility: number;
  38588. /**
  38589. * Defines the rate of change of rotationOffset.
  38590. */
  38591. rotationSensibility: number;
  38592. /**
  38593. * Defines the rate of change of radius.
  38594. */
  38595. radiusSensibility: number;
  38596. private _keys;
  38597. private _ctrlPressed;
  38598. private _altPressed;
  38599. private _shiftPressed;
  38600. private _onCanvasBlurObserver;
  38601. private _onKeyboardObserver;
  38602. private _engine;
  38603. private _scene;
  38604. /**
  38605. * Attach the input controls to a specific dom element to get the input from.
  38606. * @param element Defines the element the controls should be listened from
  38607. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38608. */
  38609. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38610. /**
  38611. * Detach the current controls from the specified dom element.
  38612. * @param element Defines the element to stop listening the inputs from
  38613. */
  38614. detachControl(element: Nullable<HTMLElement>): void;
  38615. /**
  38616. * Update the current camera state depending on the inputs that have been used this frame.
  38617. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38618. */
  38619. checkInputs(): void;
  38620. /**
  38621. * Gets the class name of the current input.
  38622. * @returns the class name
  38623. */
  38624. getClassName(): string;
  38625. /**
  38626. * Get the friendly name associated with the input class.
  38627. * @returns the input friendly name
  38628. */
  38629. getSimpleName(): string;
  38630. /**
  38631. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38632. * allow modification of the heightOffset value.
  38633. */
  38634. private _modifierHeightOffset;
  38635. /**
  38636. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38637. * allow modification of the rotationOffset value.
  38638. */
  38639. private _modifierRotationOffset;
  38640. /**
  38641. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38642. * allow modification of the radius value.
  38643. */
  38644. private _modifierRadius;
  38645. }
  38646. }
  38647. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  38648. import { Nullable } from "babylonjs/types";
  38649. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38650. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38651. import { Observable } from "babylonjs/Misc/observable";
  38652. module "babylonjs/Cameras/freeCameraInputsManager" {
  38653. interface FreeCameraInputsManager {
  38654. /**
  38655. * @hidden
  38656. */
  38657. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38658. /**
  38659. * Add orientation input support to the input manager.
  38660. * @returns the current input manager
  38661. */
  38662. addDeviceOrientation(): FreeCameraInputsManager;
  38663. }
  38664. }
  38665. /**
  38666. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38667. * Screen rotation is taken into account.
  38668. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38669. */
  38670. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38671. private _camera;
  38672. private _screenOrientationAngle;
  38673. private _constantTranform;
  38674. private _screenQuaternion;
  38675. private _alpha;
  38676. private _beta;
  38677. private _gamma;
  38678. /**
  38679. * Can be used to detect if a device orientation sensor is availible on a device
  38680. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38681. * @returns a promise that will resolve on orientation change
  38682. */
  38683. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38684. /**
  38685. * @hidden
  38686. */
  38687. _onDeviceOrientationChangedObservable: Observable<void>;
  38688. /**
  38689. * Instantiates a new input
  38690. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38691. */
  38692. constructor();
  38693. /**
  38694. * Define the camera controlled by the input.
  38695. */
  38696. camera: FreeCamera;
  38697. /**
  38698. * Attach the input controls to a specific dom element to get the input from.
  38699. * @param element Defines the element the controls should be listened from
  38700. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38701. */
  38702. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38703. private _orientationChanged;
  38704. private _deviceOrientation;
  38705. /**
  38706. * Detach the current controls from the specified dom element.
  38707. * @param element Defines the element to stop listening the inputs from
  38708. */
  38709. detachControl(element: Nullable<HTMLElement>): void;
  38710. /**
  38711. * Update the current camera state depending on the inputs that have been used this frame.
  38712. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38713. */
  38714. checkInputs(): void;
  38715. /**
  38716. * Gets the class name of the current intput.
  38717. * @returns the class name
  38718. */
  38719. getClassName(): string;
  38720. /**
  38721. * Get the friendly name associated with the input class.
  38722. * @returns the input friendly name
  38723. */
  38724. getSimpleName(): string;
  38725. }
  38726. }
  38727. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  38728. import { Nullable } from "babylonjs/types";
  38729. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38730. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38731. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38732. /**
  38733. * Manage the gamepad inputs to control a free camera.
  38734. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38735. */
  38736. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38737. /**
  38738. * Define the camera the input is attached to.
  38739. */
  38740. camera: FreeCamera;
  38741. /**
  38742. * Define the Gamepad controlling the input
  38743. */
  38744. gamepad: Nullable<Gamepad>;
  38745. /**
  38746. * Defines the gamepad rotation sensiblity.
  38747. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38748. */
  38749. gamepadAngularSensibility: number;
  38750. /**
  38751. * Defines the gamepad move sensiblity.
  38752. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38753. */
  38754. gamepadMoveSensibility: number;
  38755. private _onGamepadConnectedObserver;
  38756. private _onGamepadDisconnectedObserver;
  38757. private _cameraTransform;
  38758. private _deltaTransform;
  38759. private _vector3;
  38760. private _vector2;
  38761. /**
  38762. * Attach the input controls to a specific dom element to get the input from.
  38763. * @param element Defines the element the controls should be listened from
  38764. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38765. */
  38766. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38767. /**
  38768. * Detach the current controls from the specified dom element.
  38769. * @param element Defines the element to stop listening the inputs from
  38770. */
  38771. detachControl(element: Nullable<HTMLElement>): void;
  38772. /**
  38773. * Update the current camera state depending on the inputs that have been used this frame.
  38774. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38775. */
  38776. checkInputs(): void;
  38777. /**
  38778. * Gets the class name of the current intput.
  38779. * @returns the class name
  38780. */
  38781. getClassName(): string;
  38782. /**
  38783. * Get the friendly name associated with the input class.
  38784. * @returns the input friendly name
  38785. */
  38786. getSimpleName(): string;
  38787. }
  38788. }
  38789. declare module "babylonjs/Misc/virtualJoystick" {
  38790. import { Nullable } from "babylonjs/types";
  38791. import { Vector3 } from "babylonjs/Maths/math";
  38792. /**
  38793. * Defines the potential axis of a Joystick
  38794. */
  38795. export enum JoystickAxis {
  38796. /** X axis */
  38797. X = 0,
  38798. /** Y axis */
  38799. Y = 1,
  38800. /** Z axis */
  38801. Z = 2
  38802. }
  38803. /**
  38804. * Class used to define virtual joystick (used in touch mode)
  38805. */
  38806. export class VirtualJoystick {
  38807. /**
  38808. * Gets or sets a boolean indicating that left and right values must be inverted
  38809. */
  38810. reverseLeftRight: boolean;
  38811. /**
  38812. * Gets or sets a boolean indicating that up and down values must be inverted
  38813. */
  38814. reverseUpDown: boolean;
  38815. /**
  38816. * Gets the offset value for the position (ie. the change of the position value)
  38817. */
  38818. deltaPosition: Vector3;
  38819. /**
  38820. * Gets a boolean indicating if the virtual joystick was pressed
  38821. */
  38822. pressed: boolean;
  38823. /**
  38824. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38825. */
  38826. static Canvas: Nullable<HTMLCanvasElement>;
  38827. private static _globalJoystickIndex;
  38828. private static vjCanvasContext;
  38829. private static vjCanvasWidth;
  38830. private static vjCanvasHeight;
  38831. private static halfWidth;
  38832. private _action;
  38833. private _axisTargetedByLeftAndRight;
  38834. private _axisTargetedByUpAndDown;
  38835. private _joystickSensibility;
  38836. private _inversedSensibility;
  38837. private _joystickPointerID;
  38838. private _joystickColor;
  38839. private _joystickPointerPos;
  38840. private _joystickPreviousPointerPos;
  38841. private _joystickPointerStartPos;
  38842. private _deltaJoystickVector;
  38843. private _leftJoystick;
  38844. private _touches;
  38845. private _onPointerDownHandlerRef;
  38846. private _onPointerMoveHandlerRef;
  38847. private _onPointerUpHandlerRef;
  38848. private _onResize;
  38849. /**
  38850. * Creates a new virtual joystick
  38851. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38852. */
  38853. constructor(leftJoystick?: boolean);
  38854. /**
  38855. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38856. * @param newJoystickSensibility defines the new sensibility
  38857. */
  38858. setJoystickSensibility(newJoystickSensibility: number): void;
  38859. private _onPointerDown;
  38860. private _onPointerMove;
  38861. private _onPointerUp;
  38862. /**
  38863. * Change the color of the virtual joystick
  38864. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38865. */
  38866. setJoystickColor(newColor: string): void;
  38867. /**
  38868. * Defines a callback to call when the joystick is touched
  38869. * @param action defines the callback
  38870. */
  38871. setActionOnTouch(action: () => any): void;
  38872. /**
  38873. * Defines which axis you'd like to control for left & right
  38874. * @param axis defines the axis to use
  38875. */
  38876. setAxisForLeftRight(axis: JoystickAxis): void;
  38877. /**
  38878. * Defines which axis you'd like to control for up & down
  38879. * @param axis defines the axis to use
  38880. */
  38881. setAxisForUpDown(axis: JoystickAxis): void;
  38882. private _drawVirtualJoystick;
  38883. /**
  38884. * Release internal HTML canvas
  38885. */
  38886. releaseCanvas(): void;
  38887. }
  38888. }
  38889. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38890. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38891. import { Nullable } from "babylonjs/types";
  38892. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38893. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38894. module "babylonjs/Cameras/freeCameraInputsManager" {
  38895. interface FreeCameraInputsManager {
  38896. /**
  38897. * Add virtual joystick input support to the input manager.
  38898. * @returns the current input manager
  38899. */
  38900. addVirtualJoystick(): FreeCameraInputsManager;
  38901. }
  38902. }
  38903. /**
  38904. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38905. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38906. */
  38907. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38908. /**
  38909. * Defines the camera the input is attached to.
  38910. */
  38911. camera: FreeCamera;
  38912. private _leftjoystick;
  38913. private _rightjoystick;
  38914. /**
  38915. * Gets the left stick of the virtual joystick.
  38916. * @returns The virtual Joystick
  38917. */
  38918. getLeftJoystick(): VirtualJoystick;
  38919. /**
  38920. * Gets the right stick of the virtual joystick.
  38921. * @returns The virtual Joystick
  38922. */
  38923. getRightJoystick(): VirtualJoystick;
  38924. /**
  38925. * Update the current camera state depending on the inputs that have been used this frame.
  38926. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38927. */
  38928. checkInputs(): void;
  38929. /**
  38930. * Attach the input controls to a specific dom element to get the input from.
  38931. * @param element Defines the element the controls should be listened from
  38932. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38933. */
  38934. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38935. /**
  38936. * Detach the current controls from the specified dom element.
  38937. * @param element Defines the element to stop listening the inputs from
  38938. */
  38939. detachControl(element: Nullable<HTMLElement>): void;
  38940. /**
  38941. * Gets the class name of the current intput.
  38942. * @returns the class name
  38943. */
  38944. getClassName(): string;
  38945. /**
  38946. * Get the friendly name associated with the input class.
  38947. * @returns the input friendly name
  38948. */
  38949. getSimpleName(): string;
  38950. }
  38951. }
  38952. declare module "babylonjs/Cameras/Inputs/index" {
  38953. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38954. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38955. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38956. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38957. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38958. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38959. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38960. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38961. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38962. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38963. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38964. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38965. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38966. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38967. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38968. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38969. }
  38970. declare module "babylonjs/Cameras/touchCamera" {
  38971. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38972. import { Scene } from "babylonjs/scene";
  38973. import { Vector3 } from "babylonjs/Maths/math";
  38974. /**
  38975. * This represents a FPS type of camera controlled by touch.
  38976. * This is like a universal camera minus the Gamepad controls.
  38977. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38978. */
  38979. export class TouchCamera extends FreeCamera {
  38980. /**
  38981. * Defines the touch sensibility for rotation.
  38982. * The higher the faster.
  38983. */
  38984. touchAngularSensibility: number;
  38985. /**
  38986. * Defines the touch sensibility for move.
  38987. * The higher the faster.
  38988. */
  38989. touchMoveSensibility: number;
  38990. /**
  38991. * Instantiates a new touch camera.
  38992. * This represents a FPS type of camera controlled by touch.
  38993. * This is like a universal camera minus the Gamepad controls.
  38994. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38995. * @param name Define the name of the camera in the scene
  38996. * @param position Define the start position of the camera in the scene
  38997. * @param scene Define the scene the camera belongs to
  38998. */
  38999. constructor(name: string, position: Vector3, scene: Scene);
  39000. /**
  39001. * Gets the current object class name.
  39002. * @return the class name
  39003. */
  39004. getClassName(): string;
  39005. /** @hidden */
  39006. _setupInputs(): void;
  39007. }
  39008. }
  39009. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39010. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39011. import { Scene } from "babylonjs/scene";
  39012. import { Vector3, Axis } from "babylonjs/Maths/math";
  39013. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39014. /**
  39015. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39016. * being tilted forward or back and left or right.
  39017. */
  39018. export class DeviceOrientationCamera extends FreeCamera {
  39019. private _initialQuaternion;
  39020. private _quaternionCache;
  39021. private _tmpDragQuaternion;
  39022. /**
  39023. * Creates a new device orientation camera
  39024. * @param name The name of the camera
  39025. * @param position The start position camera
  39026. * @param scene The scene the camera belongs to
  39027. */
  39028. constructor(name: string, position: Vector3, scene: Scene);
  39029. /**
  39030. * @hidden
  39031. * Disabled pointer input on first orientation sensor update (Default: true)
  39032. */
  39033. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  39034. private _dragFactor;
  39035. /**
  39036. * Enabled turning on the y axis when the orientation sensor is active
  39037. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39038. */
  39039. enableHorizontalDragging(dragFactor?: number): void;
  39040. /**
  39041. * Gets the current instance class name ("DeviceOrientationCamera").
  39042. * This helps avoiding instanceof at run time.
  39043. * @returns the class name
  39044. */
  39045. getClassName(): string;
  39046. /**
  39047. * @hidden
  39048. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39049. */
  39050. _checkInputs(): void;
  39051. /**
  39052. * Reset the camera to its default orientation on the specified axis only.
  39053. * @param axis The axis to reset
  39054. */
  39055. resetToCurrentRotation(axis?: Axis): void;
  39056. }
  39057. }
  39058. declare module "babylonjs/Gamepads/xboxGamepad" {
  39059. import { Observable } from "babylonjs/Misc/observable";
  39060. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39061. /**
  39062. * Defines supported buttons for XBox360 compatible gamepads
  39063. */
  39064. export enum Xbox360Button {
  39065. /** A */
  39066. A = 0,
  39067. /** B */
  39068. B = 1,
  39069. /** X */
  39070. X = 2,
  39071. /** Y */
  39072. Y = 3,
  39073. /** Start */
  39074. Start = 4,
  39075. /** Back */
  39076. Back = 5,
  39077. /** Left button */
  39078. LB = 6,
  39079. /** Right button */
  39080. RB = 7,
  39081. /** Left stick */
  39082. LeftStick = 8,
  39083. /** Right stick */
  39084. RightStick = 9
  39085. }
  39086. /** Defines values for XBox360 DPad */
  39087. export enum Xbox360Dpad {
  39088. /** Up */
  39089. Up = 0,
  39090. /** Down */
  39091. Down = 1,
  39092. /** Left */
  39093. Left = 2,
  39094. /** Right */
  39095. Right = 3
  39096. }
  39097. /**
  39098. * Defines a XBox360 gamepad
  39099. */
  39100. export class Xbox360Pad extends Gamepad {
  39101. private _leftTrigger;
  39102. private _rightTrigger;
  39103. private _onlefttriggerchanged;
  39104. private _onrighttriggerchanged;
  39105. private _onbuttondown;
  39106. private _onbuttonup;
  39107. private _ondpaddown;
  39108. private _ondpadup;
  39109. /** Observable raised when a button is pressed */
  39110. onButtonDownObservable: Observable<Xbox360Button>;
  39111. /** Observable raised when a button is released */
  39112. onButtonUpObservable: Observable<Xbox360Button>;
  39113. /** Observable raised when a pad is pressed */
  39114. onPadDownObservable: Observable<Xbox360Dpad>;
  39115. /** Observable raised when a pad is released */
  39116. onPadUpObservable: Observable<Xbox360Dpad>;
  39117. private _buttonA;
  39118. private _buttonB;
  39119. private _buttonX;
  39120. private _buttonY;
  39121. private _buttonBack;
  39122. private _buttonStart;
  39123. private _buttonLB;
  39124. private _buttonRB;
  39125. private _buttonLeftStick;
  39126. private _buttonRightStick;
  39127. private _dPadUp;
  39128. private _dPadDown;
  39129. private _dPadLeft;
  39130. private _dPadRight;
  39131. private _isXboxOnePad;
  39132. /**
  39133. * Creates a new XBox360 gamepad object
  39134. * @param id defines the id of this gamepad
  39135. * @param index defines its index
  39136. * @param gamepad defines the internal HTML gamepad object
  39137. * @param xboxOne defines if it is a XBox One gamepad
  39138. */
  39139. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39140. /**
  39141. * Defines the callback to call when left trigger is pressed
  39142. * @param callback defines the callback to use
  39143. */
  39144. onlefttriggerchanged(callback: (value: number) => void): void;
  39145. /**
  39146. * Defines the callback to call when right trigger is pressed
  39147. * @param callback defines the callback to use
  39148. */
  39149. onrighttriggerchanged(callback: (value: number) => void): void;
  39150. /**
  39151. * Gets the left trigger value
  39152. */
  39153. /**
  39154. * Sets the left trigger value
  39155. */
  39156. leftTrigger: number;
  39157. /**
  39158. * Gets the right trigger value
  39159. */
  39160. /**
  39161. * Sets the right trigger value
  39162. */
  39163. rightTrigger: number;
  39164. /**
  39165. * Defines the callback to call when a button is pressed
  39166. * @param callback defines the callback to use
  39167. */
  39168. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39169. /**
  39170. * Defines the callback to call when a button is released
  39171. * @param callback defines the callback to use
  39172. */
  39173. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39174. /**
  39175. * Defines the callback to call when a pad is pressed
  39176. * @param callback defines the callback to use
  39177. */
  39178. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39179. /**
  39180. * Defines the callback to call when a pad is released
  39181. * @param callback defines the callback to use
  39182. */
  39183. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39184. private _setButtonValue;
  39185. private _setDPadValue;
  39186. /**
  39187. * Gets the value of the `A` button
  39188. */
  39189. /**
  39190. * Sets the value of the `A` button
  39191. */
  39192. buttonA: number;
  39193. /**
  39194. * Gets the value of the `B` button
  39195. */
  39196. /**
  39197. * Sets the value of the `B` button
  39198. */
  39199. buttonB: number;
  39200. /**
  39201. * Gets the value of the `X` button
  39202. */
  39203. /**
  39204. * Sets the value of the `X` button
  39205. */
  39206. buttonX: number;
  39207. /**
  39208. * Gets the value of the `Y` button
  39209. */
  39210. /**
  39211. * Sets the value of the `Y` button
  39212. */
  39213. buttonY: number;
  39214. /**
  39215. * Gets the value of the `Start` button
  39216. */
  39217. /**
  39218. * Sets the value of the `Start` button
  39219. */
  39220. buttonStart: number;
  39221. /**
  39222. * Gets the value of the `Back` button
  39223. */
  39224. /**
  39225. * Sets the value of the `Back` button
  39226. */
  39227. buttonBack: number;
  39228. /**
  39229. * Gets the value of the `Left` button
  39230. */
  39231. /**
  39232. * Sets the value of the `Left` button
  39233. */
  39234. buttonLB: number;
  39235. /**
  39236. * Gets the value of the `Right` button
  39237. */
  39238. /**
  39239. * Sets the value of the `Right` button
  39240. */
  39241. buttonRB: number;
  39242. /**
  39243. * Gets the value of the Left joystick
  39244. */
  39245. /**
  39246. * Sets the value of the Left joystick
  39247. */
  39248. buttonLeftStick: number;
  39249. /**
  39250. * Gets the value of the Right joystick
  39251. */
  39252. /**
  39253. * Sets the value of the Right joystick
  39254. */
  39255. buttonRightStick: number;
  39256. /**
  39257. * Gets the value of D-pad up
  39258. */
  39259. /**
  39260. * Sets the value of D-pad up
  39261. */
  39262. dPadUp: number;
  39263. /**
  39264. * Gets the value of D-pad down
  39265. */
  39266. /**
  39267. * Sets the value of D-pad down
  39268. */
  39269. dPadDown: number;
  39270. /**
  39271. * Gets the value of D-pad left
  39272. */
  39273. /**
  39274. * Sets the value of D-pad left
  39275. */
  39276. dPadLeft: number;
  39277. /**
  39278. * Gets the value of D-pad right
  39279. */
  39280. /**
  39281. * Sets the value of D-pad right
  39282. */
  39283. dPadRight: number;
  39284. /**
  39285. * Force the gamepad to synchronize with device values
  39286. */
  39287. update(): void;
  39288. /**
  39289. * Disposes the gamepad
  39290. */
  39291. dispose(): void;
  39292. }
  39293. }
  39294. declare module "babylonjs/Gamepads/gamepadManager" {
  39295. import { Observable } from "babylonjs/Misc/observable";
  39296. import { Nullable } from "babylonjs/types";
  39297. import { Scene } from "babylonjs/scene";
  39298. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39299. /**
  39300. * Manager for handling gamepads
  39301. */
  39302. export class GamepadManager {
  39303. private _scene?;
  39304. private _babylonGamepads;
  39305. private _oneGamepadConnected;
  39306. /** @hidden */
  39307. _isMonitoring: boolean;
  39308. private _gamepadEventSupported;
  39309. private _gamepadSupport;
  39310. /**
  39311. * observable to be triggered when the gamepad controller has been connected
  39312. */
  39313. onGamepadConnectedObservable: Observable<Gamepad>;
  39314. /**
  39315. * observable to be triggered when the gamepad controller has been disconnected
  39316. */
  39317. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39318. private _onGamepadConnectedEvent;
  39319. private _onGamepadDisconnectedEvent;
  39320. /**
  39321. * Initializes the gamepad manager
  39322. * @param _scene BabylonJS scene
  39323. */
  39324. constructor(_scene?: Scene | undefined);
  39325. /**
  39326. * The gamepads in the game pad manager
  39327. */
  39328. readonly gamepads: Gamepad[];
  39329. /**
  39330. * Get the gamepad controllers based on type
  39331. * @param type The type of gamepad controller
  39332. * @returns Nullable gamepad
  39333. */
  39334. getGamepadByType(type?: number): Nullable<Gamepad>;
  39335. /**
  39336. * Disposes the gamepad manager
  39337. */
  39338. dispose(): void;
  39339. private _addNewGamepad;
  39340. private _startMonitoringGamepads;
  39341. private _stopMonitoringGamepads;
  39342. /** @hidden */
  39343. _checkGamepadsStatus(): void;
  39344. private _updateGamepadObjects;
  39345. }
  39346. }
  39347. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39348. import { Nullable } from "babylonjs/types";
  39349. import { Scene } from "babylonjs/scene";
  39350. import { ISceneComponent } from "babylonjs/sceneComponent";
  39351. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39352. module "babylonjs/scene" {
  39353. interface Scene {
  39354. /** @hidden */
  39355. _gamepadManager: Nullable<GamepadManager>;
  39356. /**
  39357. * Gets the gamepad manager associated with the scene
  39358. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39359. */
  39360. gamepadManager: GamepadManager;
  39361. }
  39362. }
  39363. module "babylonjs/Cameras/freeCameraInputsManager" {
  39364. /**
  39365. * Interface representing a free camera inputs manager
  39366. */
  39367. interface FreeCameraInputsManager {
  39368. /**
  39369. * Adds gamepad input support to the FreeCameraInputsManager.
  39370. * @returns the FreeCameraInputsManager
  39371. */
  39372. addGamepad(): FreeCameraInputsManager;
  39373. }
  39374. }
  39375. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39376. /**
  39377. * Interface representing an arc rotate camera inputs manager
  39378. */
  39379. interface ArcRotateCameraInputsManager {
  39380. /**
  39381. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39382. * @returns the camera inputs manager
  39383. */
  39384. addGamepad(): ArcRotateCameraInputsManager;
  39385. }
  39386. }
  39387. /**
  39388. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39389. */
  39390. export class GamepadSystemSceneComponent implements ISceneComponent {
  39391. /**
  39392. * The component name helpfull to identify the component in the list of scene components.
  39393. */
  39394. readonly name: string;
  39395. /**
  39396. * The scene the component belongs to.
  39397. */
  39398. scene: Scene;
  39399. /**
  39400. * Creates a new instance of the component for the given scene
  39401. * @param scene Defines the scene to register the component in
  39402. */
  39403. constructor(scene: Scene);
  39404. /**
  39405. * Registers the component in a given scene
  39406. */
  39407. register(): void;
  39408. /**
  39409. * Rebuilds the elements related to this component in case of
  39410. * context lost for instance.
  39411. */
  39412. rebuild(): void;
  39413. /**
  39414. * Disposes the component and the associated ressources
  39415. */
  39416. dispose(): void;
  39417. private _beforeCameraUpdate;
  39418. }
  39419. }
  39420. declare module "babylonjs/Cameras/universalCamera" {
  39421. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  39422. import { Scene } from "babylonjs/scene";
  39423. import { Vector3 } from "babylonjs/Maths/math";
  39424. import "babylonjs/Gamepads/gamepadSceneComponent";
  39425. /**
  39426. * 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,
  39427. * which still works and will still be found in many Playgrounds.
  39428. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39429. */
  39430. export class UniversalCamera extends TouchCamera {
  39431. /**
  39432. * Defines the gamepad rotation sensiblity.
  39433. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39434. */
  39435. gamepadAngularSensibility: number;
  39436. /**
  39437. * Defines the gamepad move sensiblity.
  39438. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39439. */
  39440. gamepadMoveSensibility: number;
  39441. /**
  39442. * 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,
  39443. * which still works and will still be found in many Playgrounds.
  39444. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39445. * @param name Define the name of the camera in the scene
  39446. * @param position Define the start position of the camera in the scene
  39447. * @param scene Define the scene the camera belongs to
  39448. */
  39449. constructor(name: string, position: Vector3, scene: Scene);
  39450. /**
  39451. * Gets the current object class name.
  39452. * @return the class name
  39453. */
  39454. getClassName(): string;
  39455. }
  39456. }
  39457. declare module "babylonjs/Cameras/gamepadCamera" {
  39458. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39459. import { Scene } from "babylonjs/scene";
  39460. import { Vector3 } from "babylonjs/Maths/math";
  39461. /**
  39462. * This represents a FPS type of camera. This is only here for back compat purpose.
  39463. * Please use the UniversalCamera instead as both are identical.
  39464. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39465. */
  39466. export class GamepadCamera extends UniversalCamera {
  39467. /**
  39468. * Instantiates a new Gamepad Camera
  39469. * This represents a FPS type of camera. This is only here for back compat purpose.
  39470. * Please use the UniversalCamera instead as both are identical.
  39471. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39472. * @param name Define the name of the camera in the scene
  39473. * @param position Define the start position of the camera in the scene
  39474. * @param scene Define the scene the camera belongs to
  39475. */
  39476. constructor(name: string, position: Vector3, scene: Scene);
  39477. /**
  39478. * Gets the current object class name.
  39479. * @return the class name
  39480. */
  39481. getClassName(): string;
  39482. }
  39483. }
  39484. declare module "babylonjs/Shaders/pass.fragment" {
  39485. /** @hidden */
  39486. export var passPixelShader: {
  39487. name: string;
  39488. shader: string;
  39489. };
  39490. }
  39491. declare module "babylonjs/Shaders/passCube.fragment" {
  39492. /** @hidden */
  39493. export var passCubePixelShader: {
  39494. name: string;
  39495. shader: string;
  39496. };
  39497. }
  39498. declare module "babylonjs/PostProcesses/passPostProcess" {
  39499. import { Nullable } from "babylonjs/types";
  39500. import { Camera } from "babylonjs/Cameras/camera";
  39501. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39502. import { Engine } from "babylonjs/Engines/engine";
  39503. import "babylonjs/Shaders/pass.fragment";
  39504. import "babylonjs/Shaders/passCube.fragment";
  39505. /**
  39506. * PassPostProcess which produces an output the same as it's input
  39507. */
  39508. export class PassPostProcess extends PostProcess {
  39509. /**
  39510. * Creates the PassPostProcess
  39511. * @param name The name of the effect.
  39512. * @param options The required width/height ratio to downsize to before computing the render pass.
  39513. * @param camera The camera to apply the render pass to.
  39514. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39515. * @param engine The engine which the post process will be applied. (default: current engine)
  39516. * @param reusable If the post process can be reused on the same frame. (default: false)
  39517. * @param textureType The type of texture to be used when performing the post processing.
  39518. * @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)
  39519. */
  39520. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39521. }
  39522. /**
  39523. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39524. */
  39525. export class PassCubePostProcess extends PostProcess {
  39526. private _face;
  39527. /**
  39528. * Gets or sets the cube face to display.
  39529. * * 0 is +X
  39530. * * 1 is -X
  39531. * * 2 is +Y
  39532. * * 3 is -Y
  39533. * * 4 is +Z
  39534. * * 5 is -Z
  39535. */
  39536. face: number;
  39537. /**
  39538. * Creates the PassCubePostProcess
  39539. * @param name The name of the effect.
  39540. * @param options The required width/height ratio to downsize to before computing the render pass.
  39541. * @param camera The camera to apply the render pass to.
  39542. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39543. * @param engine The engine which the post process will be applied. (default: current engine)
  39544. * @param reusable If the post process can be reused on the same frame. (default: false)
  39545. * @param textureType The type of texture to be used when performing the post processing.
  39546. * @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)
  39547. */
  39548. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39549. }
  39550. }
  39551. declare module "babylonjs/Shaders/anaglyph.fragment" {
  39552. /** @hidden */
  39553. export var anaglyphPixelShader: {
  39554. name: string;
  39555. shader: string;
  39556. };
  39557. }
  39558. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  39559. import { Engine } from "babylonjs/Engines/engine";
  39560. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39561. import { Camera } from "babylonjs/Cameras/camera";
  39562. import "babylonjs/Shaders/anaglyph.fragment";
  39563. /**
  39564. * Postprocess used to generate anaglyphic rendering
  39565. */
  39566. export class AnaglyphPostProcess extends PostProcess {
  39567. private _passedProcess;
  39568. /**
  39569. * Creates a new AnaglyphPostProcess
  39570. * @param name defines postprocess name
  39571. * @param options defines creation options or target ratio scale
  39572. * @param rigCameras defines cameras using this postprocess
  39573. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39574. * @param engine defines hosting engine
  39575. * @param reusable defines if the postprocess will be reused multiple times per frame
  39576. */
  39577. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39578. }
  39579. }
  39580. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  39581. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  39582. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39583. import { Scene } from "babylonjs/scene";
  39584. import { Vector3 } from "babylonjs/Maths/math";
  39585. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39586. /**
  39587. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39588. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39589. */
  39590. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39591. /**
  39592. * Creates a new AnaglyphArcRotateCamera
  39593. * @param name defines camera name
  39594. * @param alpha defines alpha angle (in radians)
  39595. * @param beta defines beta angle (in radians)
  39596. * @param radius defines radius
  39597. * @param target defines camera target
  39598. * @param interaxialDistance defines distance between each color axis
  39599. * @param scene defines the hosting scene
  39600. */
  39601. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39602. /**
  39603. * Gets camera class name
  39604. * @returns AnaglyphArcRotateCamera
  39605. */
  39606. getClassName(): string;
  39607. }
  39608. }
  39609. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  39610. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39611. import { Scene } from "babylonjs/scene";
  39612. import { Vector3 } from "babylonjs/Maths/math";
  39613. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39614. /**
  39615. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39616. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39617. */
  39618. export class AnaglyphFreeCamera extends FreeCamera {
  39619. /**
  39620. * Creates a new AnaglyphFreeCamera
  39621. * @param name defines camera name
  39622. * @param position defines initial position
  39623. * @param interaxialDistance defines distance between each color axis
  39624. * @param scene defines the hosting scene
  39625. */
  39626. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39627. /**
  39628. * Gets camera class name
  39629. * @returns AnaglyphFreeCamera
  39630. */
  39631. getClassName(): string;
  39632. }
  39633. }
  39634. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  39635. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39636. import { Scene } from "babylonjs/scene";
  39637. import { Vector3 } from "babylonjs/Maths/math";
  39638. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39639. /**
  39640. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39641. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39642. */
  39643. export class AnaglyphGamepadCamera extends GamepadCamera {
  39644. /**
  39645. * Creates a new AnaglyphGamepadCamera
  39646. * @param name defines camera name
  39647. * @param position defines initial position
  39648. * @param interaxialDistance defines distance between each color axis
  39649. * @param scene defines the hosting scene
  39650. */
  39651. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39652. /**
  39653. * Gets camera class name
  39654. * @returns AnaglyphGamepadCamera
  39655. */
  39656. getClassName(): string;
  39657. }
  39658. }
  39659. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  39660. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39661. import { Scene } from "babylonjs/scene";
  39662. import { Vector3 } from "babylonjs/Maths/math";
  39663. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39664. /**
  39665. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39666. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39667. */
  39668. export class AnaglyphUniversalCamera extends UniversalCamera {
  39669. /**
  39670. * Creates a new AnaglyphUniversalCamera
  39671. * @param name defines camera name
  39672. * @param position defines initial position
  39673. * @param interaxialDistance defines distance between each color axis
  39674. * @param scene defines the hosting scene
  39675. */
  39676. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39677. /**
  39678. * Gets camera class name
  39679. * @returns AnaglyphUniversalCamera
  39680. */
  39681. getClassName(): string;
  39682. }
  39683. }
  39684. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  39685. /** @hidden */
  39686. export var stereoscopicInterlacePixelShader: {
  39687. name: string;
  39688. shader: string;
  39689. };
  39690. }
  39691. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  39692. import { Camera } from "babylonjs/Cameras/camera";
  39693. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39694. import { Engine } from "babylonjs/Engines/engine";
  39695. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  39696. /**
  39697. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39698. */
  39699. export class StereoscopicInterlacePostProcess extends PostProcess {
  39700. private _stepSize;
  39701. private _passedProcess;
  39702. /**
  39703. * Initializes a StereoscopicInterlacePostProcess
  39704. * @param name The name of the effect.
  39705. * @param rigCameras The rig cameras to be appled to the post process
  39706. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39707. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39708. * @param engine The engine which the post process will be applied. (default: current engine)
  39709. * @param reusable If the post process can be reused on the same frame. (default: false)
  39710. */
  39711. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39712. }
  39713. }
  39714. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  39715. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  39716. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39717. import { Scene } from "babylonjs/scene";
  39718. import { Vector3 } from "babylonjs/Maths/math";
  39719. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39720. /**
  39721. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39722. * @see http://doc.babylonjs.com/features/cameras
  39723. */
  39724. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39725. /**
  39726. * Creates a new StereoscopicArcRotateCamera
  39727. * @param name defines camera name
  39728. * @param alpha defines alpha angle (in radians)
  39729. * @param beta defines beta angle (in radians)
  39730. * @param radius defines radius
  39731. * @param target defines camera target
  39732. * @param interaxialDistance defines distance between each color axis
  39733. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39734. * @param scene defines the hosting scene
  39735. */
  39736. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39737. /**
  39738. * Gets camera class name
  39739. * @returns StereoscopicArcRotateCamera
  39740. */
  39741. getClassName(): string;
  39742. }
  39743. }
  39744. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  39745. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39746. import { Scene } from "babylonjs/scene";
  39747. import { Vector3 } from "babylonjs/Maths/math";
  39748. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39749. /**
  39750. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39751. * @see http://doc.babylonjs.com/features/cameras
  39752. */
  39753. export class StereoscopicFreeCamera extends FreeCamera {
  39754. /**
  39755. * Creates a new StereoscopicFreeCamera
  39756. * @param name defines camera name
  39757. * @param position defines initial position
  39758. * @param interaxialDistance defines distance between each color axis
  39759. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39760. * @param scene defines the hosting scene
  39761. */
  39762. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39763. /**
  39764. * Gets camera class name
  39765. * @returns StereoscopicFreeCamera
  39766. */
  39767. getClassName(): string;
  39768. }
  39769. }
  39770. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  39771. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39772. import { Scene } from "babylonjs/scene";
  39773. import { Vector3 } from "babylonjs/Maths/math";
  39774. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39775. /**
  39776. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39777. * @see http://doc.babylonjs.com/features/cameras
  39778. */
  39779. export class StereoscopicGamepadCamera extends GamepadCamera {
  39780. /**
  39781. * Creates a new StereoscopicGamepadCamera
  39782. * @param name defines camera name
  39783. * @param position defines initial position
  39784. * @param interaxialDistance defines distance between each color axis
  39785. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39786. * @param scene defines the hosting scene
  39787. */
  39788. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39789. /**
  39790. * Gets camera class name
  39791. * @returns StereoscopicGamepadCamera
  39792. */
  39793. getClassName(): string;
  39794. }
  39795. }
  39796. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  39797. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39798. import { Scene } from "babylonjs/scene";
  39799. import { Vector3 } from "babylonjs/Maths/math";
  39800. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39801. /**
  39802. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39803. * @see http://doc.babylonjs.com/features/cameras
  39804. */
  39805. export class StereoscopicUniversalCamera extends UniversalCamera {
  39806. /**
  39807. * Creates a new StereoscopicUniversalCamera
  39808. * @param name defines camera name
  39809. * @param position defines initial position
  39810. * @param interaxialDistance defines distance between each color axis
  39811. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39812. * @param scene defines the hosting scene
  39813. */
  39814. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39815. /**
  39816. * Gets camera class name
  39817. * @returns StereoscopicUniversalCamera
  39818. */
  39819. getClassName(): string;
  39820. }
  39821. }
  39822. declare module "babylonjs/Cameras/Stereoscopic/index" {
  39823. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  39824. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  39825. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  39826. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  39827. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  39828. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  39829. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  39830. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  39831. }
  39832. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  39833. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39834. import { Scene } from "babylonjs/scene";
  39835. import { Vector3 } from "babylonjs/Maths/math";
  39836. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39837. /**
  39838. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39839. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39840. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39841. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39842. */
  39843. export class VirtualJoysticksCamera extends FreeCamera {
  39844. /**
  39845. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39846. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39847. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39848. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39849. * @param name Define the name of the camera in the scene
  39850. * @param position Define the start position of the camera in the scene
  39851. * @param scene Define the scene the camera belongs to
  39852. */
  39853. constructor(name: string, position: Vector3, scene: Scene);
  39854. /**
  39855. * Gets the current object class name.
  39856. * @return the class name
  39857. */
  39858. getClassName(): string;
  39859. }
  39860. }
  39861. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  39862. import { Matrix } from "babylonjs/Maths/math";
  39863. /**
  39864. * This represents all the required metrics to create a VR camera.
  39865. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39866. */
  39867. export class VRCameraMetrics {
  39868. /**
  39869. * Define the horizontal resolution off the screen.
  39870. */
  39871. hResolution: number;
  39872. /**
  39873. * Define the vertical resolution off the screen.
  39874. */
  39875. vResolution: number;
  39876. /**
  39877. * Define the horizontal screen size.
  39878. */
  39879. hScreenSize: number;
  39880. /**
  39881. * Define the vertical screen size.
  39882. */
  39883. vScreenSize: number;
  39884. /**
  39885. * Define the vertical screen center position.
  39886. */
  39887. vScreenCenter: number;
  39888. /**
  39889. * Define the distance of the eyes to the screen.
  39890. */
  39891. eyeToScreenDistance: number;
  39892. /**
  39893. * Define the distance between both lenses
  39894. */
  39895. lensSeparationDistance: number;
  39896. /**
  39897. * Define the distance between both viewer's eyes.
  39898. */
  39899. interpupillaryDistance: number;
  39900. /**
  39901. * Define the distortion factor of the VR postprocess.
  39902. * Please, touch with care.
  39903. */
  39904. distortionK: number[];
  39905. /**
  39906. * Define the chromatic aberration correction factors for the VR post process.
  39907. */
  39908. chromaAbCorrection: number[];
  39909. /**
  39910. * Define the scale factor of the post process.
  39911. * The smaller the better but the slower.
  39912. */
  39913. postProcessScaleFactor: number;
  39914. /**
  39915. * Define an offset for the lens center.
  39916. */
  39917. lensCenterOffset: number;
  39918. /**
  39919. * Define if the current vr camera should compensate the distortion of the lense or not.
  39920. */
  39921. compensateDistortion: boolean;
  39922. /**
  39923. * Defines if multiview should be enabled when rendering (Default: false)
  39924. */
  39925. multiviewEnabled: boolean;
  39926. /**
  39927. * Gets the rendering aspect ratio based on the provided resolutions.
  39928. */
  39929. readonly aspectRatio: number;
  39930. /**
  39931. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39932. */
  39933. readonly aspectRatioFov: number;
  39934. /**
  39935. * @hidden
  39936. */
  39937. readonly leftHMatrix: Matrix;
  39938. /**
  39939. * @hidden
  39940. */
  39941. readonly rightHMatrix: Matrix;
  39942. /**
  39943. * @hidden
  39944. */
  39945. readonly leftPreViewMatrix: Matrix;
  39946. /**
  39947. * @hidden
  39948. */
  39949. readonly rightPreViewMatrix: Matrix;
  39950. /**
  39951. * Get the default VRMetrics based on the most generic setup.
  39952. * @returns the default vr metrics
  39953. */
  39954. static GetDefault(): VRCameraMetrics;
  39955. }
  39956. }
  39957. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  39958. /** @hidden */
  39959. export var vrDistortionCorrectionPixelShader: {
  39960. name: string;
  39961. shader: string;
  39962. };
  39963. }
  39964. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  39965. import { Camera } from "babylonjs/Cameras/camera";
  39966. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39967. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39968. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  39969. /**
  39970. * VRDistortionCorrectionPostProcess used for mobile VR
  39971. */
  39972. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39973. private _isRightEye;
  39974. private _distortionFactors;
  39975. private _postProcessScaleFactor;
  39976. private _lensCenterOffset;
  39977. private _scaleIn;
  39978. private _scaleFactor;
  39979. private _lensCenter;
  39980. /**
  39981. * Initializes the VRDistortionCorrectionPostProcess
  39982. * @param name The name of the effect.
  39983. * @param camera The camera to apply the render pass to.
  39984. * @param isRightEye If this is for the right eye distortion
  39985. * @param vrMetrics All the required metrics for the VR camera
  39986. */
  39987. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39988. }
  39989. }
  39990. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  39991. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  39992. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39993. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39994. import { Scene } from "babylonjs/scene";
  39995. import { Vector3 } from "babylonjs/Maths/math";
  39996. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39997. import "babylonjs/Cameras/RigModes/vrRigMode";
  39998. /**
  39999. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40000. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40001. */
  40002. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40003. /**
  40004. * Creates a new VRDeviceOrientationArcRotateCamera
  40005. * @param name defines camera name
  40006. * @param alpha defines the camera rotation along the logitudinal axis
  40007. * @param beta defines the camera rotation along the latitudinal axis
  40008. * @param radius defines the camera distance from its target
  40009. * @param target defines the camera target
  40010. * @param scene defines the scene the camera belongs to
  40011. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40012. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40013. */
  40014. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40015. /**
  40016. * Gets camera class name
  40017. * @returns VRDeviceOrientationArcRotateCamera
  40018. */
  40019. getClassName(): string;
  40020. }
  40021. }
  40022. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40023. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40024. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40025. import { Scene } from "babylonjs/scene";
  40026. import { Vector3 } from "babylonjs/Maths/math";
  40027. import "babylonjs/Cameras/RigModes/vrRigMode";
  40028. /**
  40029. * Camera used to simulate VR rendering (based on FreeCamera)
  40030. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40031. */
  40032. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40033. /**
  40034. * Creates a new VRDeviceOrientationFreeCamera
  40035. * @param name defines camera name
  40036. * @param position defines the start position of the camera
  40037. * @param scene defines the scene the camera belongs to
  40038. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40039. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40040. */
  40041. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40042. /**
  40043. * Gets camera class name
  40044. * @returns VRDeviceOrientationFreeCamera
  40045. */
  40046. getClassName(): string;
  40047. }
  40048. }
  40049. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40050. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40051. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40052. import { Scene } from "babylonjs/scene";
  40053. import { Vector3 } from "babylonjs/Maths/math";
  40054. import "babylonjs/Gamepads/gamepadSceneComponent";
  40055. /**
  40056. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40057. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40058. */
  40059. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40060. /**
  40061. * Creates a new VRDeviceOrientationGamepadCamera
  40062. * @param name defines camera name
  40063. * @param position defines the start position of the camera
  40064. * @param scene defines the scene the camera belongs to
  40065. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40066. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40067. */
  40068. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40069. /**
  40070. * Gets camera class name
  40071. * @returns VRDeviceOrientationGamepadCamera
  40072. */
  40073. getClassName(): string;
  40074. }
  40075. }
  40076. declare module "babylonjs/Materials/pushMaterial" {
  40077. import { Nullable } from "babylonjs/types";
  40078. import { Scene } from "babylonjs/scene";
  40079. import { Matrix } from "babylonjs/Maths/math";
  40080. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40081. import { Mesh } from "babylonjs/Meshes/mesh";
  40082. import { Material } from "babylonjs/Materials/material";
  40083. import { Effect } from "babylonjs/Materials/effect";
  40084. /**
  40085. * Base class of materials working in push mode in babylon JS
  40086. * @hidden
  40087. */
  40088. export class PushMaterial extends Material {
  40089. protected _activeEffect: Effect;
  40090. protected _normalMatrix: Matrix;
  40091. /**
  40092. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40093. * This means that the material can keep using a previous shader while a new one is being compiled.
  40094. * This is mostly used when shader parallel compilation is supported (true by default)
  40095. */
  40096. allowShaderHotSwapping: boolean;
  40097. constructor(name: string, scene: Scene);
  40098. getEffect(): Effect;
  40099. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40100. /**
  40101. * Binds the given world matrix to the active effect
  40102. *
  40103. * @param world the matrix to bind
  40104. */
  40105. bindOnlyWorldMatrix(world: Matrix): void;
  40106. /**
  40107. * Binds the given normal matrix to the active effect
  40108. *
  40109. * @param normalMatrix the matrix to bind
  40110. */
  40111. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40112. bind(world: Matrix, mesh?: Mesh): void;
  40113. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40114. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40115. }
  40116. }
  40117. declare module "babylonjs/Materials/materialFlags" {
  40118. /**
  40119. * This groups all the flags used to control the materials channel.
  40120. */
  40121. export class MaterialFlags {
  40122. private static _DiffuseTextureEnabled;
  40123. /**
  40124. * Are diffuse textures enabled in the application.
  40125. */
  40126. static DiffuseTextureEnabled: boolean;
  40127. private static _AmbientTextureEnabled;
  40128. /**
  40129. * Are ambient textures enabled in the application.
  40130. */
  40131. static AmbientTextureEnabled: boolean;
  40132. private static _OpacityTextureEnabled;
  40133. /**
  40134. * Are opacity textures enabled in the application.
  40135. */
  40136. static OpacityTextureEnabled: boolean;
  40137. private static _ReflectionTextureEnabled;
  40138. /**
  40139. * Are reflection textures enabled in the application.
  40140. */
  40141. static ReflectionTextureEnabled: boolean;
  40142. private static _EmissiveTextureEnabled;
  40143. /**
  40144. * Are emissive textures enabled in the application.
  40145. */
  40146. static EmissiveTextureEnabled: boolean;
  40147. private static _SpecularTextureEnabled;
  40148. /**
  40149. * Are specular textures enabled in the application.
  40150. */
  40151. static SpecularTextureEnabled: boolean;
  40152. private static _BumpTextureEnabled;
  40153. /**
  40154. * Are bump textures enabled in the application.
  40155. */
  40156. static BumpTextureEnabled: boolean;
  40157. private static _LightmapTextureEnabled;
  40158. /**
  40159. * Are lightmap textures enabled in the application.
  40160. */
  40161. static LightmapTextureEnabled: boolean;
  40162. private static _RefractionTextureEnabled;
  40163. /**
  40164. * Are refraction textures enabled in the application.
  40165. */
  40166. static RefractionTextureEnabled: boolean;
  40167. private static _ColorGradingTextureEnabled;
  40168. /**
  40169. * Are color grading textures enabled in the application.
  40170. */
  40171. static ColorGradingTextureEnabled: boolean;
  40172. private static _FresnelEnabled;
  40173. /**
  40174. * Are fresnels enabled in the application.
  40175. */
  40176. static FresnelEnabled: boolean;
  40177. private static _ClearCoatTextureEnabled;
  40178. /**
  40179. * Are clear coat textures enabled in the application.
  40180. */
  40181. static ClearCoatTextureEnabled: boolean;
  40182. private static _ClearCoatBumpTextureEnabled;
  40183. /**
  40184. * Are clear coat bump textures enabled in the application.
  40185. */
  40186. static ClearCoatBumpTextureEnabled: boolean;
  40187. private static _ClearCoatTintTextureEnabled;
  40188. /**
  40189. * Are clear coat tint textures enabled in the application.
  40190. */
  40191. static ClearCoatTintTextureEnabled: boolean;
  40192. private static _SheenTextureEnabled;
  40193. /**
  40194. * Are sheen textures enabled in the application.
  40195. */
  40196. static SheenTextureEnabled: boolean;
  40197. private static _AnisotropicTextureEnabled;
  40198. /**
  40199. * Are anisotropic textures enabled in the application.
  40200. */
  40201. static AnisotropicTextureEnabled: boolean;
  40202. private static _ThicknessTextureEnabled;
  40203. /**
  40204. * Are thickness textures enabled in the application.
  40205. */
  40206. static ThicknessTextureEnabled: boolean;
  40207. }
  40208. }
  40209. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  40210. /** @hidden */
  40211. export var defaultFragmentDeclaration: {
  40212. name: string;
  40213. shader: string;
  40214. };
  40215. }
  40216. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  40217. /** @hidden */
  40218. export var defaultUboDeclaration: {
  40219. name: string;
  40220. shader: string;
  40221. };
  40222. }
  40223. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  40224. /** @hidden */
  40225. export var lightFragmentDeclaration: {
  40226. name: string;
  40227. shader: string;
  40228. };
  40229. }
  40230. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  40231. /** @hidden */
  40232. export var lightUboDeclaration: {
  40233. name: string;
  40234. shader: string;
  40235. };
  40236. }
  40237. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  40238. /** @hidden */
  40239. export var lightsFragmentFunctions: {
  40240. name: string;
  40241. shader: string;
  40242. };
  40243. }
  40244. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  40245. /** @hidden */
  40246. export var shadowsFragmentFunctions: {
  40247. name: string;
  40248. shader: string;
  40249. };
  40250. }
  40251. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  40252. /** @hidden */
  40253. export var fresnelFunction: {
  40254. name: string;
  40255. shader: string;
  40256. };
  40257. }
  40258. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  40259. /** @hidden */
  40260. export var reflectionFunction: {
  40261. name: string;
  40262. shader: string;
  40263. };
  40264. }
  40265. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  40266. /** @hidden */
  40267. export var bumpFragmentFunctions: {
  40268. name: string;
  40269. shader: string;
  40270. };
  40271. }
  40272. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  40273. /** @hidden */
  40274. export var logDepthDeclaration: {
  40275. name: string;
  40276. shader: string;
  40277. };
  40278. }
  40279. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  40280. /** @hidden */
  40281. export var bumpFragment: {
  40282. name: string;
  40283. shader: string;
  40284. };
  40285. }
  40286. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  40287. /** @hidden */
  40288. export var depthPrePass: {
  40289. name: string;
  40290. shader: string;
  40291. };
  40292. }
  40293. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  40294. /** @hidden */
  40295. export var lightFragment: {
  40296. name: string;
  40297. shader: string;
  40298. };
  40299. }
  40300. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  40301. /** @hidden */
  40302. export var logDepthFragment: {
  40303. name: string;
  40304. shader: string;
  40305. };
  40306. }
  40307. declare module "babylonjs/Shaders/default.fragment" {
  40308. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  40309. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40310. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40311. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40312. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40313. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  40314. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  40315. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  40316. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  40317. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40318. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40319. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  40320. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  40321. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40322. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  40323. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  40324. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  40325. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  40326. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  40327. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  40328. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  40329. /** @hidden */
  40330. export var defaultPixelShader: {
  40331. name: string;
  40332. shader: string;
  40333. };
  40334. }
  40335. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  40336. /** @hidden */
  40337. export var defaultVertexDeclaration: {
  40338. name: string;
  40339. shader: string;
  40340. };
  40341. }
  40342. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  40343. /** @hidden */
  40344. export var bumpVertexDeclaration: {
  40345. name: string;
  40346. shader: string;
  40347. };
  40348. }
  40349. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  40350. /** @hidden */
  40351. export var bumpVertex: {
  40352. name: string;
  40353. shader: string;
  40354. };
  40355. }
  40356. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  40357. /** @hidden */
  40358. export var fogVertex: {
  40359. name: string;
  40360. shader: string;
  40361. };
  40362. }
  40363. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  40364. /** @hidden */
  40365. export var shadowsVertex: {
  40366. name: string;
  40367. shader: string;
  40368. };
  40369. }
  40370. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  40371. /** @hidden */
  40372. export var pointCloudVertex: {
  40373. name: string;
  40374. shader: string;
  40375. };
  40376. }
  40377. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  40378. /** @hidden */
  40379. export var logDepthVertex: {
  40380. name: string;
  40381. shader: string;
  40382. };
  40383. }
  40384. declare module "babylonjs/Shaders/default.vertex" {
  40385. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  40386. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40387. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40388. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  40389. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  40390. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  40391. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  40392. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  40393. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40394. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40395. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  40396. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  40397. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40398. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  40399. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  40400. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  40401. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  40402. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  40403. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  40404. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  40405. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  40406. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  40407. /** @hidden */
  40408. export var defaultVertexShader: {
  40409. name: string;
  40410. shader: string;
  40411. };
  40412. }
  40413. declare module "babylonjs/Materials/standardMaterial" {
  40414. import { SmartArray } from "babylonjs/Misc/smartArray";
  40415. import { IAnimatable } from "babylonjs/Misc/tools";
  40416. import { Nullable } from "babylonjs/types";
  40417. import { Scene } from "babylonjs/scene";
  40418. import { Matrix, Color3 } from "babylonjs/Maths/math";
  40419. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40420. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40421. import { Mesh } from "babylonjs/Meshes/mesh";
  40422. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  40423. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40424. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  40425. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  40426. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  40427. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40428. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40429. import "babylonjs/Shaders/default.fragment";
  40430. import "babylonjs/Shaders/default.vertex";
  40431. /** @hidden */
  40432. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40433. MAINUV1: boolean;
  40434. MAINUV2: boolean;
  40435. DIFFUSE: boolean;
  40436. DIFFUSEDIRECTUV: number;
  40437. AMBIENT: boolean;
  40438. AMBIENTDIRECTUV: number;
  40439. OPACITY: boolean;
  40440. OPACITYDIRECTUV: number;
  40441. OPACITYRGB: boolean;
  40442. REFLECTION: boolean;
  40443. EMISSIVE: boolean;
  40444. EMISSIVEDIRECTUV: number;
  40445. SPECULAR: boolean;
  40446. SPECULARDIRECTUV: number;
  40447. BUMP: boolean;
  40448. BUMPDIRECTUV: number;
  40449. PARALLAX: boolean;
  40450. PARALLAXOCCLUSION: boolean;
  40451. SPECULAROVERALPHA: boolean;
  40452. CLIPPLANE: boolean;
  40453. CLIPPLANE2: boolean;
  40454. CLIPPLANE3: boolean;
  40455. CLIPPLANE4: boolean;
  40456. ALPHATEST: boolean;
  40457. DEPTHPREPASS: boolean;
  40458. ALPHAFROMDIFFUSE: boolean;
  40459. POINTSIZE: boolean;
  40460. FOG: boolean;
  40461. SPECULARTERM: boolean;
  40462. DIFFUSEFRESNEL: boolean;
  40463. OPACITYFRESNEL: boolean;
  40464. REFLECTIONFRESNEL: boolean;
  40465. REFRACTIONFRESNEL: boolean;
  40466. EMISSIVEFRESNEL: boolean;
  40467. FRESNEL: boolean;
  40468. NORMAL: boolean;
  40469. UV1: boolean;
  40470. UV2: boolean;
  40471. VERTEXCOLOR: boolean;
  40472. VERTEXALPHA: boolean;
  40473. NUM_BONE_INFLUENCERS: number;
  40474. BonesPerMesh: number;
  40475. BONETEXTURE: boolean;
  40476. INSTANCES: boolean;
  40477. GLOSSINESS: boolean;
  40478. ROUGHNESS: boolean;
  40479. EMISSIVEASILLUMINATION: boolean;
  40480. LINKEMISSIVEWITHDIFFUSE: boolean;
  40481. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40482. LIGHTMAP: boolean;
  40483. LIGHTMAPDIRECTUV: number;
  40484. OBJECTSPACE_NORMALMAP: boolean;
  40485. USELIGHTMAPASSHADOWMAP: boolean;
  40486. REFLECTIONMAP_3D: boolean;
  40487. REFLECTIONMAP_SPHERICAL: boolean;
  40488. REFLECTIONMAP_PLANAR: boolean;
  40489. REFLECTIONMAP_CUBIC: boolean;
  40490. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40491. REFLECTIONMAP_PROJECTION: boolean;
  40492. REFLECTIONMAP_SKYBOX: boolean;
  40493. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40494. REFLECTIONMAP_EXPLICIT: boolean;
  40495. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40496. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40497. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40498. INVERTCUBICMAP: boolean;
  40499. LOGARITHMICDEPTH: boolean;
  40500. REFRACTION: boolean;
  40501. REFRACTIONMAP_3D: boolean;
  40502. REFLECTIONOVERALPHA: boolean;
  40503. TWOSIDEDLIGHTING: boolean;
  40504. SHADOWFLOAT: boolean;
  40505. MORPHTARGETS: boolean;
  40506. MORPHTARGETS_NORMAL: boolean;
  40507. MORPHTARGETS_TANGENT: boolean;
  40508. MORPHTARGETS_UV: boolean;
  40509. NUM_MORPH_INFLUENCERS: number;
  40510. NONUNIFORMSCALING: boolean;
  40511. PREMULTIPLYALPHA: boolean;
  40512. IMAGEPROCESSING: boolean;
  40513. VIGNETTE: boolean;
  40514. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40515. VIGNETTEBLENDMODEOPAQUE: boolean;
  40516. TONEMAPPING: boolean;
  40517. TONEMAPPING_ACES: boolean;
  40518. CONTRAST: boolean;
  40519. COLORCURVES: boolean;
  40520. COLORGRADING: boolean;
  40521. COLORGRADING3D: boolean;
  40522. SAMPLER3DGREENDEPTH: boolean;
  40523. SAMPLER3DBGRMAP: boolean;
  40524. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40525. MULTIVIEW: boolean;
  40526. /**
  40527. * If the reflection texture on this material is in linear color space
  40528. * @hidden
  40529. */
  40530. IS_REFLECTION_LINEAR: boolean;
  40531. /**
  40532. * If the refraction texture on this material is in linear color space
  40533. * @hidden
  40534. */
  40535. IS_REFRACTION_LINEAR: boolean;
  40536. EXPOSURE: boolean;
  40537. constructor();
  40538. setReflectionMode(modeToEnable: string): void;
  40539. }
  40540. /**
  40541. * This is the default material used in Babylon. It is the best trade off between quality
  40542. * and performances.
  40543. * @see http://doc.babylonjs.com/babylon101/materials
  40544. */
  40545. export class StandardMaterial extends PushMaterial {
  40546. private _diffuseTexture;
  40547. /**
  40548. * The basic texture of the material as viewed under a light.
  40549. */
  40550. diffuseTexture: Nullable<BaseTexture>;
  40551. private _ambientTexture;
  40552. /**
  40553. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40554. */
  40555. ambientTexture: Nullable<BaseTexture>;
  40556. private _opacityTexture;
  40557. /**
  40558. * Define the transparency of the material from a texture.
  40559. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40560. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40561. */
  40562. opacityTexture: Nullable<BaseTexture>;
  40563. private _reflectionTexture;
  40564. /**
  40565. * Define the texture used to display the reflection.
  40566. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40567. */
  40568. reflectionTexture: Nullable<BaseTexture>;
  40569. private _emissiveTexture;
  40570. /**
  40571. * Define texture of the material as if self lit.
  40572. * This will be mixed in the final result even in the absence of light.
  40573. */
  40574. emissiveTexture: Nullable<BaseTexture>;
  40575. private _specularTexture;
  40576. /**
  40577. * Define how the color and intensity of the highlight given by the light in the material.
  40578. */
  40579. specularTexture: Nullable<BaseTexture>;
  40580. private _bumpTexture;
  40581. /**
  40582. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40583. * 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.
  40584. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40585. */
  40586. bumpTexture: Nullable<BaseTexture>;
  40587. private _lightmapTexture;
  40588. /**
  40589. * Complex lighting can be computationally expensive to compute at runtime.
  40590. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40591. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40592. */
  40593. lightmapTexture: Nullable<BaseTexture>;
  40594. private _refractionTexture;
  40595. /**
  40596. * Define the texture used to display the refraction.
  40597. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40598. */
  40599. refractionTexture: Nullable<BaseTexture>;
  40600. /**
  40601. * The color of the material lit by the environmental background lighting.
  40602. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40603. */
  40604. ambientColor: Color3;
  40605. /**
  40606. * The basic color of the material as viewed under a light.
  40607. */
  40608. diffuseColor: Color3;
  40609. /**
  40610. * Define how the color and intensity of the highlight given by the light in the material.
  40611. */
  40612. specularColor: Color3;
  40613. /**
  40614. * Define the color of the material as if self lit.
  40615. * This will be mixed in the final result even in the absence of light.
  40616. */
  40617. emissiveColor: Color3;
  40618. /**
  40619. * Defines how sharp are the highlights in the material.
  40620. * The bigger the value the sharper giving a more glossy feeling to the result.
  40621. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40622. */
  40623. specularPower: number;
  40624. private _useAlphaFromDiffuseTexture;
  40625. /**
  40626. * Does the transparency come from the diffuse texture alpha channel.
  40627. */
  40628. useAlphaFromDiffuseTexture: boolean;
  40629. private _useEmissiveAsIllumination;
  40630. /**
  40631. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40632. */
  40633. useEmissiveAsIllumination: boolean;
  40634. private _linkEmissiveWithDiffuse;
  40635. /**
  40636. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40637. * the emissive level when the final color is close to one.
  40638. */
  40639. linkEmissiveWithDiffuse: boolean;
  40640. private _useSpecularOverAlpha;
  40641. /**
  40642. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40643. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40644. */
  40645. useSpecularOverAlpha: boolean;
  40646. private _useReflectionOverAlpha;
  40647. /**
  40648. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40649. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40650. */
  40651. useReflectionOverAlpha: boolean;
  40652. private _disableLighting;
  40653. /**
  40654. * Does lights from the scene impacts this material.
  40655. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40656. */
  40657. disableLighting: boolean;
  40658. private _useObjectSpaceNormalMap;
  40659. /**
  40660. * Allows using an object space normal map (instead of tangent space).
  40661. */
  40662. useObjectSpaceNormalMap: boolean;
  40663. private _useParallax;
  40664. /**
  40665. * Is parallax enabled or not.
  40666. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40667. */
  40668. useParallax: boolean;
  40669. private _useParallaxOcclusion;
  40670. /**
  40671. * Is parallax occlusion enabled or not.
  40672. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40673. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40674. */
  40675. useParallaxOcclusion: boolean;
  40676. /**
  40677. * 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.
  40678. */
  40679. parallaxScaleBias: number;
  40680. private _roughness;
  40681. /**
  40682. * Helps to define how blurry the reflections should appears in the material.
  40683. */
  40684. roughness: number;
  40685. /**
  40686. * In case of refraction, define the value of the index of refraction.
  40687. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40688. */
  40689. indexOfRefraction: number;
  40690. /**
  40691. * Invert the refraction texture alongside the y axis.
  40692. * It can be useful with procedural textures or probe for instance.
  40693. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40694. */
  40695. invertRefractionY: boolean;
  40696. /**
  40697. * Defines the alpha limits in alpha test mode.
  40698. */
  40699. alphaCutOff: number;
  40700. private _useLightmapAsShadowmap;
  40701. /**
  40702. * In case of light mapping, define whether the map contains light or shadow informations.
  40703. */
  40704. useLightmapAsShadowmap: boolean;
  40705. private _diffuseFresnelParameters;
  40706. /**
  40707. * Define the diffuse fresnel parameters of the material.
  40708. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40709. */
  40710. diffuseFresnelParameters: FresnelParameters;
  40711. private _opacityFresnelParameters;
  40712. /**
  40713. * Define the opacity fresnel parameters of the material.
  40714. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40715. */
  40716. opacityFresnelParameters: FresnelParameters;
  40717. private _reflectionFresnelParameters;
  40718. /**
  40719. * Define the reflection fresnel parameters of the material.
  40720. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40721. */
  40722. reflectionFresnelParameters: FresnelParameters;
  40723. private _refractionFresnelParameters;
  40724. /**
  40725. * Define the refraction fresnel parameters of the material.
  40726. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40727. */
  40728. refractionFresnelParameters: FresnelParameters;
  40729. private _emissiveFresnelParameters;
  40730. /**
  40731. * Define the emissive fresnel parameters of the material.
  40732. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40733. */
  40734. emissiveFresnelParameters: FresnelParameters;
  40735. private _useReflectionFresnelFromSpecular;
  40736. /**
  40737. * If true automatically deducts the fresnels values from the material specularity.
  40738. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40739. */
  40740. useReflectionFresnelFromSpecular: boolean;
  40741. private _useGlossinessFromSpecularMapAlpha;
  40742. /**
  40743. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40744. */
  40745. useGlossinessFromSpecularMapAlpha: boolean;
  40746. private _maxSimultaneousLights;
  40747. /**
  40748. * Defines the maximum number of lights that can be used in the material
  40749. */
  40750. maxSimultaneousLights: number;
  40751. private _invertNormalMapX;
  40752. /**
  40753. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40754. */
  40755. invertNormalMapX: boolean;
  40756. private _invertNormalMapY;
  40757. /**
  40758. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40759. */
  40760. invertNormalMapY: boolean;
  40761. private _twoSidedLighting;
  40762. /**
  40763. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40764. */
  40765. twoSidedLighting: boolean;
  40766. /**
  40767. * Default configuration related to image processing available in the standard Material.
  40768. */
  40769. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40770. /**
  40771. * Gets the image processing configuration used either in this material.
  40772. */
  40773. /**
  40774. * Sets the Default image processing configuration used either in the this material.
  40775. *
  40776. * If sets to null, the scene one is in use.
  40777. */
  40778. imageProcessingConfiguration: ImageProcessingConfiguration;
  40779. /**
  40780. * Keep track of the image processing observer to allow dispose and replace.
  40781. */
  40782. private _imageProcessingObserver;
  40783. /**
  40784. * Attaches a new image processing configuration to the Standard Material.
  40785. * @param configuration
  40786. */
  40787. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40788. /**
  40789. * Gets wether the color curves effect is enabled.
  40790. */
  40791. /**
  40792. * Sets wether the color curves effect is enabled.
  40793. */
  40794. cameraColorCurvesEnabled: boolean;
  40795. /**
  40796. * Gets wether the color grading effect is enabled.
  40797. */
  40798. /**
  40799. * Gets wether the color grading effect is enabled.
  40800. */
  40801. cameraColorGradingEnabled: boolean;
  40802. /**
  40803. * Gets wether tonemapping is enabled or not.
  40804. */
  40805. /**
  40806. * Sets wether tonemapping is enabled or not
  40807. */
  40808. cameraToneMappingEnabled: boolean;
  40809. /**
  40810. * The camera exposure used on this material.
  40811. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40812. * This corresponds to a photographic exposure.
  40813. */
  40814. /**
  40815. * The camera exposure used on this material.
  40816. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40817. * This corresponds to a photographic exposure.
  40818. */
  40819. cameraExposure: number;
  40820. /**
  40821. * Gets The camera contrast used on this material.
  40822. */
  40823. /**
  40824. * Sets The camera contrast used on this material.
  40825. */
  40826. cameraContrast: number;
  40827. /**
  40828. * Gets the Color Grading 2D Lookup Texture.
  40829. */
  40830. /**
  40831. * Sets the Color Grading 2D Lookup Texture.
  40832. */
  40833. cameraColorGradingTexture: Nullable<BaseTexture>;
  40834. /**
  40835. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40836. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40837. * 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;
  40838. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40839. */
  40840. /**
  40841. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40842. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40843. * 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;
  40844. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40845. */
  40846. cameraColorCurves: Nullable<ColorCurves>;
  40847. /**
  40848. * Custom callback helping to override the default shader used in the material.
  40849. */
  40850. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40851. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40852. protected _worldViewProjectionMatrix: Matrix;
  40853. protected _globalAmbientColor: Color3;
  40854. protected _useLogarithmicDepth: boolean;
  40855. /**
  40856. * Instantiates a new standard material.
  40857. * This is the default material used in Babylon. It is the best trade off between quality
  40858. * and performances.
  40859. * @see http://doc.babylonjs.com/babylon101/materials
  40860. * @param name Define the name of the material in the scene
  40861. * @param scene Define the scene the material belong to
  40862. */
  40863. constructor(name: string, scene: Scene);
  40864. /**
  40865. * Gets a boolean indicating that current material needs to register RTT
  40866. */
  40867. readonly hasRenderTargetTextures: boolean;
  40868. /**
  40869. * Gets the current class name of the material e.g. "StandardMaterial"
  40870. * Mainly use in serialization.
  40871. * @returns the class name
  40872. */
  40873. getClassName(): string;
  40874. /**
  40875. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40876. * You can try switching to logarithmic depth.
  40877. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40878. */
  40879. useLogarithmicDepth: boolean;
  40880. /**
  40881. * Specifies if the material will require alpha blending
  40882. * @returns a boolean specifying if alpha blending is needed
  40883. */
  40884. needAlphaBlending(): boolean;
  40885. /**
  40886. * Specifies if this material should be rendered in alpha test mode
  40887. * @returns a boolean specifying if an alpha test is needed.
  40888. */
  40889. needAlphaTesting(): boolean;
  40890. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40891. /**
  40892. * Get the texture used for alpha test purpose.
  40893. * @returns the diffuse texture in case of the standard material.
  40894. */
  40895. getAlphaTestTexture(): Nullable<BaseTexture>;
  40896. /**
  40897. * Get if the submesh is ready to be used and all its information available.
  40898. * Child classes can use it to update shaders
  40899. * @param mesh defines the mesh to check
  40900. * @param subMesh defines which submesh to check
  40901. * @param useInstances specifies that instances should be used
  40902. * @returns a boolean indicating that the submesh is ready or not
  40903. */
  40904. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40905. /**
  40906. * Builds the material UBO layouts.
  40907. * Used internally during the effect preparation.
  40908. */
  40909. buildUniformLayout(): void;
  40910. /**
  40911. * Unbinds the material from the mesh
  40912. */
  40913. unbind(): void;
  40914. /**
  40915. * Binds the submesh to this material by preparing the effect and shader to draw
  40916. * @param world defines the world transformation matrix
  40917. * @param mesh defines the mesh containing the submesh
  40918. * @param subMesh defines the submesh to bind the material to
  40919. */
  40920. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40921. /**
  40922. * Get the list of animatables in the material.
  40923. * @returns the list of animatables object used in the material
  40924. */
  40925. getAnimatables(): IAnimatable[];
  40926. /**
  40927. * Gets the active textures from the material
  40928. * @returns an array of textures
  40929. */
  40930. getActiveTextures(): BaseTexture[];
  40931. /**
  40932. * Specifies if the material uses a texture
  40933. * @param texture defines the texture to check against the material
  40934. * @returns a boolean specifying if the material uses the texture
  40935. */
  40936. hasTexture(texture: BaseTexture): boolean;
  40937. /**
  40938. * Disposes the material
  40939. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40940. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40941. */
  40942. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40943. /**
  40944. * Makes a duplicate of the material, and gives it a new name
  40945. * @param name defines the new name for the duplicated material
  40946. * @returns the cloned material
  40947. */
  40948. clone(name: string): StandardMaterial;
  40949. /**
  40950. * Serializes this material in a JSON representation
  40951. * @returns the serialized material object
  40952. */
  40953. serialize(): any;
  40954. /**
  40955. * Creates a standard material from parsed material data
  40956. * @param source defines the JSON representation of the material
  40957. * @param scene defines the hosting scene
  40958. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40959. * @returns a new standard material
  40960. */
  40961. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40962. /**
  40963. * Are diffuse textures enabled in the application.
  40964. */
  40965. static DiffuseTextureEnabled: boolean;
  40966. /**
  40967. * Are ambient textures enabled in the application.
  40968. */
  40969. static AmbientTextureEnabled: boolean;
  40970. /**
  40971. * Are opacity textures enabled in the application.
  40972. */
  40973. static OpacityTextureEnabled: boolean;
  40974. /**
  40975. * Are reflection textures enabled in the application.
  40976. */
  40977. static ReflectionTextureEnabled: boolean;
  40978. /**
  40979. * Are emissive textures enabled in the application.
  40980. */
  40981. static EmissiveTextureEnabled: boolean;
  40982. /**
  40983. * Are specular textures enabled in the application.
  40984. */
  40985. static SpecularTextureEnabled: boolean;
  40986. /**
  40987. * Are bump textures enabled in the application.
  40988. */
  40989. static BumpTextureEnabled: boolean;
  40990. /**
  40991. * Are lightmap textures enabled in the application.
  40992. */
  40993. static LightmapTextureEnabled: boolean;
  40994. /**
  40995. * Are refraction textures enabled in the application.
  40996. */
  40997. static RefractionTextureEnabled: boolean;
  40998. /**
  40999. * Are color grading textures enabled in the application.
  41000. */
  41001. static ColorGradingTextureEnabled: boolean;
  41002. /**
  41003. * Are fresnels enabled in the application.
  41004. */
  41005. static FresnelEnabled: boolean;
  41006. }
  41007. }
  41008. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  41009. import { Scene } from "babylonjs/scene";
  41010. import { Texture } from "babylonjs/Materials/Textures/texture";
  41011. /**
  41012. * A class extending Texture allowing drawing on a texture
  41013. * @see http://doc.babylonjs.com/how_to/dynamictexture
  41014. */
  41015. export class DynamicTexture extends Texture {
  41016. private _generateMipMaps;
  41017. private _canvas;
  41018. private _context;
  41019. private _engine;
  41020. /**
  41021. * Creates a DynamicTexture
  41022. * @param name defines the name of the texture
  41023. * @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
  41024. * @param scene defines the scene where you want the texture
  41025. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  41026. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  41027. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  41028. */
  41029. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  41030. /**
  41031. * Get the current class name of the texture useful for serialization or dynamic coding.
  41032. * @returns "DynamicTexture"
  41033. */
  41034. getClassName(): string;
  41035. /**
  41036. * Gets the current state of canRescale
  41037. */
  41038. readonly canRescale: boolean;
  41039. private _recreate;
  41040. /**
  41041. * Scales the texture
  41042. * @param ratio the scale factor to apply to both width and height
  41043. */
  41044. scale(ratio: number): void;
  41045. /**
  41046. * Resizes the texture
  41047. * @param width the new width
  41048. * @param height the new height
  41049. */
  41050. scaleTo(width: number, height: number): void;
  41051. /**
  41052. * Gets the context of the canvas used by the texture
  41053. * @returns the canvas context of the dynamic texture
  41054. */
  41055. getContext(): CanvasRenderingContext2D;
  41056. /**
  41057. * Clears the texture
  41058. */
  41059. clear(): void;
  41060. /**
  41061. * Updates the texture
  41062. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41063. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  41064. */
  41065. update(invertY?: boolean, premulAlpha?: boolean): void;
  41066. /**
  41067. * Draws text onto the texture
  41068. * @param text defines the text to be drawn
  41069. * @param x defines the placement of the text from the left
  41070. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  41071. * @param font defines the font to be used with font-style, font-size, font-name
  41072. * @param color defines the color used for the text
  41073. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  41074. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41075. * @param update defines whether texture is immediately update (default is true)
  41076. */
  41077. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  41078. /**
  41079. * Clones the texture
  41080. * @returns the clone of the texture.
  41081. */
  41082. clone(): DynamicTexture;
  41083. /**
  41084. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  41085. * @returns a serialized dynamic texture object
  41086. */
  41087. serialize(): any;
  41088. /** @hidden */
  41089. _rebuild(): void;
  41090. }
  41091. }
  41092. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41093. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41094. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41095. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41096. /** @hidden */
  41097. export var imageProcessingPixelShader: {
  41098. name: string;
  41099. shader: string;
  41100. };
  41101. }
  41102. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41103. import { Nullable } from "babylonjs/types";
  41104. import { Color4 } from "babylonjs/Maths/math";
  41105. import { Camera } from "babylonjs/Cameras/camera";
  41106. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41107. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41108. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41109. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41110. import { Engine } from "babylonjs/Engines/engine";
  41111. import "babylonjs/Shaders/imageProcessing.fragment";
  41112. import "babylonjs/Shaders/postprocess.vertex";
  41113. /**
  41114. * ImageProcessingPostProcess
  41115. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41116. */
  41117. export class ImageProcessingPostProcess extends PostProcess {
  41118. /**
  41119. * Default configuration related to image processing available in the PBR Material.
  41120. */
  41121. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41122. /**
  41123. * Gets the image processing configuration used either in this material.
  41124. */
  41125. /**
  41126. * Sets the Default image processing configuration used either in the this material.
  41127. *
  41128. * If sets to null, the scene one is in use.
  41129. */
  41130. imageProcessingConfiguration: ImageProcessingConfiguration;
  41131. /**
  41132. * Keep track of the image processing observer to allow dispose and replace.
  41133. */
  41134. private _imageProcessingObserver;
  41135. /**
  41136. * Attaches a new image processing configuration to the PBR Material.
  41137. * @param configuration
  41138. */
  41139. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41140. /**
  41141. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41142. */
  41143. /**
  41144. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41145. */
  41146. colorCurves: Nullable<ColorCurves>;
  41147. /**
  41148. * Gets wether the color curves effect is enabled.
  41149. */
  41150. /**
  41151. * Sets wether the color curves effect is enabled.
  41152. */
  41153. colorCurvesEnabled: boolean;
  41154. /**
  41155. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41156. */
  41157. /**
  41158. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41159. */
  41160. colorGradingTexture: Nullable<BaseTexture>;
  41161. /**
  41162. * Gets wether the color grading effect is enabled.
  41163. */
  41164. /**
  41165. * Gets wether the color grading effect is enabled.
  41166. */
  41167. colorGradingEnabled: boolean;
  41168. /**
  41169. * Gets exposure used in the effect.
  41170. */
  41171. /**
  41172. * Sets exposure used in the effect.
  41173. */
  41174. exposure: number;
  41175. /**
  41176. * Gets wether tonemapping is enabled or not.
  41177. */
  41178. /**
  41179. * Sets wether tonemapping is enabled or not
  41180. */
  41181. toneMappingEnabled: boolean;
  41182. /**
  41183. * Gets the type of tone mapping effect.
  41184. */
  41185. /**
  41186. * Sets the type of tone mapping effect.
  41187. */
  41188. toneMappingType: number;
  41189. /**
  41190. * Gets contrast used in the effect.
  41191. */
  41192. /**
  41193. * Sets contrast used in the effect.
  41194. */
  41195. contrast: number;
  41196. /**
  41197. * Gets Vignette stretch size.
  41198. */
  41199. /**
  41200. * Sets Vignette stretch size.
  41201. */
  41202. vignetteStretch: number;
  41203. /**
  41204. * Gets Vignette centre X Offset.
  41205. */
  41206. /**
  41207. * Sets Vignette centre X Offset.
  41208. */
  41209. vignetteCentreX: number;
  41210. /**
  41211. * Gets Vignette centre Y Offset.
  41212. */
  41213. /**
  41214. * Sets Vignette centre Y Offset.
  41215. */
  41216. vignetteCentreY: number;
  41217. /**
  41218. * Gets Vignette weight or intensity of the vignette effect.
  41219. */
  41220. /**
  41221. * Sets Vignette weight or intensity of the vignette effect.
  41222. */
  41223. vignetteWeight: number;
  41224. /**
  41225. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41226. * if vignetteEnabled is set to true.
  41227. */
  41228. /**
  41229. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41230. * if vignetteEnabled is set to true.
  41231. */
  41232. vignetteColor: Color4;
  41233. /**
  41234. * Gets Camera field of view used by the Vignette effect.
  41235. */
  41236. /**
  41237. * Sets Camera field of view used by the Vignette effect.
  41238. */
  41239. vignetteCameraFov: number;
  41240. /**
  41241. * Gets the vignette blend mode allowing different kind of effect.
  41242. */
  41243. /**
  41244. * Sets the vignette blend mode allowing different kind of effect.
  41245. */
  41246. vignetteBlendMode: number;
  41247. /**
  41248. * Gets wether the vignette effect is enabled.
  41249. */
  41250. /**
  41251. * Sets wether the vignette effect is enabled.
  41252. */
  41253. vignetteEnabled: boolean;
  41254. private _fromLinearSpace;
  41255. /**
  41256. * Gets wether the input of the processing is in Gamma or Linear Space.
  41257. */
  41258. /**
  41259. * Sets wether the input of the processing is in Gamma or Linear Space.
  41260. */
  41261. fromLinearSpace: boolean;
  41262. /**
  41263. * Defines cache preventing GC.
  41264. */
  41265. private _defines;
  41266. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41267. /**
  41268. * "ImageProcessingPostProcess"
  41269. * @returns "ImageProcessingPostProcess"
  41270. */
  41271. getClassName(): string;
  41272. protected _updateParameters(): void;
  41273. dispose(camera?: Camera): void;
  41274. }
  41275. }
  41276. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  41277. import { Scene } from "babylonjs/scene";
  41278. import { Color3 } from "babylonjs/Maths/math";
  41279. import { Mesh } from "babylonjs/Meshes/mesh";
  41280. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  41281. import { Nullable } from "babylonjs/types";
  41282. /**
  41283. * Class containing static functions to help procedurally build meshes
  41284. */
  41285. export class GroundBuilder {
  41286. /**
  41287. * Creates a ground mesh
  41288. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41289. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41291. * @param name defines the name of the mesh
  41292. * @param options defines the options used to create the mesh
  41293. * @param scene defines the hosting scene
  41294. * @returns the ground mesh
  41295. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41296. */
  41297. static CreateGround(name: string, options: {
  41298. width?: number;
  41299. height?: number;
  41300. subdivisions?: number;
  41301. subdivisionsX?: number;
  41302. subdivisionsY?: number;
  41303. updatable?: boolean;
  41304. }, scene: any): Mesh;
  41305. /**
  41306. * Creates a tiled ground mesh
  41307. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41308. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41309. * * 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
  41310. * * 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
  41311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41312. * @param name defines the name of the mesh
  41313. * @param options defines the options used to create the mesh
  41314. * @param scene defines the hosting scene
  41315. * @returns the tiled ground mesh
  41316. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41317. */
  41318. static CreateTiledGround(name: string, options: {
  41319. xmin: number;
  41320. zmin: number;
  41321. xmax: number;
  41322. zmax: number;
  41323. subdivisions?: {
  41324. w: number;
  41325. h: number;
  41326. };
  41327. precision?: {
  41328. w: number;
  41329. h: number;
  41330. };
  41331. updatable?: boolean;
  41332. }, scene?: Nullable<Scene>): Mesh;
  41333. /**
  41334. * Creates a ground mesh from a height map
  41335. * * The parameter `url` sets the URL of the height map image resource.
  41336. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41337. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41338. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41339. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41340. * * 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.
  41341. * * 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).
  41342. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41344. * @param name defines the name of the mesh
  41345. * @param url defines the url to the height map
  41346. * @param options defines the options used to create the mesh
  41347. * @param scene defines the hosting scene
  41348. * @returns the ground mesh
  41349. * @see https://doc.babylonjs.com/babylon101/height_map
  41350. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41351. */
  41352. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41353. width?: number;
  41354. height?: number;
  41355. subdivisions?: number;
  41356. minHeight?: number;
  41357. maxHeight?: number;
  41358. colorFilter?: Color3;
  41359. alphaFilter?: number;
  41360. updatable?: boolean;
  41361. onReady?: (mesh: GroundMesh) => void;
  41362. }, scene?: Nullable<Scene>): GroundMesh;
  41363. }
  41364. }
  41365. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  41366. import { Vector4 } from "babylonjs/Maths/math";
  41367. import { Mesh } from "babylonjs/Meshes/mesh";
  41368. /**
  41369. * Class containing static functions to help procedurally build meshes
  41370. */
  41371. export class TorusBuilder {
  41372. /**
  41373. * Creates a torus mesh
  41374. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41375. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41376. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41377. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41378. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41380. * @param name defines the name of the mesh
  41381. * @param options defines the options used to create the mesh
  41382. * @param scene defines the hosting scene
  41383. * @returns the torus mesh
  41384. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41385. */
  41386. static CreateTorus(name: string, options: {
  41387. diameter?: number;
  41388. thickness?: number;
  41389. tessellation?: number;
  41390. updatable?: boolean;
  41391. sideOrientation?: number;
  41392. frontUVs?: Vector4;
  41393. backUVs?: Vector4;
  41394. }, scene: any): Mesh;
  41395. }
  41396. }
  41397. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  41398. import { Color4, Vector4 } from "babylonjs/Maths/math";
  41399. import { Mesh } from "babylonjs/Meshes/mesh";
  41400. /**
  41401. * Class containing static functions to help procedurally build meshes
  41402. */
  41403. export class CylinderBuilder {
  41404. /**
  41405. * Creates a cylinder or a cone mesh
  41406. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41407. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41408. * * 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.
  41409. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41410. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41411. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41412. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41413. * * 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).
  41414. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41415. * * 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).
  41416. * * 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
  41417. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41418. * * 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
  41419. * * 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.
  41420. * * If `enclose` is false, a ring surface is one element.
  41421. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41422. * * 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
  41423. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41424. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41426. * @param name defines the name of the mesh
  41427. * @param options defines the options used to create the mesh
  41428. * @param scene defines the hosting scene
  41429. * @returns the cylinder mesh
  41430. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41431. */
  41432. static CreateCylinder(name: string, options: {
  41433. height?: number;
  41434. diameterTop?: number;
  41435. diameterBottom?: number;
  41436. diameter?: number;
  41437. tessellation?: number;
  41438. subdivisions?: number;
  41439. arc?: number;
  41440. faceColors?: Color4[];
  41441. faceUV?: Vector4[];
  41442. updatable?: boolean;
  41443. hasRings?: boolean;
  41444. enclose?: boolean;
  41445. cap?: number;
  41446. sideOrientation?: number;
  41447. frontUVs?: Vector4;
  41448. backUVs?: Vector4;
  41449. }, scene: any): Mesh;
  41450. }
  41451. }
  41452. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  41453. import { Observable } from "babylonjs/Misc/observable";
  41454. import { Nullable } from "babylonjs/types";
  41455. import { Camera } from "babylonjs/Cameras/camera";
  41456. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41457. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41458. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  41459. import { Scene } from "babylonjs/scene";
  41460. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41461. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  41462. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41463. import { Mesh } from "babylonjs/Meshes/mesh";
  41464. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  41465. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41466. import "babylonjs/Meshes/Builders/groundBuilder";
  41467. import "babylonjs/Meshes/Builders/torusBuilder";
  41468. import "babylonjs/Meshes/Builders/cylinderBuilder";
  41469. import "babylonjs/Gamepads/gamepadSceneComponent";
  41470. import "babylonjs/Animations/animatable";
  41471. /**
  41472. * Options to modify the vr teleportation behavior.
  41473. */
  41474. export interface VRTeleportationOptions {
  41475. /**
  41476. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41477. */
  41478. floorMeshName?: string;
  41479. /**
  41480. * A list of meshes to be used as the teleportation floor. (default: empty)
  41481. */
  41482. floorMeshes?: Mesh[];
  41483. }
  41484. /**
  41485. * Options to modify the vr experience helper's behavior.
  41486. */
  41487. export interface VRExperienceHelperOptions extends WebVROptions {
  41488. /**
  41489. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41490. */
  41491. createDeviceOrientationCamera?: boolean;
  41492. /**
  41493. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41494. */
  41495. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41496. /**
  41497. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41498. */
  41499. laserToggle?: boolean;
  41500. /**
  41501. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41502. */
  41503. floorMeshes?: Mesh[];
  41504. /**
  41505. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41506. */
  41507. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41508. }
  41509. /**
  41510. * Event containing information after VR has been entered
  41511. */
  41512. export class OnAfterEnteringVRObservableEvent {
  41513. /**
  41514. * If entering vr was successful
  41515. */
  41516. success: boolean;
  41517. }
  41518. /**
  41519. * Helps to quickly add VR support to an existing scene.
  41520. * See http://doc.babylonjs.com/how_to/webvr_helper
  41521. */
  41522. export class VRExperienceHelper {
  41523. /** Options to modify the vr experience helper's behavior. */
  41524. webVROptions: VRExperienceHelperOptions;
  41525. private _scene;
  41526. private _position;
  41527. private _btnVR;
  41528. private _btnVRDisplayed;
  41529. private _webVRsupported;
  41530. private _webVRready;
  41531. private _webVRrequesting;
  41532. private _webVRpresenting;
  41533. private _hasEnteredVR;
  41534. private _fullscreenVRpresenting;
  41535. private _canvas;
  41536. private _webVRCamera;
  41537. private _vrDeviceOrientationCamera;
  41538. private _deviceOrientationCamera;
  41539. private _existingCamera;
  41540. private _onKeyDown;
  41541. private _onVrDisplayPresentChange;
  41542. private _onVRDisplayChanged;
  41543. private _onVRRequestPresentStart;
  41544. private _onVRRequestPresentComplete;
  41545. /**
  41546. * Observable raised right before entering VR.
  41547. */
  41548. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41549. /**
  41550. * Observable raised when entering VR has completed.
  41551. */
  41552. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41553. /**
  41554. * Observable raised when exiting VR.
  41555. */
  41556. onExitingVRObservable: Observable<VRExperienceHelper>;
  41557. /**
  41558. * Observable raised when controller mesh is loaded.
  41559. */
  41560. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41561. /** Return this.onEnteringVRObservable
  41562. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41563. */
  41564. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41565. /** Return this.onExitingVRObservable
  41566. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41567. */
  41568. readonly onExitingVR: Observable<VRExperienceHelper>;
  41569. /** Return this.onControllerMeshLoadedObservable
  41570. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41571. */
  41572. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41573. private _rayLength;
  41574. private _useCustomVRButton;
  41575. private _teleportationRequested;
  41576. private _teleportActive;
  41577. private _floorMeshName;
  41578. private _floorMeshesCollection;
  41579. private _rotationAllowed;
  41580. private _teleportBackwardsVector;
  41581. private _teleportationTarget;
  41582. private _isDefaultTeleportationTarget;
  41583. private _postProcessMove;
  41584. private _teleportationFillColor;
  41585. private _teleportationBorderColor;
  41586. private _rotationAngle;
  41587. private _haloCenter;
  41588. private _cameraGazer;
  41589. private _padSensibilityUp;
  41590. private _padSensibilityDown;
  41591. private _leftController;
  41592. private _rightController;
  41593. /**
  41594. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41595. */
  41596. onNewMeshSelected: Observable<AbstractMesh>;
  41597. /**
  41598. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41599. */
  41600. onNewMeshPicked: Observable<PickingInfo>;
  41601. private _circleEase;
  41602. /**
  41603. * Observable raised before camera teleportation
  41604. */
  41605. onBeforeCameraTeleport: Observable<Vector3>;
  41606. /**
  41607. * Observable raised after camera teleportation
  41608. */
  41609. onAfterCameraTeleport: Observable<Vector3>;
  41610. /**
  41611. * Observable raised when current selected mesh gets unselected
  41612. */
  41613. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41614. private _raySelectionPredicate;
  41615. /**
  41616. * To be optionaly changed by user to define custom ray selection
  41617. */
  41618. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41619. /**
  41620. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41621. */
  41622. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41623. /**
  41624. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41625. */
  41626. teleportationEnabled: boolean;
  41627. private _defaultHeight;
  41628. private _teleportationInitialized;
  41629. private _interactionsEnabled;
  41630. private _interactionsRequested;
  41631. private _displayGaze;
  41632. private _displayLaserPointer;
  41633. /**
  41634. * The mesh used to display where the user is going to teleport.
  41635. */
  41636. /**
  41637. * Sets the mesh to be used to display where the user is going to teleport.
  41638. */
  41639. teleportationTarget: Mesh;
  41640. /**
  41641. * 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
  41642. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41643. * See http://doc.babylonjs.com/resources/baking_transformations
  41644. */
  41645. gazeTrackerMesh: Mesh;
  41646. /**
  41647. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41648. */
  41649. updateGazeTrackerScale: boolean;
  41650. /**
  41651. * If the gaze trackers color should be updated when selecting meshes
  41652. */
  41653. updateGazeTrackerColor: boolean;
  41654. /**
  41655. * The gaze tracking mesh corresponding to the left controller
  41656. */
  41657. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41658. /**
  41659. * The gaze tracking mesh corresponding to the right controller
  41660. */
  41661. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41662. /**
  41663. * If the ray of the gaze should be displayed.
  41664. */
  41665. /**
  41666. * Sets if the ray of the gaze should be displayed.
  41667. */
  41668. displayGaze: boolean;
  41669. /**
  41670. * If the ray of the LaserPointer should be displayed.
  41671. */
  41672. /**
  41673. * Sets if the ray of the LaserPointer should be displayed.
  41674. */
  41675. displayLaserPointer: boolean;
  41676. /**
  41677. * The deviceOrientationCamera used as the camera when not in VR.
  41678. */
  41679. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41680. /**
  41681. * Based on the current WebVR support, returns the current VR camera used.
  41682. */
  41683. readonly currentVRCamera: Nullable<Camera>;
  41684. /**
  41685. * The webVRCamera which is used when in VR.
  41686. */
  41687. readonly webVRCamera: WebVRFreeCamera;
  41688. /**
  41689. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41690. */
  41691. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41692. private readonly _teleportationRequestInitiated;
  41693. /**
  41694. * Defines wether or not Pointer lock should be requested when switching to
  41695. * full screen.
  41696. */
  41697. requestPointerLockOnFullScreen: boolean;
  41698. /**
  41699. * Instantiates a VRExperienceHelper.
  41700. * Helps to quickly add VR support to an existing scene.
  41701. * @param scene The scene the VRExperienceHelper belongs to.
  41702. * @param webVROptions Options to modify the vr experience helper's behavior.
  41703. */
  41704. constructor(scene: Scene,
  41705. /** Options to modify the vr experience helper's behavior. */
  41706. webVROptions?: VRExperienceHelperOptions);
  41707. private _onDefaultMeshLoaded;
  41708. private _onResize;
  41709. private _onFullscreenChange;
  41710. /**
  41711. * Gets a value indicating if we are currently in VR mode.
  41712. */
  41713. readonly isInVRMode: boolean;
  41714. private onVrDisplayPresentChange;
  41715. private onVRDisplayChanged;
  41716. private moveButtonToBottomRight;
  41717. private displayVRButton;
  41718. private updateButtonVisibility;
  41719. private _cachedAngularSensibility;
  41720. /**
  41721. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41722. * Otherwise, will use the fullscreen API.
  41723. */
  41724. enterVR(): void;
  41725. /**
  41726. * Attempt to exit VR, or fullscreen.
  41727. */
  41728. exitVR(): void;
  41729. /**
  41730. * The position of the vr experience helper.
  41731. */
  41732. /**
  41733. * Sets the position of the vr experience helper.
  41734. */
  41735. position: Vector3;
  41736. /**
  41737. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41738. */
  41739. enableInteractions(): void;
  41740. private readonly _noControllerIsActive;
  41741. private beforeRender;
  41742. private _isTeleportationFloor;
  41743. /**
  41744. * Adds a floor mesh to be used for teleportation.
  41745. * @param floorMesh the mesh to be used for teleportation.
  41746. */
  41747. addFloorMesh(floorMesh: Mesh): void;
  41748. /**
  41749. * Removes a floor mesh from being used for teleportation.
  41750. * @param floorMesh the mesh to be removed.
  41751. */
  41752. removeFloorMesh(floorMesh: Mesh): void;
  41753. /**
  41754. * Enables interactions and teleportation using the VR controllers and gaze.
  41755. * @param vrTeleportationOptions options to modify teleportation behavior.
  41756. */
  41757. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41758. private _onNewGamepadConnected;
  41759. private _tryEnableInteractionOnController;
  41760. private _onNewGamepadDisconnected;
  41761. private _enableInteractionOnController;
  41762. private _checkTeleportWithRay;
  41763. private _checkRotate;
  41764. private _checkTeleportBackwards;
  41765. private _enableTeleportationOnController;
  41766. private _createTeleportationCircles;
  41767. private _displayTeleportationTarget;
  41768. private _hideTeleportationTarget;
  41769. private _rotateCamera;
  41770. private _moveTeleportationSelectorTo;
  41771. private _workingVector;
  41772. private _workingQuaternion;
  41773. private _workingMatrix;
  41774. /**
  41775. * Teleports the users feet to the desired location
  41776. * @param location The location where the user's feet should be placed
  41777. */
  41778. teleportCamera(location: Vector3): void;
  41779. private _convertNormalToDirectionOfRay;
  41780. private _castRayAndSelectObject;
  41781. private _notifySelectedMeshUnselected;
  41782. /**
  41783. * Sets the color of the laser ray from the vr controllers.
  41784. * @param color new color for the ray.
  41785. */
  41786. changeLaserColor(color: Color3): void;
  41787. /**
  41788. * Sets the color of the ray from the vr headsets gaze.
  41789. * @param color new color for the ray.
  41790. */
  41791. changeGazeColor(color: Color3): void;
  41792. /**
  41793. * Exits VR and disposes of the vr experience helper
  41794. */
  41795. dispose(): void;
  41796. /**
  41797. * Gets the name of the VRExperienceHelper class
  41798. * @returns "VRExperienceHelper"
  41799. */
  41800. getClassName(): string;
  41801. }
  41802. }
  41803. declare module "babylonjs/Cameras/VR/index" {
  41804. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  41805. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41806. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41807. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41808. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41809. export * from "babylonjs/Cameras/VR/webVRCamera";
  41810. }
  41811. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41812. import { Observable } from "babylonjs/Misc/observable";
  41813. import { Nullable } from "babylonjs/types";
  41814. import { IDisposable, Scene } from "babylonjs/scene";
  41815. import { Vector3 } from "babylonjs/Maths/math";
  41816. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41817. import { Ray } from "babylonjs/Culling/ray";
  41818. /**
  41819. * Manages an XRSession
  41820. * @see https://doc.babylonjs.com/how_to/webxr
  41821. */
  41822. export class WebXRSessionManager implements IDisposable {
  41823. private scene;
  41824. /**
  41825. * Fires every time a new xrFrame arrives which can be used to update the camera
  41826. */
  41827. onXRFrameObservable: Observable<any>;
  41828. /**
  41829. * Fires when the xr session is ended either by the device or manually done
  41830. */
  41831. onXRSessionEnded: Observable<any>;
  41832. /** @hidden */
  41833. _xrSession: XRSession;
  41834. /** @hidden */
  41835. _frameOfReference: XRFrameOfReference;
  41836. /** @hidden */
  41837. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41838. /** @hidden */
  41839. _currentXRFrame: Nullable<XRFrame>;
  41840. private _xrNavigator;
  41841. private _xrDevice;
  41842. private _tmpMatrix;
  41843. /**
  41844. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41845. * @param scene The scene which the session should be created for
  41846. */
  41847. constructor(scene: Scene);
  41848. /**
  41849. * Initializes the manager
  41850. * After initialization enterXR can be called to start an XR session
  41851. * @returns Promise which resolves after it is initialized
  41852. */
  41853. initializeAsync(): Promise<void>;
  41854. /**
  41855. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41856. * @param sessionCreationOptions xr options to create the session with
  41857. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41858. * @returns Promise which resolves after it enters XR
  41859. */
  41860. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41861. /**
  41862. * Stops the xrSession and restores the renderloop
  41863. * @returns Promise which resolves after it exits XR
  41864. */
  41865. exitXRAsync(): Promise<void>;
  41866. /**
  41867. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41868. * @param ray ray to cast into the environment
  41869. * @returns Promise which resolves with a collision point in the environment if it exists
  41870. */
  41871. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41872. /**
  41873. * Checks if a session would be supported for the creation options specified
  41874. * @param options creation options to check if they are supported
  41875. * @returns true if supported
  41876. */
  41877. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41878. /**
  41879. * @hidden
  41880. * Converts the render layer of xrSession to a render target
  41881. * @param session session to create render target for
  41882. * @param scene scene the new render target should be created for
  41883. */
  41884. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41885. /**
  41886. * Disposes of the session manager
  41887. */
  41888. dispose(): void;
  41889. }
  41890. }
  41891. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41892. import { Scene } from "babylonjs/scene";
  41893. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41894. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41895. /**
  41896. * WebXR Camera which holds the views for the xrSession
  41897. * @see https://doc.babylonjs.com/how_to/webxr
  41898. */
  41899. export class WebXRCamera extends FreeCamera {
  41900. private static _TmpMatrix;
  41901. /**
  41902. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41903. * @param name the name of the camera
  41904. * @param scene the scene to add the camera to
  41905. */
  41906. constructor(name: string, scene: Scene);
  41907. private _updateNumberOfRigCameras;
  41908. /** @hidden */
  41909. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41910. /**
  41911. * Updates the cameras position from the current pose information of the XR session
  41912. * @param xrSessionManager the session containing pose information
  41913. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41914. */
  41915. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41916. }
  41917. }
  41918. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41919. import { Nullable } from "babylonjs/types";
  41920. import { Observable } from "babylonjs/Misc/observable";
  41921. import { IDisposable, Scene } from "babylonjs/scene";
  41922. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41923. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41924. import { Ray } from "babylonjs/Culling/ray";
  41925. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41926. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41927. /**
  41928. * States of the webXR experience
  41929. */
  41930. export enum WebXRState {
  41931. /**
  41932. * Transitioning to being in XR mode
  41933. */
  41934. ENTERING_XR = 0,
  41935. /**
  41936. * Transitioning to non XR mode
  41937. */
  41938. EXITING_XR = 1,
  41939. /**
  41940. * In XR mode and presenting
  41941. */
  41942. IN_XR = 2,
  41943. /**
  41944. * Not entered XR mode
  41945. */
  41946. NOT_IN_XR = 3
  41947. }
  41948. /**
  41949. * Helper class used to enable XR
  41950. * @see https://doc.babylonjs.com/how_to/webxr
  41951. */
  41952. export class WebXRExperienceHelper implements IDisposable {
  41953. private scene;
  41954. /**
  41955. * 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
  41956. */
  41957. container: AbstractMesh;
  41958. /**
  41959. * Camera used to render xr content
  41960. */
  41961. camera: WebXRCamera;
  41962. /**
  41963. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41964. */
  41965. state: WebXRState;
  41966. private _setState;
  41967. private static _TmpVector;
  41968. /**
  41969. * Fires when the state of the experience helper has changed
  41970. */
  41971. onStateChangedObservable: Observable<WebXRState>;
  41972. /** @hidden */
  41973. _sessionManager: WebXRSessionManager;
  41974. private _nonVRCamera;
  41975. private _originalSceneAutoClear;
  41976. private _supported;
  41977. /**
  41978. * Creates the experience helper
  41979. * @param scene the scene to attach the experience helper to
  41980. * @returns a promise for the experience helper
  41981. */
  41982. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41983. /**
  41984. * Creates a WebXRExperienceHelper
  41985. * @param scene The scene the helper should be created in
  41986. */
  41987. private constructor();
  41988. /**
  41989. * Exits XR mode and returns the scene to its original state
  41990. * @returns promise that resolves after xr mode has exited
  41991. */
  41992. exitXRAsync(): Promise<void>;
  41993. /**
  41994. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41995. * @param sessionCreationOptions options for the XR session
  41996. * @param frameOfReference frame of reference of the XR session
  41997. * @returns promise that resolves after xr mode has entered
  41998. */
  41999. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  42000. /**
  42001. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  42002. * @param ray ray to cast into the environment
  42003. * @returns Promise which resolves with a collision point in the environment if it exists
  42004. */
  42005. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  42006. /**
  42007. * Updates the global position of the camera by moving the camera's container
  42008. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42009. * @param position The desired global position of the camera
  42010. */
  42011. setPositionOfCameraUsingContainer(position: Vector3): void;
  42012. /**
  42013. * Rotates the xr camera by rotating the camera's container around the camera's position
  42014. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42015. * @param rotation the desired quaternion rotation to apply to the camera
  42016. */
  42017. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42018. /**
  42019. * Checks if the creation options are supported by the xr session
  42020. * @param options creation options
  42021. * @returns true if supported
  42022. */
  42023. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  42024. /**
  42025. * Disposes of the experience helper
  42026. */
  42027. dispose(): void;
  42028. }
  42029. }
  42030. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42031. import { Nullable } from "babylonjs/types";
  42032. import { Observable } from "babylonjs/Misc/observable";
  42033. import { IDisposable, Scene } from "babylonjs/scene";
  42034. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42035. /**
  42036. * Button which can be used to enter a different mode of XR
  42037. */
  42038. export class WebXREnterExitUIButton {
  42039. /** button element */
  42040. element: HTMLElement;
  42041. /** XR initialization options for the button */
  42042. initializationOptions: XRSessionCreationOptions;
  42043. /**
  42044. * Creates a WebXREnterExitUIButton
  42045. * @param element button element
  42046. * @param initializationOptions XR initialization options for the button
  42047. */
  42048. constructor(
  42049. /** button element */
  42050. element: HTMLElement,
  42051. /** XR initialization options for the button */
  42052. initializationOptions: XRSessionCreationOptions);
  42053. /**
  42054. * Overwritable function which can be used to update the button's visuals when the state changes
  42055. * @param activeButton the current active button in the UI
  42056. */
  42057. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42058. }
  42059. /**
  42060. * Options to create the webXR UI
  42061. */
  42062. export class WebXREnterExitUIOptions {
  42063. /**
  42064. * Context to enter xr with
  42065. */
  42066. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  42067. /**
  42068. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42069. */
  42070. customButtons?: Array<WebXREnterExitUIButton>;
  42071. }
  42072. /**
  42073. * UI to allow the user to enter/exit XR mode
  42074. */
  42075. export class WebXREnterExitUI implements IDisposable {
  42076. private scene;
  42077. private _overlay;
  42078. private _buttons;
  42079. private _activeButton;
  42080. /**
  42081. * Fired every time the active button is changed.
  42082. *
  42083. * When xr is entered via a button that launches xr that button will be the callback parameter
  42084. *
  42085. * When exiting xr the callback parameter will be null)
  42086. */
  42087. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42088. /**
  42089. * Creates UI to allow the user to enter/exit XR mode
  42090. * @param scene the scene to add the ui to
  42091. * @param helper the xr experience helper to enter/exit xr with
  42092. * @param options options to configure the UI
  42093. * @returns the created ui
  42094. */
  42095. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42096. private constructor();
  42097. private _updateButtons;
  42098. /**
  42099. * Disposes of the object
  42100. */
  42101. dispose(): void;
  42102. }
  42103. }
  42104. declare module "babylonjs/Cameras/XR/webXRInput" {
  42105. import { IDisposable, Scene } from "babylonjs/scene";
  42106. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42107. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42108. /**
  42109. * Represents an XR input
  42110. */
  42111. export class WebXRController {
  42112. /**
  42113. * 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
  42114. */
  42115. grip?: AbstractMesh;
  42116. /**
  42117. * Pointer which can be used to select objects or attach a visible laser to
  42118. */
  42119. pointer: AbstractMesh;
  42120. /**
  42121. * Creates the controller
  42122. * @see https://doc.babylonjs.com/how_to/webxr
  42123. * @param scene the scene which the controller should be associated to
  42124. */
  42125. constructor(scene: Scene);
  42126. /**
  42127. * Disposes of the object
  42128. */
  42129. dispose(): void;
  42130. }
  42131. /**
  42132. * XR input used to track XR inputs such as controllers/rays
  42133. */
  42134. export class WebXRInput implements IDisposable {
  42135. private helper;
  42136. /**
  42137. * XR controllers being tracked
  42138. */
  42139. controllers: Array<WebXRController>;
  42140. private _tmpMatrix;
  42141. private _frameObserver;
  42142. /**
  42143. * Initializes the WebXRInput
  42144. * @param helper experience helper which the input should be created for
  42145. */
  42146. constructor(helper: WebXRExperienceHelper);
  42147. /**
  42148. * Disposes of the object
  42149. */
  42150. dispose(): void;
  42151. }
  42152. }
  42153. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42154. import { Nullable } from "babylonjs/types";
  42155. import { IDisposable } from "babylonjs/scene";
  42156. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42157. /**
  42158. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42159. */
  42160. export class WebXRManagedOutputCanvas implements IDisposable {
  42161. private _canvas;
  42162. /**
  42163. * xrpresent context of the canvas which can be used to display/mirror xr content
  42164. */
  42165. canvasContext: Nullable<WebGLRenderingContext>;
  42166. /**
  42167. * Initializes the canvas to be added/removed upon entering/exiting xr
  42168. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42169. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42170. */
  42171. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42172. /**
  42173. * Disposes of the object
  42174. */
  42175. dispose(): void;
  42176. private _setManagedOutputCanvas;
  42177. private _addCanvas;
  42178. private _removeCanvas;
  42179. }
  42180. }
  42181. declare module "babylonjs/Cameras/XR/index" {
  42182. export * from "babylonjs/Cameras/XR/webXRCamera";
  42183. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  42184. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42185. export * from "babylonjs/Cameras/XR/webXRInput";
  42186. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42187. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  42188. }
  42189. declare module "babylonjs/Cameras/RigModes/index" {
  42190. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42191. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42192. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  42193. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  42194. }
  42195. declare module "babylonjs/Cameras/index" {
  42196. export * from "babylonjs/Cameras/Inputs/index";
  42197. export * from "babylonjs/Cameras/cameraInputsManager";
  42198. export * from "babylonjs/Cameras/camera";
  42199. export * from "babylonjs/Cameras/targetCamera";
  42200. export * from "babylonjs/Cameras/freeCamera";
  42201. export * from "babylonjs/Cameras/freeCameraInputsManager";
  42202. export * from "babylonjs/Cameras/touchCamera";
  42203. export * from "babylonjs/Cameras/arcRotateCamera";
  42204. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  42205. export * from "babylonjs/Cameras/deviceOrientationCamera";
  42206. export * from "babylonjs/Cameras/flyCamera";
  42207. export * from "babylonjs/Cameras/flyCameraInputsManager";
  42208. export * from "babylonjs/Cameras/followCamera";
  42209. export * from "babylonjs/Cameras/gamepadCamera";
  42210. export * from "babylonjs/Cameras/Stereoscopic/index";
  42211. export * from "babylonjs/Cameras/universalCamera";
  42212. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  42213. export * from "babylonjs/Cameras/VR/index";
  42214. export * from "babylonjs/Cameras/XR/index";
  42215. export * from "babylonjs/Cameras/RigModes/index";
  42216. }
  42217. declare module "babylonjs/Collisions/index" {
  42218. export * from "babylonjs/Collisions/collider";
  42219. export * from "babylonjs/Collisions/collisionCoordinator";
  42220. export * from "babylonjs/Collisions/pickingInfo";
  42221. export * from "babylonjs/Collisions/intersectionInfo";
  42222. export * from "babylonjs/Collisions/meshCollisionData";
  42223. }
  42224. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  42225. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  42226. import { Vector3, Plane } from "babylonjs/Maths/math";
  42227. import { Ray } from "babylonjs/Culling/ray";
  42228. /**
  42229. * Contains an array of blocks representing the octree
  42230. */
  42231. export interface IOctreeContainer<T> {
  42232. /**
  42233. * Blocks within the octree
  42234. */
  42235. blocks: Array<OctreeBlock<T>>;
  42236. }
  42237. /**
  42238. * Class used to store a cell in an octree
  42239. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42240. */
  42241. export class OctreeBlock<T> {
  42242. /**
  42243. * Gets the content of the current block
  42244. */
  42245. entries: T[];
  42246. /**
  42247. * Gets the list of block children
  42248. */
  42249. blocks: Array<OctreeBlock<T>>;
  42250. private _depth;
  42251. private _maxDepth;
  42252. private _capacity;
  42253. private _minPoint;
  42254. private _maxPoint;
  42255. private _boundingVectors;
  42256. private _creationFunc;
  42257. /**
  42258. * Creates a new block
  42259. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42260. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42261. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42262. * @param depth defines the current depth of this block in the octree
  42263. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42264. * @param creationFunc defines a callback to call when an element is added to the block
  42265. */
  42266. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42267. /**
  42268. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42269. */
  42270. readonly capacity: number;
  42271. /**
  42272. * Gets the minimum vector (in world space) of the block's bounding box
  42273. */
  42274. readonly minPoint: Vector3;
  42275. /**
  42276. * Gets the maximum vector (in world space) of the block's bounding box
  42277. */
  42278. readonly maxPoint: Vector3;
  42279. /**
  42280. * Add a new element to this block
  42281. * @param entry defines the element to add
  42282. */
  42283. addEntry(entry: T): void;
  42284. /**
  42285. * Remove an element from this block
  42286. * @param entry defines the element to remove
  42287. */
  42288. removeEntry(entry: T): void;
  42289. /**
  42290. * Add an array of elements to this block
  42291. * @param entries defines the array of elements to add
  42292. */
  42293. addEntries(entries: T[]): void;
  42294. /**
  42295. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42296. * @param frustumPlanes defines the frustum planes to test
  42297. * @param selection defines the array to store current content if selection is positive
  42298. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42299. */
  42300. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42301. /**
  42302. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42303. * @param sphereCenter defines the bounding sphere center
  42304. * @param sphereRadius defines the bounding sphere radius
  42305. * @param selection defines the array to store current content if selection is positive
  42306. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42307. */
  42308. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42309. /**
  42310. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42311. * @param ray defines the ray to test with
  42312. * @param selection defines the array to store current content if selection is positive
  42313. */
  42314. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42315. /**
  42316. * Subdivide the content into child blocks (this block will then be empty)
  42317. */
  42318. createInnerBlocks(): void;
  42319. /**
  42320. * @hidden
  42321. */
  42322. 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;
  42323. }
  42324. }
  42325. declare module "babylonjs/Culling/Octrees/octree" {
  42326. import { SmartArray } from "babylonjs/Misc/smartArray";
  42327. import { Vector3, Plane } from "babylonjs/Maths/math";
  42328. import { SubMesh } from "babylonjs/Meshes/subMesh";
  42329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42330. import { Ray } from "babylonjs/Culling/ray";
  42331. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  42332. /**
  42333. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42334. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42335. */
  42336. export class Octree<T> {
  42337. /** 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.) */
  42338. maxDepth: number;
  42339. /**
  42340. * Blocks within the octree containing objects
  42341. */
  42342. blocks: Array<OctreeBlock<T>>;
  42343. /**
  42344. * Content stored in the octree
  42345. */
  42346. dynamicContent: T[];
  42347. private _maxBlockCapacity;
  42348. private _selectionContent;
  42349. private _creationFunc;
  42350. /**
  42351. * Creates a octree
  42352. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42353. * @param creationFunc function to be used to instatiate the octree
  42354. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42355. * @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.)
  42356. */
  42357. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42358. /** 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.) */
  42359. maxDepth?: number);
  42360. /**
  42361. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42362. * @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);
  42363. * @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);
  42364. * @param entries meshes to be added to the octree blocks
  42365. */
  42366. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42367. /**
  42368. * Adds a mesh to the octree
  42369. * @param entry Mesh to add to the octree
  42370. */
  42371. addMesh(entry: T): void;
  42372. /**
  42373. * Remove an element from the octree
  42374. * @param entry defines the element to remove
  42375. */
  42376. removeMesh(entry: T): void;
  42377. /**
  42378. * Selects an array of meshes within the frustum
  42379. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42380. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42381. * @returns array of meshes within the frustum
  42382. */
  42383. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42384. /**
  42385. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42386. * @param sphereCenter defines the bounding sphere center
  42387. * @param sphereRadius defines the bounding sphere radius
  42388. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42389. * @returns an array of objects that intersect the sphere
  42390. */
  42391. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42392. /**
  42393. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42394. * @param ray defines the ray to test with
  42395. * @returns array of intersected objects
  42396. */
  42397. intersectsRay(ray: Ray): SmartArray<T>;
  42398. /**
  42399. * Adds a mesh into the octree block if it intersects the block
  42400. */
  42401. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42402. /**
  42403. * Adds a submesh into the octree block if it intersects the block
  42404. */
  42405. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42406. }
  42407. }
  42408. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  42409. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  42410. import { Scene } from "babylonjs/scene";
  42411. import { SubMesh } from "babylonjs/Meshes/subMesh";
  42412. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42413. import { Ray } from "babylonjs/Culling/ray";
  42414. import { Octree } from "babylonjs/Culling/Octrees/octree";
  42415. import { Collider } from "babylonjs/Collisions/collider";
  42416. module "babylonjs/scene" {
  42417. interface Scene {
  42418. /**
  42419. * @hidden
  42420. * Backing Filed
  42421. */
  42422. _selectionOctree: Octree<AbstractMesh>;
  42423. /**
  42424. * Gets the octree used to boost mesh selection (picking)
  42425. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42426. */
  42427. selectionOctree: Octree<AbstractMesh>;
  42428. /**
  42429. * Creates or updates the octree used to boost selection (picking)
  42430. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42431. * @param maxCapacity defines the maximum capacity per leaf
  42432. * @param maxDepth defines the maximum depth of the octree
  42433. * @returns an octree of AbstractMesh
  42434. */
  42435. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42436. }
  42437. }
  42438. module "babylonjs/Meshes/abstractMesh" {
  42439. interface AbstractMesh {
  42440. /**
  42441. * @hidden
  42442. * Backing Field
  42443. */
  42444. _submeshesOctree: Octree<SubMesh>;
  42445. /**
  42446. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42447. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42448. * @param maxCapacity defines the maximum size of each block (64 by default)
  42449. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42450. * @returns the new octree
  42451. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42452. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42453. */
  42454. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42455. }
  42456. }
  42457. /**
  42458. * Defines the octree scene component responsible to manage any octrees
  42459. * in a given scene.
  42460. */
  42461. export class OctreeSceneComponent {
  42462. /**
  42463. * The component name help to identify the component in the list of scene components.
  42464. */
  42465. readonly name: string;
  42466. /**
  42467. * The scene the component belongs to.
  42468. */
  42469. scene: Scene;
  42470. /**
  42471. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42472. */
  42473. readonly checksIsEnabled: boolean;
  42474. /**
  42475. * Creates a new instance of the component for the given scene
  42476. * @param scene Defines the scene to register the component in
  42477. */
  42478. constructor(scene: Scene);
  42479. /**
  42480. * Registers the component in a given scene
  42481. */
  42482. register(): void;
  42483. /**
  42484. * Return the list of active meshes
  42485. * @returns the list of active meshes
  42486. */
  42487. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42488. /**
  42489. * Return the list of active sub meshes
  42490. * @param mesh The mesh to get the candidates sub meshes from
  42491. * @returns the list of active sub meshes
  42492. */
  42493. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42494. private _tempRay;
  42495. /**
  42496. * Return the list of sub meshes intersecting with a given local ray
  42497. * @param mesh defines the mesh to find the submesh for
  42498. * @param localRay defines the ray in local space
  42499. * @returns the list of intersecting sub meshes
  42500. */
  42501. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42502. /**
  42503. * Return the list of sub meshes colliding with a collider
  42504. * @param mesh defines the mesh to find the submesh for
  42505. * @param collider defines the collider to evaluate the collision against
  42506. * @returns the list of colliding sub meshes
  42507. */
  42508. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42509. /**
  42510. * Rebuilds the elements related to this component in case of
  42511. * context lost for instance.
  42512. */
  42513. rebuild(): void;
  42514. /**
  42515. * Disposes the component and the associated ressources.
  42516. */
  42517. dispose(): void;
  42518. }
  42519. }
  42520. declare module "babylonjs/Culling/Octrees/index" {
  42521. export * from "babylonjs/Culling/Octrees/octree";
  42522. export * from "babylonjs/Culling/Octrees/octreeBlock";
  42523. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  42524. }
  42525. declare module "babylonjs/Culling/index" {
  42526. export * from "babylonjs/Culling/boundingBox";
  42527. export * from "babylonjs/Culling/boundingInfo";
  42528. export * from "babylonjs/Culling/boundingSphere";
  42529. export * from "babylonjs/Culling/Octrees/index";
  42530. export * from "babylonjs/Culling/ray";
  42531. }
  42532. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  42533. import { IDisposable, Scene } from "babylonjs/scene";
  42534. import { Nullable } from "babylonjs/types";
  42535. import { Observable } from "babylonjs/Misc/observable";
  42536. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42537. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  42538. import { Camera } from "babylonjs/Cameras/camera";
  42539. /**
  42540. * Renders a layer on top of an existing scene
  42541. */
  42542. export class UtilityLayerRenderer implements IDisposable {
  42543. /** the original scene that will be rendered on top of */
  42544. originalScene: Scene;
  42545. private _pointerCaptures;
  42546. private _lastPointerEvents;
  42547. private static _DefaultUtilityLayer;
  42548. private static _DefaultKeepDepthUtilityLayer;
  42549. private _sharedGizmoLight;
  42550. private _renderCamera;
  42551. /**
  42552. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42553. * @returns the camera that is used when rendering the utility layer
  42554. */
  42555. getRenderCamera(): Nullable<Camera>;
  42556. /**
  42557. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42558. * @param cam the camera that should be used when rendering the utility layer
  42559. */
  42560. setRenderCamera(cam: Nullable<Camera>): void;
  42561. /**
  42562. * @hidden
  42563. * Light which used by gizmos to get light shading
  42564. */
  42565. _getSharedGizmoLight(): HemisphericLight;
  42566. /**
  42567. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42568. */
  42569. pickUtilitySceneFirst: boolean;
  42570. /**
  42571. * 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)
  42572. */
  42573. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42574. /**
  42575. * 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)
  42576. */
  42577. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42578. /**
  42579. * The scene that is rendered on top of the original scene
  42580. */
  42581. utilityLayerScene: Scene;
  42582. /**
  42583. * If the utility layer should automatically be rendered on top of existing scene
  42584. */
  42585. shouldRender: boolean;
  42586. /**
  42587. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42588. */
  42589. onlyCheckPointerDownEvents: boolean;
  42590. /**
  42591. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42592. */
  42593. processAllEvents: boolean;
  42594. /**
  42595. * Observable raised when the pointer move from the utility layer scene to the main scene
  42596. */
  42597. onPointerOutObservable: Observable<number>;
  42598. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42599. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42600. private _afterRenderObserver;
  42601. private _sceneDisposeObserver;
  42602. private _originalPointerObserver;
  42603. /**
  42604. * Instantiates a UtilityLayerRenderer
  42605. * @param originalScene the original scene that will be rendered on top of
  42606. * @param handleEvents boolean indicating if the utility layer should handle events
  42607. */
  42608. constructor(
  42609. /** the original scene that will be rendered on top of */
  42610. originalScene: Scene, handleEvents?: boolean);
  42611. private _notifyObservers;
  42612. /**
  42613. * Renders the utility layers scene on top of the original scene
  42614. */
  42615. render(): void;
  42616. /**
  42617. * Disposes of the renderer
  42618. */
  42619. dispose(): void;
  42620. private _updateCamera;
  42621. }
  42622. }
  42623. declare module "babylonjs/Gizmos/gizmo" {
  42624. import { Nullable } from "babylonjs/types";
  42625. import { IDisposable } from "babylonjs/scene";
  42626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42627. import { Mesh } from "babylonjs/Meshes/mesh";
  42628. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42629. /**
  42630. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42631. */
  42632. export class Gizmo implements IDisposable {
  42633. /** The utility layer the gizmo will be added to */
  42634. gizmoLayer: UtilityLayerRenderer;
  42635. /**
  42636. * The root mesh of the gizmo
  42637. */
  42638. _rootMesh: Mesh;
  42639. private _attachedMesh;
  42640. /**
  42641. * Ratio for the scale of the gizmo (Default: 1)
  42642. */
  42643. scaleRatio: number;
  42644. /**
  42645. * If a custom mesh has been set (Default: false)
  42646. */
  42647. protected _customMeshSet: boolean;
  42648. /**
  42649. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42650. * * When set, interactions will be enabled
  42651. */
  42652. attachedMesh: Nullable<AbstractMesh>;
  42653. /**
  42654. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42655. * @param mesh The mesh to replace the default mesh of the gizmo
  42656. */
  42657. setCustomMesh(mesh: Mesh): void;
  42658. /**
  42659. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42660. */
  42661. updateGizmoRotationToMatchAttachedMesh: boolean;
  42662. /**
  42663. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42664. */
  42665. updateGizmoPositionToMatchAttachedMesh: boolean;
  42666. /**
  42667. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  42668. */
  42669. protected _updateScale: boolean;
  42670. protected _interactionsEnabled: boolean;
  42671. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42672. private _beforeRenderObserver;
  42673. private _tempVector;
  42674. /**
  42675. * Creates a gizmo
  42676. * @param gizmoLayer The utility layer the gizmo will be added to
  42677. */
  42678. constructor(
  42679. /** The utility layer the gizmo will be added to */
  42680. gizmoLayer?: UtilityLayerRenderer);
  42681. /**
  42682. * Updates the gizmo to match the attached mesh's position/rotation
  42683. */
  42684. protected _update(): void;
  42685. /**
  42686. * Disposes of the gizmo
  42687. */
  42688. dispose(): void;
  42689. }
  42690. }
  42691. declare module "babylonjs/Gizmos/planeDragGizmo" {
  42692. import { Observable } from "babylonjs/Misc/observable";
  42693. import { Nullable } from "babylonjs/types";
  42694. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42695. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42696. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42697. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42698. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42699. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42700. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42701. import { Scene } from "babylonjs/scene";
  42702. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42703. /**
  42704. * Single plane drag gizmo
  42705. */
  42706. export class PlaneDragGizmo extends Gizmo {
  42707. /**
  42708. * Drag behavior responsible for the gizmos dragging interactions
  42709. */
  42710. dragBehavior: PointerDragBehavior;
  42711. private _pointerObserver;
  42712. /**
  42713. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42714. */
  42715. snapDistance: number;
  42716. /**
  42717. * Event that fires each time the gizmo snaps to a new location.
  42718. * * snapDistance is the the change in distance
  42719. */
  42720. onSnapObservable: Observable<{
  42721. snapDistance: number;
  42722. }>;
  42723. private _plane;
  42724. private _coloredMaterial;
  42725. private _hoverMaterial;
  42726. private _isEnabled;
  42727. private _parent;
  42728. /** @hidden */
  42729. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42730. /** @hidden */
  42731. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42732. /**
  42733. * Creates a PlaneDragGizmo
  42734. * @param gizmoLayer The utility layer the gizmo will be added to
  42735. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42736. * @param color The color of the gizmo
  42737. */
  42738. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42739. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42740. /**
  42741. * If the gizmo is enabled
  42742. */
  42743. isEnabled: boolean;
  42744. /**
  42745. * Disposes of the gizmo
  42746. */
  42747. dispose(): void;
  42748. }
  42749. }
  42750. declare module "babylonjs/Gizmos/positionGizmo" {
  42751. import { Observable } from "babylonjs/Misc/observable";
  42752. import { Nullable } from "babylonjs/types";
  42753. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42754. import { Mesh } from "babylonjs/Meshes/mesh";
  42755. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42756. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  42757. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  42758. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42759. /**
  42760. * Gizmo that enables dragging a mesh along 3 axis
  42761. */
  42762. export class PositionGizmo extends Gizmo {
  42763. /**
  42764. * Internal gizmo used for interactions on the x axis
  42765. */
  42766. xGizmo: AxisDragGizmo;
  42767. /**
  42768. * Internal gizmo used for interactions on the y axis
  42769. */
  42770. yGizmo: AxisDragGizmo;
  42771. /**
  42772. * Internal gizmo used for interactions on the z axis
  42773. */
  42774. zGizmo: AxisDragGizmo;
  42775. /**
  42776. * Internal gizmo used for interactions on the yz plane
  42777. */
  42778. xPlaneGizmo: PlaneDragGizmo;
  42779. /**
  42780. * Internal gizmo used for interactions on the xz plane
  42781. */
  42782. yPlaneGizmo: PlaneDragGizmo;
  42783. /**
  42784. * Internal gizmo used for interactions on the xy plane
  42785. */
  42786. zPlaneGizmo: PlaneDragGizmo;
  42787. /**
  42788. * private variables
  42789. */
  42790. private _meshAttached;
  42791. private _updateGizmoRotationToMatchAttachedMesh;
  42792. private _snapDistance;
  42793. private _scaleRatio;
  42794. /** Fires an event when any of it's sub gizmos are dragged */
  42795. onDragStartObservable: Observable<unknown>;
  42796. /** Fires an event when any of it's sub gizmos are released from dragging */
  42797. onDragEndObservable: Observable<unknown>;
  42798. /**
  42799. * If set to true, planar drag is enabled
  42800. */
  42801. private _planarGizmoEnabled;
  42802. attachedMesh: Nullable<AbstractMesh>;
  42803. /**
  42804. * Creates a PositionGizmo
  42805. * @param gizmoLayer The utility layer the gizmo will be added to
  42806. */
  42807. constructor(gizmoLayer?: UtilityLayerRenderer);
  42808. /**
  42809. * If the planar drag gizmo is enabled
  42810. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42811. */
  42812. planarGizmoEnabled: boolean;
  42813. updateGizmoRotationToMatchAttachedMesh: boolean;
  42814. /**
  42815. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42816. */
  42817. snapDistance: number;
  42818. /**
  42819. * Ratio for the scale of the gizmo (Default: 1)
  42820. */
  42821. scaleRatio: number;
  42822. /**
  42823. * Disposes of the gizmo
  42824. */
  42825. dispose(): void;
  42826. /**
  42827. * CustomMeshes are not supported by this gizmo
  42828. * @param mesh The mesh to replace the default mesh of the gizmo
  42829. */
  42830. setCustomMesh(mesh: Mesh): void;
  42831. }
  42832. }
  42833. declare module "babylonjs/Gizmos/axisDragGizmo" {
  42834. import { Observable } from "babylonjs/Misc/observable";
  42835. import { Nullable } from "babylonjs/types";
  42836. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42837. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42838. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42839. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42840. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42841. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42842. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42843. import { Scene } from "babylonjs/scene";
  42844. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42845. /**
  42846. * Single axis drag gizmo
  42847. */
  42848. export class AxisDragGizmo extends Gizmo {
  42849. /**
  42850. * Drag behavior responsible for the gizmos dragging interactions
  42851. */
  42852. dragBehavior: PointerDragBehavior;
  42853. private _pointerObserver;
  42854. /**
  42855. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42856. */
  42857. snapDistance: number;
  42858. /**
  42859. * Event that fires each time the gizmo snaps to a new location.
  42860. * * snapDistance is the the change in distance
  42861. */
  42862. onSnapObservable: Observable<{
  42863. snapDistance: number;
  42864. }>;
  42865. private _isEnabled;
  42866. private _parent;
  42867. private _arrow;
  42868. private _coloredMaterial;
  42869. private _hoverMaterial;
  42870. /** @hidden */
  42871. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42872. /** @hidden */
  42873. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42874. /**
  42875. * Creates an AxisDragGizmo
  42876. * @param gizmoLayer The utility layer the gizmo will be added to
  42877. * @param dragAxis The axis which the gizmo will be able to drag on
  42878. * @param color The color of the gizmo
  42879. */
  42880. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42881. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42882. /**
  42883. * If the gizmo is enabled
  42884. */
  42885. isEnabled: boolean;
  42886. /**
  42887. * Disposes of the gizmo
  42888. */
  42889. dispose(): void;
  42890. }
  42891. }
  42892. declare module "babylonjs/Debug/axesViewer" {
  42893. import { Vector3 } from "babylonjs/Maths/math";
  42894. import { Nullable } from "babylonjs/types";
  42895. import { Scene } from "babylonjs/scene";
  42896. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42897. /**
  42898. * The Axes viewer will show 3 axes in a specific point in space
  42899. */
  42900. export class AxesViewer {
  42901. private _xAxis;
  42902. private _yAxis;
  42903. private _zAxis;
  42904. private _scaleLinesFactor;
  42905. private _instanced;
  42906. /**
  42907. * Gets the hosting scene
  42908. */
  42909. scene: Scene;
  42910. /**
  42911. * Gets or sets a number used to scale line length
  42912. */
  42913. scaleLines: number;
  42914. /** Gets the node hierarchy used to render x-axis */
  42915. readonly xAxis: TransformNode;
  42916. /** Gets the node hierarchy used to render y-axis */
  42917. readonly yAxis: TransformNode;
  42918. /** Gets the node hierarchy used to render z-axis */
  42919. readonly zAxis: TransformNode;
  42920. /**
  42921. * Creates a new AxesViewer
  42922. * @param scene defines the hosting scene
  42923. * @param scaleLines defines a number used to scale line length (1 by default)
  42924. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42925. * @param xAxis defines the node hierarchy used to render the x-axis
  42926. * @param yAxis defines the node hierarchy used to render the y-axis
  42927. * @param zAxis defines the node hierarchy used to render the z-axis
  42928. */
  42929. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42930. /**
  42931. * Force the viewer to update
  42932. * @param position defines the position of the viewer
  42933. * @param xaxis defines the x axis of the viewer
  42934. * @param yaxis defines the y axis of the viewer
  42935. * @param zaxis defines the z axis of the viewer
  42936. */
  42937. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42938. /**
  42939. * Creates an instance of this axes viewer.
  42940. * @returns a new axes viewer with instanced meshes
  42941. */
  42942. createInstance(): AxesViewer;
  42943. /** Releases resources */
  42944. dispose(): void;
  42945. private static _SetRenderingGroupId;
  42946. }
  42947. }
  42948. declare module "babylonjs/Debug/boneAxesViewer" {
  42949. import { Nullable } from "babylonjs/types";
  42950. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  42951. import { Vector3 } from "babylonjs/Maths/math";
  42952. import { Mesh } from "babylonjs/Meshes/mesh";
  42953. import { Bone } from "babylonjs/Bones/bone";
  42954. import { Scene } from "babylonjs/scene";
  42955. /**
  42956. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42957. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42958. */
  42959. export class BoneAxesViewer extends AxesViewer {
  42960. /**
  42961. * Gets or sets the target mesh where to display the axes viewer
  42962. */
  42963. mesh: Nullable<Mesh>;
  42964. /**
  42965. * Gets or sets the target bone where to display the axes viewer
  42966. */
  42967. bone: Nullable<Bone>;
  42968. /** Gets current position */
  42969. pos: Vector3;
  42970. /** Gets direction of X axis */
  42971. xaxis: Vector3;
  42972. /** Gets direction of Y axis */
  42973. yaxis: Vector3;
  42974. /** Gets direction of Z axis */
  42975. zaxis: Vector3;
  42976. /**
  42977. * Creates a new BoneAxesViewer
  42978. * @param scene defines the hosting scene
  42979. * @param bone defines the target bone
  42980. * @param mesh defines the target mesh
  42981. * @param scaleLines defines a scaling factor for line length (1 by default)
  42982. */
  42983. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42984. /**
  42985. * Force the viewer to update
  42986. */
  42987. update(): void;
  42988. /** Releases resources */
  42989. dispose(): void;
  42990. }
  42991. }
  42992. declare module "babylonjs/Debug/debugLayer" {
  42993. import { Scene } from "babylonjs/scene";
  42994. /**
  42995. * Interface used to define scene explorer extensibility option
  42996. */
  42997. export interface IExplorerExtensibilityOption {
  42998. /**
  42999. * Define the option label
  43000. */
  43001. label: string;
  43002. /**
  43003. * Defines the action to execute on click
  43004. */
  43005. action: (entity: any) => void;
  43006. }
  43007. /**
  43008. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  43009. */
  43010. export interface IExplorerExtensibilityGroup {
  43011. /**
  43012. * Defines a predicate to test if a given type mut be extended
  43013. */
  43014. predicate: (entity: any) => boolean;
  43015. /**
  43016. * Gets the list of options added to a type
  43017. */
  43018. entries: IExplorerExtensibilityOption[];
  43019. }
  43020. /**
  43021. * Interface used to define the options to use to create the Inspector
  43022. */
  43023. export interface IInspectorOptions {
  43024. /**
  43025. * Display in overlay mode (default: false)
  43026. */
  43027. overlay?: boolean;
  43028. /**
  43029. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  43030. */
  43031. globalRoot?: HTMLElement;
  43032. /**
  43033. * Display the Scene explorer
  43034. */
  43035. showExplorer?: boolean;
  43036. /**
  43037. * Display the property inspector
  43038. */
  43039. showInspector?: boolean;
  43040. /**
  43041. * Display in embed mode (both panes on the right)
  43042. */
  43043. embedMode?: boolean;
  43044. /**
  43045. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  43046. */
  43047. handleResize?: boolean;
  43048. /**
  43049. * Allow the panes to popup (default: true)
  43050. */
  43051. enablePopup?: boolean;
  43052. /**
  43053. * Allow the panes to be closed by users (default: true)
  43054. */
  43055. enableClose?: boolean;
  43056. /**
  43057. * Optional list of extensibility entries
  43058. */
  43059. explorerExtensibility?: IExplorerExtensibilityGroup[];
  43060. /**
  43061. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  43062. */
  43063. inspectorURL?: string;
  43064. }
  43065. module "babylonjs/scene" {
  43066. interface Scene {
  43067. /**
  43068. * @hidden
  43069. * Backing field
  43070. */
  43071. _debugLayer: DebugLayer;
  43072. /**
  43073. * Gets the debug layer (aka Inspector) associated with the scene
  43074. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43075. */
  43076. debugLayer: DebugLayer;
  43077. }
  43078. }
  43079. /**
  43080. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43081. * what is happening in your scene
  43082. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43083. */
  43084. export class DebugLayer {
  43085. /**
  43086. * Define the url to get the inspector script from.
  43087. * By default it uses the babylonjs CDN.
  43088. * @ignoreNaming
  43089. */
  43090. static InspectorURL: string;
  43091. private _scene;
  43092. private BJSINSPECTOR;
  43093. private _onPropertyChangedObservable?;
  43094. /**
  43095. * Observable triggered when a property is changed through the inspector.
  43096. */
  43097. readonly onPropertyChangedObservable: any;
  43098. /**
  43099. * Instantiates a new debug layer.
  43100. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43101. * what is happening in your scene
  43102. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43103. * @param scene Defines the scene to inspect
  43104. */
  43105. constructor(scene: Scene);
  43106. /** Creates the inspector window. */
  43107. private _createInspector;
  43108. /**
  43109. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43110. * @param entity defines the entity to select
  43111. * @param lineContainerTitle defines the specific block to highlight
  43112. */
  43113. select(entity: any, lineContainerTitle?: string): void;
  43114. /** Get the inspector from bundle or global */
  43115. private _getGlobalInspector;
  43116. /**
  43117. * Get if the inspector is visible or not.
  43118. * @returns true if visible otherwise, false
  43119. */
  43120. isVisible(): boolean;
  43121. /**
  43122. * Hide the inspector and close its window.
  43123. */
  43124. hide(): void;
  43125. /**
  43126. * Launch the debugLayer.
  43127. * @param config Define the configuration of the inspector
  43128. * @return a promise fulfilled when the debug layer is visible
  43129. */
  43130. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43131. }
  43132. }
  43133. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  43134. import { Nullable } from "babylonjs/types";
  43135. import { Scene } from "babylonjs/scene";
  43136. import { Vector4, Color4 } from "babylonjs/Maths/math";
  43137. import { Mesh } from "babylonjs/Meshes/mesh";
  43138. /**
  43139. * Class containing static functions to help procedurally build meshes
  43140. */
  43141. export class BoxBuilder {
  43142. /**
  43143. * Creates a box mesh
  43144. * * The parameter `size` sets the size (float) of each box side (default 1)
  43145. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43146. * * 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)
  43147. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43148. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43149. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43150. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43151. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43152. * @param name defines the name of the mesh
  43153. * @param options defines the options used to create the mesh
  43154. * @param scene defines the hosting scene
  43155. * @returns the box mesh
  43156. */
  43157. static CreateBox(name: string, options: {
  43158. size?: number;
  43159. width?: number;
  43160. height?: number;
  43161. depth?: number;
  43162. faceUV?: Vector4[];
  43163. faceColors?: Color4[];
  43164. sideOrientation?: number;
  43165. frontUVs?: Vector4;
  43166. backUVs?: Vector4;
  43167. wrap?: boolean;
  43168. topBaseAt?: number;
  43169. bottomBaseAt?: number;
  43170. updatable?: boolean;
  43171. }, scene?: Nullable<Scene>): Mesh;
  43172. }
  43173. }
  43174. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  43175. import { Vector4 } from "babylonjs/Maths/math";
  43176. import { Mesh } from "babylonjs/Meshes/mesh";
  43177. /**
  43178. * Class containing static functions to help procedurally build meshes
  43179. */
  43180. export class SphereBuilder {
  43181. /**
  43182. * Creates a sphere mesh
  43183. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43184. * * 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`)
  43185. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43186. * * 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
  43187. * * 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)
  43188. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43189. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43191. * @param name defines the name of the mesh
  43192. * @param options defines the options used to create the mesh
  43193. * @param scene defines the hosting scene
  43194. * @returns the sphere mesh
  43195. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43196. */
  43197. static CreateSphere(name: string, options: {
  43198. segments?: number;
  43199. diameter?: number;
  43200. diameterX?: number;
  43201. diameterY?: number;
  43202. diameterZ?: number;
  43203. arc?: number;
  43204. slice?: number;
  43205. sideOrientation?: number;
  43206. frontUVs?: Vector4;
  43207. backUVs?: Vector4;
  43208. updatable?: boolean;
  43209. }, scene: any): Mesh;
  43210. }
  43211. }
  43212. declare module "babylonjs/Debug/physicsViewer" {
  43213. import { Nullable } from "babylonjs/types";
  43214. import { Scene } from "babylonjs/scene";
  43215. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43216. import { Mesh } from "babylonjs/Meshes/mesh";
  43217. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  43218. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  43219. /**
  43220. * Used to show the physics impostor around the specific mesh
  43221. */
  43222. export class PhysicsViewer {
  43223. /** @hidden */
  43224. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43225. /** @hidden */
  43226. protected _meshes: Array<Nullable<AbstractMesh>>;
  43227. /** @hidden */
  43228. protected _scene: Nullable<Scene>;
  43229. /** @hidden */
  43230. protected _numMeshes: number;
  43231. /** @hidden */
  43232. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43233. private _renderFunction;
  43234. private _utilityLayer;
  43235. private _debugBoxMesh;
  43236. private _debugSphereMesh;
  43237. private _debugCylinderMesh;
  43238. private _debugMaterial;
  43239. private _debugMeshMeshes;
  43240. /**
  43241. * Creates a new PhysicsViewer
  43242. * @param scene defines the hosting scene
  43243. */
  43244. constructor(scene: Scene);
  43245. /** @hidden */
  43246. protected _updateDebugMeshes(): void;
  43247. /**
  43248. * Renders a specified physic impostor
  43249. * @param impostor defines the impostor to render
  43250. * @param targetMesh defines the mesh represented by the impostor
  43251. * @returns the new debug mesh used to render the impostor
  43252. */
  43253. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43254. /**
  43255. * Hides a specified physic impostor
  43256. * @param impostor defines the impostor to hide
  43257. */
  43258. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43259. private _getDebugMaterial;
  43260. private _getDebugBoxMesh;
  43261. private _getDebugSphereMesh;
  43262. private _getDebugCylinderMesh;
  43263. private _getDebugMeshMesh;
  43264. private _getDebugMesh;
  43265. /** Releases all resources */
  43266. dispose(): void;
  43267. }
  43268. }
  43269. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  43270. import { Vector3, Color4 } from "babylonjs/Maths/math";
  43271. import { Nullable } from "babylonjs/types";
  43272. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  43273. import { Scene } from "babylonjs/scene";
  43274. /**
  43275. * Class containing static functions to help procedurally build meshes
  43276. */
  43277. export class LinesBuilder {
  43278. /**
  43279. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43280. * * 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
  43281. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43282. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43283. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43284. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43285. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43286. * * 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
  43287. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43289. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43290. * @param name defines the name of the new line system
  43291. * @param options defines the options used to create the line system
  43292. * @param scene defines the hosting scene
  43293. * @returns a new line system mesh
  43294. */
  43295. static CreateLineSystem(name: string, options: {
  43296. lines: Vector3[][];
  43297. updatable?: boolean;
  43298. instance?: Nullable<LinesMesh>;
  43299. colors?: Nullable<Color4[][]>;
  43300. useVertexAlpha?: boolean;
  43301. }, scene: Nullable<Scene>): LinesMesh;
  43302. /**
  43303. * Creates a line mesh
  43304. * 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
  43305. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43306. * * The parameter `points` is an array successive Vector3
  43307. * * 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
  43308. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43309. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43310. * * When updating an instance, remember that only point positions can change, not the number of points
  43311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43312. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43313. * @param name defines the name of the new line system
  43314. * @param options defines the options used to create the line system
  43315. * @param scene defines the hosting scene
  43316. * @returns a new line mesh
  43317. */
  43318. static CreateLines(name: string, options: {
  43319. points: Vector3[];
  43320. updatable?: boolean;
  43321. instance?: Nullable<LinesMesh>;
  43322. colors?: Color4[];
  43323. useVertexAlpha?: boolean;
  43324. }, scene?: Nullable<Scene>): LinesMesh;
  43325. /**
  43326. * Creates a dashed line mesh
  43327. * * 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
  43328. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43329. * * The parameter `points` is an array successive Vector3
  43330. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43331. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43332. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43333. * * 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
  43334. * * When updating an instance, remember that only point positions can change, not the number of points
  43335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43336. * @param name defines the name of the mesh
  43337. * @param options defines the options used to create the mesh
  43338. * @param scene defines the hosting scene
  43339. * @returns the dashed line mesh
  43340. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43341. */
  43342. static CreateDashedLines(name: string, options: {
  43343. points: Vector3[];
  43344. dashSize?: number;
  43345. gapSize?: number;
  43346. dashNb?: number;
  43347. updatable?: boolean;
  43348. instance?: LinesMesh;
  43349. }, scene?: Nullable<Scene>): LinesMesh;
  43350. }
  43351. }
  43352. declare module "babylonjs/Debug/rayHelper" {
  43353. import { Nullable } from "babylonjs/types";
  43354. import { Ray } from "babylonjs/Culling/ray";
  43355. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43356. import { Scene } from "babylonjs/scene";
  43357. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43358. import "babylonjs/Meshes/Builders/linesBuilder";
  43359. /**
  43360. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43361. * in order to better appreciate the issue one might have.
  43362. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43363. */
  43364. export class RayHelper {
  43365. /**
  43366. * Defines the ray we are currently tryin to visualize.
  43367. */
  43368. ray: Nullable<Ray>;
  43369. private _renderPoints;
  43370. private _renderLine;
  43371. private _renderFunction;
  43372. private _scene;
  43373. private _updateToMeshFunction;
  43374. private _attachedToMesh;
  43375. private _meshSpaceDirection;
  43376. private _meshSpaceOrigin;
  43377. /**
  43378. * Helper function to create a colored helper in a scene in one line.
  43379. * @param ray Defines the ray we are currently tryin to visualize
  43380. * @param scene Defines the scene the ray is used in
  43381. * @param color Defines the color we want to see the ray in
  43382. * @returns The newly created ray helper.
  43383. */
  43384. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43385. /**
  43386. * Instantiate a new ray helper.
  43387. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43388. * in order to better appreciate the issue one might have.
  43389. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43390. * @param ray Defines the ray we are currently tryin to visualize
  43391. */
  43392. constructor(ray: Ray);
  43393. /**
  43394. * Shows the ray we are willing to debug.
  43395. * @param scene Defines the scene the ray needs to be rendered in
  43396. * @param color Defines the color the ray needs to be rendered in
  43397. */
  43398. show(scene: Scene, color?: Color3): void;
  43399. /**
  43400. * Hides the ray we are debugging.
  43401. */
  43402. hide(): void;
  43403. private _render;
  43404. /**
  43405. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43406. * @param mesh Defines the mesh we want the helper attached to
  43407. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43408. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43409. * @param length Defines the length of the ray
  43410. */
  43411. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43412. /**
  43413. * Detach the ray helper from the mesh it has previously been attached to.
  43414. */
  43415. detachFromMesh(): void;
  43416. private _updateToMesh;
  43417. /**
  43418. * Dispose the helper and release its associated resources.
  43419. */
  43420. dispose(): void;
  43421. }
  43422. }
  43423. declare module "babylonjs/Debug/skeletonViewer" {
  43424. import { Color3 } from "babylonjs/Maths/math";
  43425. import { Scene } from "babylonjs/scene";
  43426. import { Nullable } from "babylonjs/types";
  43427. import { Skeleton } from "babylonjs/Bones/skeleton";
  43428. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43429. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  43430. /**
  43431. * Class used to render a debug view of a given skeleton
  43432. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43433. */
  43434. export class SkeletonViewer {
  43435. /** defines the skeleton to render */
  43436. skeleton: Skeleton;
  43437. /** defines the mesh attached to the skeleton */
  43438. mesh: AbstractMesh;
  43439. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43440. autoUpdateBonesMatrices: boolean;
  43441. /** defines the rendering group id to use with the viewer */
  43442. renderingGroupId: number;
  43443. /** Gets or sets the color used to render the skeleton */
  43444. color: Color3;
  43445. private _scene;
  43446. private _debugLines;
  43447. private _debugMesh;
  43448. private _isEnabled;
  43449. private _renderFunction;
  43450. private _utilityLayer;
  43451. /**
  43452. * Returns the mesh used to render the bones
  43453. */
  43454. readonly debugMesh: Nullable<LinesMesh>;
  43455. /**
  43456. * Creates a new SkeletonViewer
  43457. * @param skeleton defines the skeleton to render
  43458. * @param mesh defines the mesh attached to the skeleton
  43459. * @param scene defines the hosting scene
  43460. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43461. * @param renderingGroupId defines the rendering group id to use with the viewer
  43462. */
  43463. constructor(
  43464. /** defines the skeleton to render */
  43465. skeleton: Skeleton,
  43466. /** defines the mesh attached to the skeleton */
  43467. mesh: AbstractMesh, scene: Scene,
  43468. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43469. autoUpdateBonesMatrices?: boolean,
  43470. /** defines the rendering group id to use with the viewer */
  43471. renderingGroupId?: number);
  43472. /** Gets or sets a boolean indicating if the viewer is enabled */
  43473. isEnabled: boolean;
  43474. private _getBonePosition;
  43475. private _getLinesForBonesWithLength;
  43476. private _getLinesForBonesNoLength;
  43477. /** Update the viewer to sync with current skeleton state */
  43478. update(): void;
  43479. /** Release associated resources */
  43480. dispose(): void;
  43481. }
  43482. }
  43483. declare module "babylonjs/Debug/index" {
  43484. export * from "babylonjs/Debug/axesViewer";
  43485. export * from "babylonjs/Debug/boneAxesViewer";
  43486. export * from "babylonjs/Debug/debugLayer";
  43487. export * from "babylonjs/Debug/physicsViewer";
  43488. export * from "babylonjs/Debug/rayHelper";
  43489. export * from "babylonjs/Debug/skeletonViewer";
  43490. }
  43491. declare module "babylonjs/Engines/nullEngine" {
  43492. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  43493. import { Scene } from "babylonjs/scene";
  43494. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  43495. import { Engine } from "babylonjs/Engines/engine";
  43496. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  43497. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  43498. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43499. import { Effect } from "babylonjs/Materials/effect";
  43500. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  43501. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43502. /**
  43503. * Options to create the null engine
  43504. */
  43505. export class NullEngineOptions {
  43506. /**
  43507. * Render width (Default: 512)
  43508. */
  43509. renderWidth: number;
  43510. /**
  43511. * Render height (Default: 256)
  43512. */
  43513. renderHeight: number;
  43514. /**
  43515. * Texture size (Default: 512)
  43516. */
  43517. textureSize: number;
  43518. /**
  43519. * If delta time between frames should be constant
  43520. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43521. */
  43522. deterministicLockstep: boolean;
  43523. /**
  43524. * Maximum about of steps between frames (Default: 4)
  43525. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43526. */
  43527. lockstepMaxSteps: number;
  43528. }
  43529. /**
  43530. * The null engine class provides support for headless version of babylon.js.
  43531. * This can be used in server side scenario or for testing purposes
  43532. */
  43533. export class NullEngine extends Engine {
  43534. private _options;
  43535. /**
  43536. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43537. */
  43538. isDeterministicLockStep(): boolean;
  43539. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  43540. getLockstepMaxSteps(): number;
  43541. /**
  43542. * Sets hardware scaling, used to save performance if needed
  43543. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  43544. */
  43545. getHardwareScalingLevel(): number;
  43546. constructor(options?: NullEngineOptions);
  43547. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43548. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43549. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43550. getRenderWidth(useScreen?: boolean): number;
  43551. getRenderHeight(useScreen?: boolean): number;
  43552. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  43553. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43554. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43555. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43556. bindSamplers(effect: Effect): void;
  43557. enableEffect(effect: Effect): void;
  43558. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43559. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43560. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43561. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43562. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43563. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43564. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43565. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43566. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43567. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43568. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43569. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43570. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43571. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43572. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  43573. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43574. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43575. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43576. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43577. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43578. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43579. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43580. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  43581. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  43582. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43583. bindBuffers(vertexBuffers: {
  43584. [key: string]: VertexBuffer;
  43585. }, indexBuffer: DataBuffer, effect: Effect): void;
  43586. wipeCaches(bruteForce?: boolean): void;
  43587. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43588. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43589. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43590. /** @hidden */
  43591. _createTexture(): WebGLTexture;
  43592. /** @hidden */
  43593. _releaseTexture(texture: InternalTexture): void;
  43594. 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;
  43595. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43596. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43597. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43598. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43599. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43600. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43601. areAllEffectsReady(): boolean;
  43602. /**
  43603. * @hidden
  43604. * Get the current error code of the webGL context
  43605. * @returns the error code
  43606. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43607. */
  43608. getError(): number;
  43609. /** @hidden */
  43610. _getUnpackAlignement(): number;
  43611. /** @hidden */
  43612. _unpackFlipY(value: boolean): void;
  43613. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43614. /**
  43615. * Updates a dynamic vertex buffer.
  43616. * @param vertexBuffer the vertex buffer to update
  43617. * @param data the data used to update the vertex buffer
  43618. * @param byteOffset the byte offset of the data (optional)
  43619. * @param byteLength the byte length of the data (optional)
  43620. */
  43621. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43622. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43623. /** @hidden */
  43624. _bindTexture(channel: number, texture: InternalTexture): void;
  43625. /** @hidden */
  43626. _releaseBuffer(buffer: DataBuffer): boolean;
  43627. releaseEffects(): void;
  43628. displayLoadingUI(): void;
  43629. hideLoadingUI(): void;
  43630. /** @hidden */
  43631. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43632. /** @hidden */
  43633. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43634. /** @hidden */
  43635. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43636. /** @hidden */
  43637. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43638. }
  43639. }
  43640. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  43641. import { Nullable, int } from "babylonjs/types";
  43642. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  43643. /** @hidden */
  43644. export class _OcclusionDataStorage {
  43645. /** @hidden */
  43646. occlusionInternalRetryCounter: number;
  43647. /** @hidden */
  43648. isOcclusionQueryInProgress: boolean;
  43649. /** @hidden */
  43650. isOccluded: boolean;
  43651. /** @hidden */
  43652. occlusionRetryCount: number;
  43653. /** @hidden */
  43654. occlusionType: number;
  43655. /** @hidden */
  43656. occlusionQueryAlgorithmType: number;
  43657. }
  43658. module "babylonjs/Engines/engine" {
  43659. interface Engine {
  43660. /**
  43661. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43662. * @return the new query
  43663. */
  43664. createQuery(): WebGLQuery;
  43665. /**
  43666. * Delete and release a webGL query
  43667. * @param query defines the query to delete
  43668. * @return the current engine
  43669. */
  43670. deleteQuery(query: WebGLQuery): Engine;
  43671. /**
  43672. * Check if a given query has resolved and got its value
  43673. * @param query defines the query to check
  43674. * @returns true if the query got its value
  43675. */
  43676. isQueryResultAvailable(query: WebGLQuery): boolean;
  43677. /**
  43678. * Gets the value of a given query
  43679. * @param query defines the query to check
  43680. * @returns the value of the query
  43681. */
  43682. getQueryResult(query: WebGLQuery): number;
  43683. /**
  43684. * Initiates an occlusion query
  43685. * @param algorithmType defines the algorithm to use
  43686. * @param query defines the query to use
  43687. * @returns the current engine
  43688. * @see http://doc.babylonjs.com/features/occlusionquery
  43689. */
  43690. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43691. /**
  43692. * Ends an occlusion query
  43693. * @see http://doc.babylonjs.com/features/occlusionquery
  43694. * @param algorithmType defines the algorithm to use
  43695. * @returns the current engine
  43696. */
  43697. endOcclusionQuery(algorithmType: number): Engine;
  43698. /**
  43699. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43700. * Please note that only one query can be issued at a time
  43701. * @returns a time token used to track the time span
  43702. */
  43703. startTimeQuery(): Nullable<_TimeToken>;
  43704. /**
  43705. * Ends a time query
  43706. * @param token defines the token used to measure the time span
  43707. * @returns the time spent (in ns)
  43708. */
  43709. endTimeQuery(token: _TimeToken): int;
  43710. /** @hidden */
  43711. _currentNonTimestampToken: Nullable<_TimeToken>;
  43712. /** @hidden */
  43713. _createTimeQuery(): WebGLQuery;
  43714. /** @hidden */
  43715. _deleteTimeQuery(query: WebGLQuery): void;
  43716. /** @hidden */
  43717. _getGlAlgorithmType(algorithmType: number): number;
  43718. /** @hidden */
  43719. _getTimeQueryResult(query: WebGLQuery): any;
  43720. /** @hidden */
  43721. _getTimeQueryAvailability(query: WebGLQuery): any;
  43722. }
  43723. }
  43724. module "babylonjs/Meshes/abstractMesh" {
  43725. interface AbstractMesh {
  43726. /**
  43727. * Backing filed
  43728. * @hidden
  43729. */
  43730. __occlusionDataStorage: _OcclusionDataStorage;
  43731. /**
  43732. * Access property
  43733. * @hidden
  43734. */
  43735. _occlusionDataStorage: _OcclusionDataStorage;
  43736. /**
  43737. * 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.
  43738. * The default value is -1 which means don't break the query and wait till the result
  43739. * @see http://doc.babylonjs.com/features/occlusionquery
  43740. */
  43741. occlusionRetryCount: number;
  43742. /**
  43743. * 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:
  43744. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43745. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43746. * * 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.
  43747. * @see http://doc.babylonjs.com/features/occlusionquery
  43748. */
  43749. occlusionType: number;
  43750. /**
  43751. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43752. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43753. * * 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.
  43754. * @see http://doc.babylonjs.com/features/occlusionquery
  43755. */
  43756. occlusionQueryAlgorithmType: number;
  43757. /**
  43758. * 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
  43759. * @see http://doc.babylonjs.com/features/occlusionquery
  43760. */
  43761. isOccluded: boolean;
  43762. /**
  43763. * Flag to check the progress status of the query
  43764. * @see http://doc.babylonjs.com/features/occlusionquery
  43765. */
  43766. isOcclusionQueryInProgress: boolean;
  43767. }
  43768. }
  43769. }
  43770. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  43771. import { Nullable } from "babylonjs/types";
  43772. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43773. /** @hidden */
  43774. export var _forceTransformFeedbackToBundle: boolean;
  43775. module "babylonjs/Engines/engine" {
  43776. interface Engine {
  43777. /**
  43778. * Creates a webGL transform feedback object
  43779. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43780. * @returns the webGL transform feedback object
  43781. */
  43782. createTransformFeedback(): WebGLTransformFeedback;
  43783. /**
  43784. * Delete a webGL transform feedback object
  43785. * @param value defines the webGL transform feedback object to delete
  43786. */
  43787. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43788. /**
  43789. * Bind a webGL transform feedback object to the webgl context
  43790. * @param value defines the webGL transform feedback object to bind
  43791. */
  43792. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43793. /**
  43794. * Begins a transform feedback operation
  43795. * @param usePoints defines if points or triangles must be used
  43796. */
  43797. beginTransformFeedback(usePoints: boolean): void;
  43798. /**
  43799. * Ends a transform feedback operation
  43800. */
  43801. endTransformFeedback(): void;
  43802. /**
  43803. * Specify the varyings to use with transform feedback
  43804. * @param program defines the associated webGL program
  43805. * @param value defines the list of strings representing the varying names
  43806. */
  43807. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43808. /**
  43809. * Bind a webGL buffer for a transform feedback operation
  43810. * @param value defines the webGL buffer to bind
  43811. */
  43812. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43813. }
  43814. }
  43815. }
  43816. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  43817. import { Scene } from "babylonjs/scene";
  43818. import { Engine } from "babylonjs/Engines/engine";
  43819. import { Texture } from "babylonjs/Materials/Textures/texture";
  43820. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43821. import "babylonjs/Engines/Extensions/engine.multiRender";
  43822. /**
  43823. * Creation options of the multi render target texture.
  43824. */
  43825. export interface IMultiRenderTargetOptions {
  43826. /**
  43827. * Define if the texture needs to create mip maps after render.
  43828. */
  43829. generateMipMaps?: boolean;
  43830. /**
  43831. * Define the types of all the draw buffers we want to create
  43832. */
  43833. types?: number[];
  43834. /**
  43835. * Define the sampling modes of all the draw buffers we want to create
  43836. */
  43837. samplingModes?: number[];
  43838. /**
  43839. * Define if a depth buffer is required
  43840. */
  43841. generateDepthBuffer?: boolean;
  43842. /**
  43843. * Define if a stencil buffer is required
  43844. */
  43845. generateStencilBuffer?: boolean;
  43846. /**
  43847. * Define if a depth texture is required instead of a depth buffer
  43848. */
  43849. generateDepthTexture?: boolean;
  43850. /**
  43851. * Define the number of desired draw buffers
  43852. */
  43853. textureCount?: number;
  43854. /**
  43855. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43856. */
  43857. doNotChangeAspectRatio?: boolean;
  43858. /**
  43859. * Define the default type of the buffers we are creating
  43860. */
  43861. defaultType?: number;
  43862. }
  43863. /**
  43864. * A multi render target, like a render target provides the ability to render to a texture.
  43865. * Unlike the render target, it can render to several draw buffers in one draw.
  43866. * This is specially interesting in deferred rendering or for any effects requiring more than
  43867. * just one color from a single pass.
  43868. */
  43869. export class MultiRenderTarget extends RenderTargetTexture {
  43870. private _internalTextures;
  43871. private _textures;
  43872. private _multiRenderTargetOptions;
  43873. /**
  43874. * Get if draw buffers are currently supported by the used hardware and browser.
  43875. */
  43876. readonly isSupported: boolean;
  43877. /**
  43878. * Get the list of textures generated by the multi render target.
  43879. */
  43880. readonly textures: Texture[];
  43881. /**
  43882. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43883. */
  43884. readonly depthTexture: Texture;
  43885. /**
  43886. * Set the wrapping mode on U of all the textures we are rendering to.
  43887. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43888. */
  43889. wrapU: number;
  43890. /**
  43891. * Set the wrapping mode on V of all the textures we are rendering to.
  43892. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43893. */
  43894. wrapV: number;
  43895. /**
  43896. * Instantiate a new multi render target texture.
  43897. * A multi render target, like a render target provides the ability to render to a texture.
  43898. * Unlike the render target, it can render to several draw buffers in one draw.
  43899. * This is specially interesting in deferred rendering or for any effects requiring more than
  43900. * just one color from a single pass.
  43901. * @param name Define the name of the texture
  43902. * @param size Define the size of the buffers to render to
  43903. * @param count Define the number of target we are rendering into
  43904. * @param scene Define the scene the texture belongs to
  43905. * @param options Define the options used to create the multi render target
  43906. */
  43907. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43908. /** @hidden */
  43909. _rebuild(): void;
  43910. private _createInternalTextures;
  43911. private _createTextures;
  43912. /**
  43913. * Define the number of samples used if MSAA is enabled.
  43914. */
  43915. samples: number;
  43916. /**
  43917. * Resize all the textures in the multi render target.
  43918. * Be carrefull as it will recreate all the data in the new texture.
  43919. * @param size Define the new size
  43920. */
  43921. resize(size: any): void;
  43922. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43923. /**
  43924. * Dispose the render targets and their associated resources
  43925. */
  43926. dispose(): void;
  43927. /**
  43928. * Release all the underlying texture used as draw buffers.
  43929. */
  43930. releaseInternalTextures(): void;
  43931. }
  43932. }
  43933. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  43934. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43935. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  43936. import { Nullable } from "babylonjs/types";
  43937. module "babylonjs/Engines/engine" {
  43938. interface Engine {
  43939. /**
  43940. * Unbind a list of render target textures from the webGL context
  43941. * This is used only when drawBuffer extension or webGL2 are active
  43942. * @param textures defines the render target textures to unbind
  43943. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43944. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43945. */
  43946. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43947. /**
  43948. * Create a multi render target texture
  43949. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43950. * @param size defines the size of the texture
  43951. * @param options defines the creation options
  43952. * @returns the cube texture as an InternalTexture
  43953. */
  43954. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43955. /**
  43956. * Update the sample count for a given multiple render target texture
  43957. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43958. * @param textures defines the textures to update
  43959. * @param samples defines the sample count to set
  43960. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43961. */
  43962. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43963. }
  43964. }
  43965. }
  43966. declare module "babylonjs/Engines/Extensions/index" {
  43967. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  43968. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  43969. export * from "babylonjs/Engines/Extensions/engine.multiview";
  43970. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  43971. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  43972. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  43973. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  43974. export * from "babylonjs/Engines/Extensions/engine.webVR";
  43975. }
  43976. declare module "babylonjs/Engines/index" {
  43977. export * from "babylonjs/Engines/constants";
  43978. export * from "babylonjs/Engines/engine";
  43979. export * from "babylonjs/Engines/engineStore";
  43980. export * from "babylonjs/Engines/nullEngine";
  43981. export * from "babylonjs/Engines/Extensions/index";
  43982. export * from "babylonjs/Engines/IPipelineContext";
  43983. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  43984. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  43985. }
  43986. declare module "babylonjs/Events/clipboardEvents" {
  43987. /**
  43988. * Gather the list of clipboard event types as constants.
  43989. */
  43990. export class ClipboardEventTypes {
  43991. /**
  43992. * The clipboard event is fired when a copy command is active (pressed).
  43993. */
  43994. static readonly COPY: number;
  43995. /**
  43996. * The clipboard event is fired when a cut command is active (pressed).
  43997. */
  43998. static readonly CUT: number;
  43999. /**
  44000. * The clipboard event is fired when a paste command is active (pressed).
  44001. */
  44002. static readonly PASTE: number;
  44003. }
  44004. /**
  44005. * This class is used to store clipboard related info for the onClipboardObservable event.
  44006. */
  44007. export class ClipboardInfo {
  44008. /**
  44009. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44010. */
  44011. type: number;
  44012. /**
  44013. * Defines the related dom event
  44014. */
  44015. event: ClipboardEvent;
  44016. /**
  44017. *Creates an instance of ClipboardInfo.
  44018. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  44019. * @param event Defines the related dom event
  44020. */
  44021. constructor(
  44022. /**
  44023. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44024. */
  44025. type: number,
  44026. /**
  44027. * Defines the related dom event
  44028. */
  44029. event: ClipboardEvent);
  44030. /**
  44031. * Get the clipboard event's type from the keycode.
  44032. * @param keyCode Defines the keyCode for the current keyboard event.
  44033. * @return {number}
  44034. */
  44035. static GetTypeFromCharacter(keyCode: number): number;
  44036. }
  44037. }
  44038. declare module "babylonjs/Events/index" {
  44039. export * from "babylonjs/Events/keyboardEvents";
  44040. export * from "babylonjs/Events/pointerEvents";
  44041. export * from "babylonjs/Events/clipboardEvents";
  44042. }
  44043. declare module "babylonjs/Loading/sceneLoader" {
  44044. import { Observable } from "babylonjs/Misc/observable";
  44045. import { Nullable } from "babylonjs/types";
  44046. import { Scene } from "babylonjs/scene";
  44047. import { Engine } from "babylonjs/Engines/engine";
  44048. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44049. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44050. import { AssetContainer } from "babylonjs/assetContainer";
  44051. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44052. import { Skeleton } from "babylonjs/Bones/skeleton";
  44053. /**
  44054. * Class used to represent data loading progression
  44055. */
  44056. export class SceneLoaderProgressEvent {
  44057. /** defines if data length to load can be evaluated */
  44058. readonly lengthComputable: boolean;
  44059. /** defines the loaded data length */
  44060. readonly loaded: number;
  44061. /** defines the data length to load */
  44062. readonly total: number;
  44063. /**
  44064. * Create a new progress event
  44065. * @param lengthComputable defines if data length to load can be evaluated
  44066. * @param loaded defines the loaded data length
  44067. * @param total defines the data length to load
  44068. */
  44069. constructor(
  44070. /** defines if data length to load can be evaluated */
  44071. lengthComputable: boolean,
  44072. /** defines the loaded data length */
  44073. loaded: number,
  44074. /** defines the data length to load */
  44075. total: number);
  44076. /**
  44077. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44078. * @param event defines the source event
  44079. * @returns a new SceneLoaderProgressEvent
  44080. */
  44081. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44082. }
  44083. /**
  44084. * Interface used by SceneLoader plugins to define supported file extensions
  44085. */
  44086. export interface ISceneLoaderPluginExtensions {
  44087. /**
  44088. * Defines the list of supported extensions
  44089. */
  44090. [extension: string]: {
  44091. isBinary: boolean;
  44092. };
  44093. }
  44094. /**
  44095. * Interface used by SceneLoader plugin factory
  44096. */
  44097. export interface ISceneLoaderPluginFactory {
  44098. /**
  44099. * Defines the name of the factory
  44100. */
  44101. name: string;
  44102. /**
  44103. * Function called to create a new plugin
  44104. * @return the new plugin
  44105. */
  44106. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44107. /**
  44108. * Boolean indicating if the plugin can direct load specific data
  44109. */
  44110. canDirectLoad?: (data: string) => boolean;
  44111. }
  44112. /**
  44113. * Interface used to define a SceneLoader plugin
  44114. */
  44115. export interface ISceneLoaderPlugin {
  44116. /**
  44117. * The friendly name of this plugin.
  44118. */
  44119. name: string;
  44120. /**
  44121. * The file extensions supported by this plugin.
  44122. */
  44123. extensions: string | ISceneLoaderPluginExtensions;
  44124. /**
  44125. * Import meshes into a scene.
  44126. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44127. * @param scene The scene to import into
  44128. * @param data The data to import
  44129. * @param rootUrl The root url for scene and resources
  44130. * @param meshes The meshes array to import into
  44131. * @param particleSystems The particle systems array to import into
  44132. * @param skeletons The skeletons array to import into
  44133. * @param onError The callback when import fails
  44134. * @returns True if successful or false otherwise
  44135. */
  44136. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44137. /**
  44138. * Load into a scene.
  44139. * @param scene The scene to load into
  44140. * @param data The data to import
  44141. * @param rootUrl The root url for scene and resources
  44142. * @param onError The callback when import fails
  44143. * @returns true if successful or false otherwise
  44144. */
  44145. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44146. /**
  44147. * The callback that returns true if the data can be directly loaded.
  44148. */
  44149. canDirectLoad?: (data: string) => boolean;
  44150. /**
  44151. * The callback that allows custom handling of the root url based on the response url.
  44152. */
  44153. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  44154. /**
  44155. * Load into an asset container.
  44156. * @param scene The scene to load into
  44157. * @param data The data to import
  44158. * @param rootUrl The root url for scene and resources
  44159. * @param onError The callback when import fails
  44160. * @returns The loaded asset container
  44161. */
  44162. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44163. }
  44164. /**
  44165. * Interface used to define an async SceneLoader plugin
  44166. */
  44167. export interface ISceneLoaderPluginAsync {
  44168. /**
  44169. * The friendly name of this plugin.
  44170. */
  44171. name: string;
  44172. /**
  44173. * The file extensions supported by this plugin.
  44174. */
  44175. extensions: string | ISceneLoaderPluginExtensions;
  44176. /**
  44177. * Import meshes into a scene.
  44178. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44179. * @param scene The scene to import into
  44180. * @param data The data to import
  44181. * @param rootUrl The root url for scene and resources
  44182. * @param onProgress The callback when the load progresses
  44183. * @param fileName Defines the name of the file to load
  44184. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44185. */
  44186. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44187. meshes: AbstractMesh[];
  44188. particleSystems: IParticleSystem[];
  44189. skeletons: Skeleton[];
  44190. animationGroups: AnimationGroup[];
  44191. }>;
  44192. /**
  44193. * Load into a scene.
  44194. * @param scene The scene to load into
  44195. * @param data The data to import
  44196. * @param rootUrl The root url for scene and resources
  44197. * @param onProgress The callback when the load progresses
  44198. * @param fileName Defines the name of the file to load
  44199. * @returns Nothing
  44200. */
  44201. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44202. /**
  44203. * The callback that returns true if the data can be directly loaded.
  44204. */
  44205. canDirectLoad?: (data: string) => boolean;
  44206. /**
  44207. * The callback that allows custom handling of the root url based on the response url.
  44208. */
  44209. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  44210. /**
  44211. * Load into an asset container.
  44212. * @param scene The scene to load into
  44213. * @param data The data to import
  44214. * @param rootUrl The root url for scene and resources
  44215. * @param onProgress The callback when the load progresses
  44216. * @param fileName Defines the name of the file to load
  44217. * @returns The loaded asset container
  44218. */
  44219. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44220. }
  44221. /**
  44222. * Class used to load scene from various file formats using registered plugins
  44223. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44224. */
  44225. export class SceneLoader {
  44226. /**
  44227. * No logging while loading
  44228. */
  44229. static readonly NO_LOGGING: number;
  44230. /**
  44231. * Minimal logging while loading
  44232. */
  44233. static readonly MINIMAL_LOGGING: number;
  44234. /**
  44235. * Summary logging while loading
  44236. */
  44237. static readonly SUMMARY_LOGGING: number;
  44238. /**
  44239. * Detailled logging while loading
  44240. */
  44241. static readonly DETAILED_LOGGING: number;
  44242. /**
  44243. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44244. */
  44245. static ForceFullSceneLoadingForIncremental: boolean;
  44246. /**
  44247. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44248. */
  44249. static ShowLoadingScreen: boolean;
  44250. /**
  44251. * Defines the current logging level (while loading the scene)
  44252. * @ignorenaming
  44253. */
  44254. static loggingLevel: number;
  44255. /**
  44256. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44257. */
  44258. static CleanBoneMatrixWeights: boolean;
  44259. /**
  44260. * Event raised when a plugin is used to load a scene
  44261. */
  44262. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44263. private static _registeredPlugins;
  44264. private static _getDefaultPlugin;
  44265. private static _getPluginForExtension;
  44266. private static _getPluginForDirectLoad;
  44267. private static _getPluginForFilename;
  44268. private static _getDirectLoad;
  44269. private static _loadData;
  44270. private static _getFileInfo;
  44271. /**
  44272. * Gets a plugin that can load the given extension
  44273. * @param extension defines the extension to load
  44274. * @returns a plugin or null if none works
  44275. */
  44276. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44277. /**
  44278. * Gets a boolean indicating that the given extension can be loaded
  44279. * @param extension defines the extension to load
  44280. * @returns true if the extension is supported
  44281. */
  44282. static IsPluginForExtensionAvailable(extension: string): boolean;
  44283. /**
  44284. * Adds a new plugin to the list of registered plugins
  44285. * @param plugin defines the plugin to add
  44286. */
  44287. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44288. /**
  44289. * Import meshes into a scene
  44290. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44291. * @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)
  44292. * @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)
  44293. * @param scene the instance of BABYLON.Scene to append to
  44294. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44295. * @param onProgress a callback with a progress event for each file being loaded
  44296. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44297. * @param pluginExtension the extension used to determine the plugin
  44298. * @returns The loaded plugin
  44299. */
  44300. 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>;
  44301. /**
  44302. * Import meshes into a scene
  44303. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44304. * @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)
  44305. * @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)
  44306. * @param scene the instance of BABYLON.Scene to append to
  44307. * @param onProgress a callback with a progress event for each file being loaded
  44308. * @param pluginExtension the extension used to determine the plugin
  44309. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44310. */
  44311. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44312. meshes: AbstractMesh[];
  44313. particleSystems: IParticleSystem[];
  44314. skeletons: Skeleton[];
  44315. animationGroups: AnimationGroup[];
  44316. }>;
  44317. /**
  44318. * Load a scene
  44319. * @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)
  44320. * @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)
  44321. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44322. * @param onSuccess a callback with the scene when import succeeds
  44323. * @param onProgress a callback with a progress event for each file being loaded
  44324. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44325. * @param pluginExtension the extension used to determine the plugin
  44326. * @returns The loaded plugin
  44327. */
  44328. 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>;
  44329. /**
  44330. * Load a scene
  44331. * @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)
  44332. * @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)
  44333. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44334. * @param onProgress a callback with a progress event for each file being loaded
  44335. * @param pluginExtension the extension used to determine the plugin
  44336. * @returns The loaded scene
  44337. */
  44338. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44339. /**
  44340. * Append a scene
  44341. * @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)
  44342. * @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)
  44343. * @param scene is the instance of BABYLON.Scene to append to
  44344. * @param onSuccess a callback with the scene when import succeeds
  44345. * @param onProgress a callback with a progress event for each file being loaded
  44346. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44347. * @param pluginExtension the extension used to determine the plugin
  44348. * @returns The loaded plugin
  44349. */
  44350. 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>;
  44351. /**
  44352. * Append a scene
  44353. * @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)
  44354. * @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)
  44355. * @param scene is the instance of BABYLON.Scene to append to
  44356. * @param onProgress a callback with a progress event for each file being loaded
  44357. * @param pluginExtension the extension used to determine the plugin
  44358. * @returns The given scene
  44359. */
  44360. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44361. /**
  44362. * Load a scene into an asset container
  44363. * @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)
  44364. * @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)
  44365. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44366. * @param onSuccess a callback with the scene when import succeeds
  44367. * @param onProgress a callback with a progress event for each file being loaded
  44368. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44369. * @param pluginExtension the extension used to determine the plugin
  44370. * @returns The loaded plugin
  44371. */
  44372. 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>;
  44373. /**
  44374. * Load a scene into an asset container
  44375. * @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)
  44376. * @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)
  44377. * @param scene is the instance of Scene to append to
  44378. * @param onProgress a callback with a progress event for each file being loaded
  44379. * @param pluginExtension the extension used to determine the plugin
  44380. * @returns The loaded asset container
  44381. */
  44382. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44383. }
  44384. }
  44385. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  44386. import { Scene } from "babylonjs/scene";
  44387. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44388. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44389. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44390. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44391. /**
  44392. * Google Daydream controller
  44393. */
  44394. export class DaydreamController extends WebVRController {
  44395. /**
  44396. * Base Url for the controller model.
  44397. */
  44398. static MODEL_BASE_URL: string;
  44399. /**
  44400. * File name for the controller model.
  44401. */
  44402. static MODEL_FILENAME: string;
  44403. /**
  44404. * Gamepad Id prefix used to identify Daydream Controller.
  44405. */
  44406. static readonly GAMEPAD_ID_PREFIX: string;
  44407. /**
  44408. * Creates a new DaydreamController from a gamepad
  44409. * @param vrGamepad the gamepad that the controller should be created from
  44410. */
  44411. constructor(vrGamepad: any);
  44412. /**
  44413. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44414. * @param scene scene in which to add meshes
  44415. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44416. */
  44417. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44418. /**
  44419. * Called once for each button that changed state since the last frame
  44420. * @param buttonIdx Which button index changed
  44421. * @param state New state of the button
  44422. * @param changes Which properties on the state changed since last frame
  44423. */
  44424. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44425. }
  44426. }
  44427. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  44428. import { Scene } from "babylonjs/scene";
  44429. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44430. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44431. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44432. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44433. /**
  44434. * Gear VR Controller
  44435. */
  44436. export class GearVRController extends WebVRController {
  44437. /**
  44438. * Base Url for the controller model.
  44439. */
  44440. static MODEL_BASE_URL: string;
  44441. /**
  44442. * File name for the controller model.
  44443. */
  44444. static MODEL_FILENAME: string;
  44445. /**
  44446. * Gamepad Id prefix used to identify this controller.
  44447. */
  44448. static readonly GAMEPAD_ID_PREFIX: string;
  44449. private readonly _buttonIndexToObservableNameMap;
  44450. /**
  44451. * Creates a new GearVRController from a gamepad
  44452. * @param vrGamepad the gamepad that the controller should be created from
  44453. */
  44454. constructor(vrGamepad: any);
  44455. /**
  44456. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44457. * @param scene scene in which to add meshes
  44458. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44459. */
  44460. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44461. /**
  44462. * Called once for each button that changed state since the last frame
  44463. * @param buttonIdx Which button index changed
  44464. * @param state New state of the button
  44465. * @param changes Which properties on the state changed since last frame
  44466. */
  44467. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44468. }
  44469. }
  44470. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44471. import { Scene } from "babylonjs/scene";
  44472. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44473. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44474. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44475. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44476. /**
  44477. * Generic Controller
  44478. */
  44479. export class GenericController extends WebVRController {
  44480. /**
  44481. * Base Url for the controller model.
  44482. */
  44483. static readonly MODEL_BASE_URL: string;
  44484. /**
  44485. * File name for the controller model.
  44486. */
  44487. static readonly MODEL_FILENAME: string;
  44488. /**
  44489. * Creates a new GenericController from a gamepad
  44490. * @param vrGamepad the gamepad that the controller should be created from
  44491. */
  44492. constructor(vrGamepad: any);
  44493. /**
  44494. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44495. * @param scene scene in which to add meshes
  44496. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44497. */
  44498. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44499. /**
  44500. * Called once for each button that changed state since the last frame
  44501. * @param buttonIdx Which button index changed
  44502. * @param state New state of the button
  44503. * @param changes Which properties on the state changed since last frame
  44504. */
  44505. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44506. }
  44507. }
  44508. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44509. import { Observable } from "babylonjs/Misc/observable";
  44510. import { Scene } from "babylonjs/scene";
  44511. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44512. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44513. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44514. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44515. /**
  44516. * Oculus Touch Controller
  44517. */
  44518. export class OculusTouchController extends WebVRController {
  44519. /**
  44520. * Base Url for the controller model.
  44521. */
  44522. static MODEL_BASE_URL: string;
  44523. /**
  44524. * File name for the left controller model.
  44525. */
  44526. static MODEL_LEFT_FILENAME: string;
  44527. /**
  44528. * File name for the right controller model.
  44529. */
  44530. static MODEL_RIGHT_FILENAME: string;
  44531. /**
  44532. * Base Url for the Quest controller model.
  44533. */
  44534. static QUEST_MODEL_BASE_URL: string;
  44535. /**
  44536. * @hidden
  44537. * If the controllers are running on a device that needs the updated Quest controller models
  44538. */
  44539. static _IsQuest: boolean;
  44540. /**
  44541. * Fired when the secondary trigger on this controller is modified
  44542. */
  44543. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44544. /**
  44545. * Fired when the thumb rest on this controller is modified
  44546. */
  44547. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44548. /**
  44549. * Creates a new OculusTouchController from a gamepad
  44550. * @param vrGamepad the gamepad that the controller should be created from
  44551. */
  44552. constructor(vrGamepad: any);
  44553. /**
  44554. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44555. * @param scene scene in which to add meshes
  44556. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44557. */
  44558. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44559. /**
  44560. * Fired when the A button on this controller is modified
  44561. */
  44562. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44563. /**
  44564. * Fired when the B button on this controller is modified
  44565. */
  44566. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44567. /**
  44568. * Fired when the X button on this controller is modified
  44569. */
  44570. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44571. /**
  44572. * Fired when the Y button on this controller is modified
  44573. */
  44574. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44575. /**
  44576. * Called once for each button that changed state since the last frame
  44577. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44578. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44579. * 2) secondary trigger (same)
  44580. * 3) A (right) X (left), touch, pressed = value
  44581. * 4) B / Y
  44582. * 5) thumb rest
  44583. * @param buttonIdx Which button index changed
  44584. * @param state New state of the button
  44585. * @param changes Which properties on the state changed since last frame
  44586. */
  44587. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44588. }
  44589. }
  44590. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44591. import { Scene } from "babylonjs/scene";
  44592. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44593. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44594. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44595. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44596. import { Observable } from "babylonjs/Misc/observable";
  44597. /**
  44598. * Vive Controller
  44599. */
  44600. export class ViveController extends WebVRController {
  44601. /**
  44602. * Base Url for the controller model.
  44603. */
  44604. static MODEL_BASE_URL: string;
  44605. /**
  44606. * File name for the controller model.
  44607. */
  44608. static MODEL_FILENAME: string;
  44609. /**
  44610. * Creates a new ViveController from a gamepad
  44611. * @param vrGamepad the gamepad that the controller should be created from
  44612. */
  44613. constructor(vrGamepad: any);
  44614. /**
  44615. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44616. * @param scene scene in which to add meshes
  44617. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44618. */
  44619. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44620. /**
  44621. * Fired when the left button on this controller is modified
  44622. */
  44623. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44624. /**
  44625. * Fired when the right button on this controller is modified
  44626. */
  44627. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44628. /**
  44629. * Fired when the menu button on this controller is modified
  44630. */
  44631. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44632. /**
  44633. * Called once for each button that changed state since the last frame
  44634. * Vive mapping:
  44635. * 0: touchpad
  44636. * 1: trigger
  44637. * 2: left AND right buttons
  44638. * 3: menu button
  44639. * @param buttonIdx Which button index changed
  44640. * @param state New state of the button
  44641. * @param changes Which properties on the state changed since last frame
  44642. */
  44643. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44644. }
  44645. }
  44646. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44647. import { Observable } from "babylonjs/Misc/observable";
  44648. import { Scene } from "babylonjs/scene";
  44649. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44650. import { Ray } from "babylonjs/Culling/ray";
  44651. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44652. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44653. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44654. /**
  44655. * Defines the WindowsMotionController object that the state of the windows motion controller
  44656. */
  44657. export class WindowsMotionController extends WebVRController {
  44658. /**
  44659. * The base url used to load the left and right controller models
  44660. */
  44661. static MODEL_BASE_URL: string;
  44662. /**
  44663. * The name of the left controller model file
  44664. */
  44665. static MODEL_LEFT_FILENAME: string;
  44666. /**
  44667. * The name of the right controller model file
  44668. */
  44669. static MODEL_RIGHT_FILENAME: string;
  44670. /**
  44671. * The controller name prefix for this controller type
  44672. */
  44673. static readonly GAMEPAD_ID_PREFIX: string;
  44674. /**
  44675. * The controller id pattern for this controller type
  44676. */
  44677. private static readonly GAMEPAD_ID_PATTERN;
  44678. private _loadedMeshInfo;
  44679. private readonly _mapping;
  44680. /**
  44681. * Fired when the trackpad on this controller is clicked
  44682. */
  44683. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44684. /**
  44685. * Fired when the trackpad on this controller is modified
  44686. */
  44687. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44688. /**
  44689. * The current x and y values of this controller's trackpad
  44690. */
  44691. trackpad: StickValues;
  44692. /**
  44693. * Creates a new WindowsMotionController from a gamepad
  44694. * @param vrGamepad the gamepad that the controller should be created from
  44695. */
  44696. constructor(vrGamepad: any);
  44697. /**
  44698. * Fired when the trigger on this controller is modified
  44699. */
  44700. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44701. /**
  44702. * Fired when the menu button on this controller is modified
  44703. */
  44704. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44705. /**
  44706. * Fired when the grip button on this controller is modified
  44707. */
  44708. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44709. /**
  44710. * Fired when the thumbstick button on this controller is modified
  44711. */
  44712. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44713. /**
  44714. * Fired when the touchpad button on this controller is modified
  44715. */
  44716. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44717. /**
  44718. * Fired when the touchpad values on this controller are modified
  44719. */
  44720. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44721. private _updateTrackpad;
  44722. /**
  44723. * Called once per frame by the engine.
  44724. */
  44725. update(): void;
  44726. /**
  44727. * Called once for each button that changed state since the last frame
  44728. * @param buttonIdx Which button index changed
  44729. * @param state New state of the button
  44730. * @param changes Which properties on the state changed since last frame
  44731. */
  44732. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44733. /**
  44734. * Moves the buttons on the controller mesh based on their current state
  44735. * @param buttonName the name of the button to move
  44736. * @param buttonValue the value of the button which determines the buttons new position
  44737. */
  44738. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44739. /**
  44740. * Moves the axis on the controller mesh based on its current state
  44741. * @param axis the index of the axis
  44742. * @param axisValue the value of the axis which determines the meshes new position
  44743. * @hidden
  44744. */
  44745. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44746. /**
  44747. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44748. * @param scene scene in which to add meshes
  44749. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44750. */
  44751. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44752. /**
  44753. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44754. * can be transformed by button presses and axes values, based on this._mapping.
  44755. *
  44756. * @param scene scene in which the meshes exist
  44757. * @param meshes list of meshes that make up the controller model to process
  44758. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44759. */
  44760. private processModel;
  44761. private createMeshInfo;
  44762. /**
  44763. * Gets the ray of the controller in the direction the controller is pointing
  44764. * @param length the length the resulting ray should be
  44765. * @returns a ray in the direction the controller is pointing
  44766. */
  44767. getForwardRay(length?: number): Ray;
  44768. /**
  44769. * Disposes of the controller
  44770. */
  44771. dispose(): void;
  44772. }
  44773. }
  44774. declare module "babylonjs/Gamepads/Controllers/index" {
  44775. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  44776. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  44777. export * from "babylonjs/Gamepads/Controllers/genericController";
  44778. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  44779. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44780. export * from "babylonjs/Gamepads/Controllers/viveController";
  44781. export * from "babylonjs/Gamepads/Controllers/webVRController";
  44782. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  44783. }
  44784. declare module "babylonjs/Gamepads/index" {
  44785. export * from "babylonjs/Gamepads/Controllers/index";
  44786. export * from "babylonjs/Gamepads/gamepad";
  44787. export * from "babylonjs/Gamepads/gamepadManager";
  44788. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  44789. export * from "babylonjs/Gamepads/xboxGamepad";
  44790. }
  44791. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44792. import { Scene } from "babylonjs/scene";
  44793. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44794. import { Mesh } from "babylonjs/Meshes/mesh";
  44795. import { Nullable } from "babylonjs/types";
  44796. /**
  44797. * Class containing static functions to help procedurally build meshes
  44798. */
  44799. export class PolyhedronBuilder {
  44800. /**
  44801. * Creates a polyhedron mesh
  44802. * * 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
  44803. * * The parameter `size` (positive float, default 1) sets the polygon size
  44804. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44805. * * 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`
  44806. * * 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
  44807. * * 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)`)
  44808. * * 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
  44809. * * 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
  44810. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44811. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44813. * @param name defines the name of the mesh
  44814. * @param options defines the options used to create the mesh
  44815. * @param scene defines the hosting scene
  44816. * @returns the polyhedron mesh
  44817. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44818. */
  44819. static CreatePolyhedron(name: string, options: {
  44820. type?: number;
  44821. size?: number;
  44822. sizeX?: number;
  44823. sizeY?: number;
  44824. sizeZ?: number;
  44825. custom?: any;
  44826. faceUV?: Vector4[];
  44827. faceColors?: Color4[];
  44828. flat?: boolean;
  44829. updatable?: boolean;
  44830. sideOrientation?: number;
  44831. frontUVs?: Vector4;
  44832. backUVs?: Vector4;
  44833. }, scene?: Nullable<Scene>): Mesh;
  44834. }
  44835. }
  44836. declare module "babylonjs/Gizmos/scaleGizmo" {
  44837. import { Observable } from "babylonjs/Misc/observable";
  44838. import { Nullable } from "babylonjs/types";
  44839. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44840. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44841. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44842. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44843. /**
  44844. * Gizmo that enables scaling a mesh along 3 axis
  44845. */
  44846. export class ScaleGizmo extends Gizmo {
  44847. /**
  44848. * Internal gizmo used for interactions on the x axis
  44849. */
  44850. xGizmo: AxisScaleGizmo;
  44851. /**
  44852. * Internal gizmo used for interactions on the y axis
  44853. */
  44854. yGizmo: AxisScaleGizmo;
  44855. /**
  44856. * Internal gizmo used for interactions on the z axis
  44857. */
  44858. zGizmo: AxisScaleGizmo;
  44859. /**
  44860. * Internal gizmo used to scale all axis equally
  44861. */
  44862. uniformScaleGizmo: AxisScaleGizmo;
  44863. private _meshAttached;
  44864. private _updateGizmoRotationToMatchAttachedMesh;
  44865. private _snapDistance;
  44866. private _scaleRatio;
  44867. private _uniformScalingMesh;
  44868. private _octahedron;
  44869. /** Fires an event when any of it's sub gizmos are dragged */
  44870. onDragStartObservable: Observable<unknown>;
  44871. /** Fires an event when any of it's sub gizmos are released from dragging */
  44872. onDragEndObservable: Observable<unknown>;
  44873. attachedMesh: Nullable<AbstractMesh>;
  44874. /**
  44875. * Creates a ScaleGizmo
  44876. * @param gizmoLayer The utility layer the gizmo will be added to
  44877. */
  44878. constructor(gizmoLayer?: UtilityLayerRenderer);
  44879. updateGizmoRotationToMatchAttachedMesh: boolean;
  44880. /**
  44881. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44882. */
  44883. snapDistance: number;
  44884. /**
  44885. * Ratio for the scale of the gizmo (Default: 1)
  44886. */
  44887. scaleRatio: number;
  44888. /**
  44889. * Disposes of the gizmo
  44890. */
  44891. dispose(): void;
  44892. }
  44893. }
  44894. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  44895. import { Observable } from "babylonjs/Misc/observable";
  44896. import { Nullable } from "babylonjs/types";
  44897. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44898. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44899. import { Mesh } from "babylonjs/Meshes/mesh";
  44900. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44901. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44902. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44903. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44904. /**
  44905. * Single axis scale gizmo
  44906. */
  44907. export class AxisScaleGizmo extends Gizmo {
  44908. /**
  44909. * Drag behavior responsible for the gizmos dragging interactions
  44910. */
  44911. dragBehavior: PointerDragBehavior;
  44912. private _pointerObserver;
  44913. /**
  44914. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44915. */
  44916. snapDistance: number;
  44917. /**
  44918. * Event that fires each time the gizmo snaps to a new location.
  44919. * * snapDistance is the the change in distance
  44920. */
  44921. onSnapObservable: Observable<{
  44922. snapDistance: number;
  44923. }>;
  44924. /**
  44925. * If the scaling operation should be done on all axis (default: false)
  44926. */
  44927. uniformScaling: boolean;
  44928. private _isEnabled;
  44929. private _parent;
  44930. private _arrow;
  44931. private _coloredMaterial;
  44932. private _hoverMaterial;
  44933. /**
  44934. * Creates an AxisScaleGizmo
  44935. * @param gizmoLayer The utility layer the gizmo will be added to
  44936. * @param dragAxis The axis which the gizmo will be able to scale on
  44937. * @param color The color of the gizmo
  44938. */
  44939. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  44940. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44941. /**
  44942. * If the gizmo is enabled
  44943. */
  44944. isEnabled: boolean;
  44945. /**
  44946. * Disposes of the gizmo
  44947. */
  44948. dispose(): void;
  44949. /**
  44950. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44951. * @param mesh The mesh to replace the default mesh of the gizmo
  44952. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44953. */
  44954. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44955. }
  44956. }
  44957. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  44958. import { Observable } from "babylonjs/Misc/observable";
  44959. import { Nullable } from "babylonjs/types";
  44960. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44961. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44962. import { Mesh } from "babylonjs/Meshes/mesh";
  44963. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44964. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44965. import "babylonjs/Meshes/Builders/boxBuilder";
  44966. /**
  44967. * Bounding box gizmo
  44968. */
  44969. export class BoundingBoxGizmo extends Gizmo {
  44970. private _lineBoundingBox;
  44971. private _rotateSpheresParent;
  44972. private _scaleBoxesParent;
  44973. private _boundingDimensions;
  44974. private _renderObserver;
  44975. private _pointerObserver;
  44976. private _scaleDragSpeed;
  44977. private _tmpQuaternion;
  44978. private _tmpVector;
  44979. private _tmpRotationMatrix;
  44980. /**
  44981. * 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)
  44982. */
  44983. ignoreChildren: boolean;
  44984. /**
  44985. * 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)
  44986. */
  44987. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44988. /**
  44989. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44990. */
  44991. rotationSphereSize: number;
  44992. /**
  44993. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44994. */
  44995. scaleBoxSize: number;
  44996. /**
  44997. * 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)
  44998. */
  44999. fixedDragMeshScreenSize: boolean;
  45000. /**
  45001. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45002. */
  45003. fixedDragMeshScreenSizeDistanceFactor: number;
  45004. /**
  45005. * Fired when a rotation sphere or scale box is dragged
  45006. */
  45007. onDragStartObservable: Observable<{}>;
  45008. /**
  45009. * Fired when a scale box is dragged
  45010. */
  45011. onScaleBoxDragObservable: Observable<{}>;
  45012. /**
  45013. * Fired when a scale box drag is ended
  45014. */
  45015. onScaleBoxDragEndObservable: Observable<{}>;
  45016. /**
  45017. * Fired when a rotation sphere is dragged
  45018. */
  45019. onRotationSphereDragObservable: Observable<{}>;
  45020. /**
  45021. * Fired when a rotation sphere drag is ended
  45022. */
  45023. onRotationSphereDragEndObservable: Observable<{}>;
  45024. /**
  45025. * 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)
  45026. */
  45027. scalePivot: Nullable<Vector3>;
  45028. /**
  45029. * Mesh used as a pivot to rotate the attached mesh
  45030. */
  45031. private _anchorMesh;
  45032. private _existingMeshScale;
  45033. private _dragMesh;
  45034. private pointerDragBehavior;
  45035. private coloredMaterial;
  45036. private hoverColoredMaterial;
  45037. /**
  45038. * Sets the color of the bounding box gizmo
  45039. * @param color the color to set
  45040. */
  45041. setColor(color: Color3): void;
  45042. /**
  45043. * Creates an BoundingBoxGizmo
  45044. * @param gizmoLayer The utility layer the gizmo will be added to
  45045. * @param color The color of the gizmo
  45046. */
  45047. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45048. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45049. private _selectNode;
  45050. /**
  45051. * Updates the bounding box information for the Gizmo
  45052. */
  45053. updateBoundingBox(): void;
  45054. private _updateRotationSpheres;
  45055. private _updateScaleBoxes;
  45056. /**
  45057. * Enables rotation on the specified axis and disables rotation on the others
  45058. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45059. */
  45060. setEnabledRotationAxis(axis: string): void;
  45061. /**
  45062. * Enables/disables scaling
  45063. * @param enable if scaling should be enabled
  45064. */
  45065. setEnabledScaling(enable: boolean): void;
  45066. private _updateDummy;
  45067. /**
  45068. * Enables a pointer drag behavior on the bounding box of the gizmo
  45069. */
  45070. enableDragBehavior(): void;
  45071. /**
  45072. * Disposes of the gizmo
  45073. */
  45074. dispose(): void;
  45075. /**
  45076. * 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)
  45077. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45078. * @returns the bounding box mesh with the passed in mesh as a child
  45079. */
  45080. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45081. /**
  45082. * CustomMeshes are not supported by this gizmo
  45083. * @param mesh The mesh to replace the default mesh of the gizmo
  45084. */
  45085. setCustomMesh(mesh: Mesh): void;
  45086. }
  45087. }
  45088. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  45089. import { Observable } from "babylonjs/Misc/observable";
  45090. import { Nullable } from "babylonjs/types";
  45091. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45092. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45093. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45094. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45095. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45096. import "babylonjs/Meshes/Builders/linesBuilder";
  45097. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45098. /**
  45099. * Single plane rotation gizmo
  45100. */
  45101. export class PlaneRotationGizmo extends Gizmo {
  45102. /**
  45103. * Drag behavior responsible for the gizmos dragging interactions
  45104. */
  45105. dragBehavior: PointerDragBehavior;
  45106. private _pointerObserver;
  45107. /**
  45108. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45109. */
  45110. snapDistance: number;
  45111. /**
  45112. * Event that fires each time the gizmo snaps to a new location.
  45113. * * snapDistance is the the change in distance
  45114. */
  45115. onSnapObservable: Observable<{
  45116. snapDistance: number;
  45117. }>;
  45118. private _isEnabled;
  45119. private _parent;
  45120. /**
  45121. * Creates a PlaneRotationGizmo
  45122. * @param gizmoLayer The utility layer the gizmo will be added to
  45123. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45124. * @param color The color of the gizmo
  45125. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45126. */
  45127. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  45128. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45129. /**
  45130. * If the gizmo is enabled
  45131. */
  45132. isEnabled: boolean;
  45133. /**
  45134. * Disposes of the gizmo
  45135. */
  45136. dispose(): void;
  45137. }
  45138. }
  45139. declare module "babylonjs/Gizmos/rotationGizmo" {
  45140. import { Observable } from "babylonjs/Misc/observable";
  45141. import { Nullable } from "babylonjs/types";
  45142. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45143. import { Mesh } from "babylonjs/Meshes/mesh";
  45144. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45145. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  45146. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45147. /**
  45148. * Gizmo that enables rotating a mesh along 3 axis
  45149. */
  45150. export class RotationGizmo extends Gizmo {
  45151. /**
  45152. * Internal gizmo used for interactions on the x axis
  45153. */
  45154. xGizmo: PlaneRotationGizmo;
  45155. /**
  45156. * Internal gizmo used for interactions on the y axis
  45157. */
  45158. yGizmo: PlaneRotationGizmo;
  45159. /**
  45160. * Internal gizmo used for interactions on the z axis
  45161. */
  45162. zGizmo: PlaneRotationGizmo;
  45163. /** Fires an event when any of it's sub gizmos are dragged */
  45164. onDragStartObservable: Observable<unknown>;
  45165. /** Fires an event when any of it's sub gizmos are released from dragging */
  45166. onDragEndObservable: Observable<unknown>;
  45167. private _meshAttached;
  45168. attachedMesh: Nullable<AbstractMesh>;
  45169. /**
  45170. * Creates a RotationGizmo
  45171. * @param gizmoLayer The utility layer the gizmo will be added to
  45172. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45173. */
  45174. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  45175. updateGizmoRotationToMatchAttachedMesh: boolean;
  45176. /**
  45177. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45178. */
  45179. snapDistance: number;
  45180. /**
  45181. * Ratio for the scale of the gizmo (Default: 1)
  45182. */
  45183. scaleRatio: number;
  45184. /**
  45185. * Disposes of the gizmo
  45186. */
  45187. dispose(): void;
  45188. /**
  45189. * CustomMeshes are not supported by this gizmo
  45190. * @param mesh The mesh to replace the default mesh of the gizmo
  45191. */
  45192. setCustomMesh(mesh: Mesh): void;
  45193. }
  45194. }
  45195. declare module "babylonjs/Gizmos/gizmoManager" {
  45196. import { Observable } from "babylonjs/Misc/observable";
  45197. import { Nullable } from "babylonjs/types";
  45198. import { Scene, IDisposable } from "babylonjs/scene";
  45199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45200. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45201. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45202. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45203. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45204. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45205. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  45206. /**
  45207. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45208. */
  45209. export class GizmoManager implements IDisposable {
  45210. private scene;
  45211. /**
  45212. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45213. */
  45214. gizmos: {
  45215. positionGizmo: Nullable<PositionGizmo>;
  45216. rotationGizmo: Nullable<RotationGizmo>;
  45217. scaleGizmo: Nullable<ScaleGizmo>;
  45218. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45219. };
  45220. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45221. clearGizmoOnEmptyPointerEvent: boolean;
  45222. /** Fires an event when the manager is attached to a mesh */
  45223. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45224. private _gizmosEnabled;
  45225. private _pointerObserver;
  45226. private _attachedMesh;
  45227. private _boundingBoxColor;
  45228. private _defaultUtilityLayer;
  45229. private _defaultKeepDepthUtilityLayer;
  45230. /**
  45231. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45232. */
  45233. boundingBoxDragBehavior: SixDofDragBehavior;
  45234. /**
  45235. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45236. */
  45237. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45238. /**
  45239. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45240. */
  45241. usePointerToAttachGizmos: boolean;
  45242. /**
  45243. * Utility layer that the bounding box gizmo belongs to
  45244. */
  45245. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45246. /**
  45247. * Utility layer that all gizmos besides bounding box belong to
  45248. */
  45249. readonly utilityLayer: UtilityLayerRenderer;
  45250. /**
  45251. * Instatiates a gizmo manager
  45252. * @param scene the scene to overlay the gizmos on top of
  45253. */
  45254. constructor(scene: Scene);
  45255. /**
  45256. * Attaches a set of gizmos to the specified mesh
  45257. * @param mesh The mesh the gizmo's should be attached to
  45258. */
  45259. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45260. /**
  45261. * If the position gizmo is enabled
  45262. */
  45263. positionGizmoEnabled: boolean;
  45264. /**
  45265. * If the rotation gizmo is enabled
  45266. */
  45267. rotationGizmoEnabled: boolean;
  45268. /**
  45269. * If the scale gizmo is enabled
  45270. */
  45271. scaleGizmoEnabled: boolean;
  45272. /**
  45273. * If the boundingBox gizmo is enabled
  45274. */
  45275. boundingBoxGizmoEnabled: boolean;
  45276. /**
  45277. * Disposes of the gizmo manager
  45278. */
  45279. dispose(): void;
  45280. }
  45281. }
  45282. declare module "babylonjs/Lights/directionalLight" {
  45283. import { Camera } from "babylonjs/Cameras/camera";
  45284. import { Scene } from "babylonjs/scene";
  45285. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  45286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45287. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45288. import { Effect } from "babylonjs/Materials/effect";
  45289. /**
  45290. * A directional light is defined by a direction (what a surprise!).
  45291. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45292. * 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.
  45293. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45294. */
  45295. export class DirectionalLight extends ShadowLight {
  45296. private _shadowFrustumSize;
  45297. /**
  45298. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45299. */
  45300. /**
  45301. * Specifies a fix frustum size for the shadow generation.
  45302. */
  45303. shadowFrustumSize: number;
  45304. private _shadowOrthoScale;
  45305. /**
  45306. * Gets the shadow projection scale against the optimal computed one.
  45307. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45308. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45309. */
  45310. /**
  45311. * Sets the shadow projection scale against the optimal computed one.
  45312. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45313. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45314. */
  45315. shadowOrthoScale: number;
  45316. /**
  45317. * Automatically compute the projection matrix to best fit (including all the casters)
  45318. * on each frame.
  45319. */
  45320. autoUpdateExtends: boolean;
  45321. private _orthoLeft;
  45322. private _orthoRight;
  45323. private _orthoTop;
  45324. private _orthoBottom;
  45325. /**
  45326. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45327. * The directional light is emitted from everywhere in the given direction.
  45328. * It can cast shadows.
  45329. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45330. * @param name The friendly name of the light
  45331. * @param direction The direction of the light
  45332. * @param scene The scene the light belongs to
  45333. */
  45334. constructor(name: string, direction: Vector3, scene: Scene);
  45335. /**
  45336. * Returns the string "DirectionalLight".
  45337. * @return The class name
  45338. */
  45339. getClassName(): string;
  45340. /**
  45341. * Returns the integer 1.
  45342. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45343. */
  45344. getTypeID(): number;
  45345. /**
  45346. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45347. * Returns the DirectionalLight Shadow projection matrix.
  45348. */
  45349. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45350. /**
  45351. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45352. * Returns the DirectionalLight Shadow projection matrix.
  45353. */
  45354. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45355. /**
  45356. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45357. * Returns the DirectionalLight Shadow projection matrix.
  45358. */
  45359. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45360. protected _buildUniformLayout(): void;
  45361. /**
  45362. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45363. * @param effect The effect to update
  45364. * @param lightIndex The index of the light in the effect to update
  45365. * @returns The directional light
  45366. */
  45367. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45368. /**
  45369. * Gets the minZ used for shadow according to both the scene and the light.
  45370. *
  45371. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45372. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45373. * @param activeCamera The camera we are returning the min for
  45374. * @returns the depth min z
  45375. */
  45376. getDepthMinZ(activeCamera: Camera): number;
  45377. /**
  45378. * Gets the maxZ used for shadow according to both the scene and the light.
  45379. *
  45380. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45381. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45382. * @param activeCamera The camera we are returning the max for
  45383. * @returns the depth max z
  45384. */
  45385. getDepthMaxZ(activeCamera: Camera): number;
  45386. /**
  45387. * Prepares the list of defines specific to the light type.
  45388. * @param defines the list of defines
  45389. * @param lightIndex defines the index of the light for the effect
  45390. */
  45391. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45392. }
  45393. }
  45394. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  45395. import { Mesh } from "babylonjs/Meshes/mesh";
  45396. /**
  45397. * Class containing static functions to help procedurally build meshes
  45398. */
  45399. export class HemisphereBuilder {
  45400. /**
  45401. * Creates a hemisphere mesh
  45402. * @param name defines the name of the mesh
  45403. * @param options defines the options used to create the mesh
  45404. * @param scene defines the hosting scene
  45405. * @returns the hemisphere mesh
  45406. */
  45407. static CreateHemisphere(name: string, options: {
  45408. segments?: number;
  45409. diameter?: number;
  45410. sideOrientation?: number;
  45411. }, scene: any): Mesh;
  45412. }
  45413. }
  45414. declare module "babylonjs/Lights/spotLight" {
  45415. import { Nullable } from "babylonjs/types";
  45416. import { Scene } from "babylonjs/scene";
  45417. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  45418. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45419. import { Effect } from "babylonjs/Materials/effect";
  45420. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45421. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45422. /**
  45423. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45424. * These values define a cone of light starting from the position, emitting toward the direction.
  45425. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45426. * and the exponent defines the speed of the decay of the light with distance (reach).
  45427. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45428. */
  45429. export class SpotLight extends ShadowLight {
  45430. private _angle;
  45431. private _innerAngle;
  45432. private _cosHalfAngle;
  45433. private _lightAngleScale;
  45434. private _lightAngleOffset;
  45435. /**
  45436. * Gets the cone angle of the spot light in Radians.
  45437. */
  45438. /**
  45439. * Sets the cone angle of the spot light in Radians.
  45440. */
  45441. angle: number;
  45442. /**
  45443. * Only used in gltf falloff mode, this defines the angle where
  45444. * the directional falloff will start before cutting at angle which could be seen
  45445. * as outer angle.
  45446. */
  45447. /**
  45448. * Only used in gltf falloff mode, this defines the angle where
  45449. * the directional falloff will start before cutting at angle which could be seen
  45450. * as outer angle.
  45451. */
  45452. innerAngle: number;
  45453. private _shadowAngleScale;
  45454. /**
  45455. * Allows scaling the angle of the light for shadow generation only.
  45456. */
  45457. /**
  45458. * Allows scaling the angle of the light for shadow generation only.
  45459. */
  45460. shadowAngleScale: number;
  45461. /**
  45462. * The light decay speed with the distance from the emission spot.
  45463. */
  45464. exponent: number;
  45465. private _projectionTextureMatrix;
  45466. /**
  45467. * Allows reading the projecton texture
  45468. */
  45469. readonly projectionTextureMatrix: Matrix;
  45470. protected _projectionTextureLightNear: number;
  45471. /**
  45472. * Gets the near clip of the Spotlight for texture projection.
  45473. */
  45474. /**
  45475. * Sets the near clip of the Spotlight for texture projection.
  45476. */
  45477. projectionTextureLightNear: number;
  45478. protected _projectionTextureLightFar: number;
  45479. /**
  45480. * Gets the far clip of the Spotlight for texture projection.
  45481. */
  45482. /**
  45483. * Sets the far clip of the Spotlight for texture projection.
  45484. */
  45485. projectionTextureLightFar: number;
  45486. protected _projectionTextureUpDirection: Vector3;
  45487. /**
  45488. * Gets the Up vector of the Spotlight for texture projection.
  45489. */
  45490. /**
  45491. * Sets the Up vector of the Spotlight for texture projection.
  45492. */
  45493. projectionTextureUpDirection: Vector3;
  45494. private _projectionTexture;
  45495. /**
  45496. * Gets the projection texture of the light.
  45497. */
  45498. /**
  45499. * Sets the projection texture of the light.
  45500. */
  45501. projectionTexture: Nullable<BaseTexture>;
  45502. private _projectionTextureViewLightDirty;
  45503. private _projectionTextureProjectionLightDirty;
  45504. private _projectionTextureDirty;
  45505. private _projectionTextureViewTargetVector;
  45506. private _projectionTextureViewLightMatrix;
  45507. private _projectionTextureProjectionLightMatrix;
  45508. private _projectionTextureScalingMatrix;
  45509. /**
  45510. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45511. * It can cast shadows.
  45512. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45513. * @param name The light friendly name
  45514. * @param position The position of the spot light in the scene
  45515. * @param direction The direction of the light in the scene
  45516. * @param angle The cone angle of the light in Radians
  45517. * @param exponent The light decay speed with the distance from the emission spot
  45518. * @param scene The scene the lights belongs to
  45519. */
  45520. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45521. /**
  45522. * Returns the string "SpotLight".
  45523. * @returns the class name
  45524. */
  45525. getClassName(): string;
  45526. /**
  45527. * Returns the integer 2.
  45528. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45529. */
  45530. getTypeID(): number;
  45531. /**
  45532. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45533. */
  45534. protected _setDirection(value: Vector3): void;
  45535. /**
  45536. * Overrides the position setter to recompute the projection texture view light Matrix.
  45537. */
  45538. protected _setPosition(value: Vector3): void;
  45539. /**
  45540. * 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.
  45541. * Returns the SpotLight.
  45542. */
  45543. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45544. protected _computeProjectionTextureViewLightMatrix(): void;
  45545. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45546. /**
  45547. * Main function for light texture projection matrix computing.
  45548. */
  45549. protected _computeProjectionTextureMatrix(): void;
  45550. protected _buildUniformLayout(): void;
  45551. private _computeAngleValues;
  45552. /**
  45553. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45554. * @param effect The effect to update
  45555. * @param lightIndex The index of the light in the effect to update
  45556. * @returns The spot light
  45557. */
  45558. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45559. /**
  45560. * Disposes the light and the associated resources.
  45561. */
  45562. dispose(): void;
  45563. /**
  45564. * Prepares the list of defines specific to the light type.
  45565. * @param defines the list of defines
  45566. * @param lightIndex defines the index of the light for the effect
  45567. */
  45568. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45569. }
  45570. }
  45571. declare module "babylonjs/Gizmos/lightGizmo" {
  45572. import { Nullable } from "babylonjs/types";
  45573. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45574. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45575. import { Light } from "babylonjs/Lights/light";
  45576. /**
  45577. * Gizmo that enables viewing a light
  45578. */
  45579. export class LightGizmo extends Gizmo {
  45580. private _lightMesh;
  45581. private _material;
  45582. private cachedPosition;
  45583. private cachedForward;
  45584. /**
  45585. * Creates a LightGizmo
  45586. * @param gizmoLayer The utility layer the gizmo will be added to
  45587. */
  45588. constructor(gizmoLayer?: UtilityLayerRenderer);
  45589. private _light;
  45590. /**
  45591. * The light that the gizmo is attached to
  45592. */
  45593. light: Nullable<Light>;
  45594. /**
  45595. * @hidden
  45596. * Updates the gizmo to match the attached mesh's position/rotation
  45597. */
  45598. protected _update(): void;
  45599. private static _Scale;
  45600. /**
  45601. * Creates the lines for a light mesh
  45602. */
  45603. private static _createLightLines;
  45604. /**
  45605. * Disposes of the light gizmo
  45606. */
  45607. dispose(): void;
  45608. private static _CreateHemisphericLightMesh;
  45609. private static _CreatePointLightMesh;
  45610. private static _CreateSpotLightMesh;
  45611. private static _CreateDirectionalLightMesh;
  45612. }
  45613. }
  45614. declare module "babylonjs/Gizmos/index" {
  45615. export * from "babylonjs/Gizmos/axisDragGizmo";
  45616. export * from "babylonjs/Gizmos/axisScaleGizmo";
  45617. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  45618. export * from "babylonjs/Gizmos/gizmo";
  45619. export * from "babylonjs/Gizmos/gizmoManager";
  45620. export * from "babylonjs/Gizmos/planeRotationGizmo";
  45621. export * from "babylonjs/Gizmos/positionGizmo";
  45622. export * from "babylonjs/Gizmos/rotationGizmo";
  45623. export * from "babylonjs/Gizmos/scaleGizmo";
  45624. export * from "babylonjs/Gizmos/lightGizmo";
  45625. }
  45626. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  45627. /** @hidden */
  45628. export var backgroundFragmentDeclaration: {
  45629. name: string;
  45630. shader: string;
  45631. };
  45632. }
  45633. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  45634. /** @hidden */
  45635. export var backgroundUboDeclaration: {
  45636. name: string;
  45637. shader: string;
  45638. };
  45639. }
  45640. declare module "babylonjs/Shaders/background.fragment" {
  45641. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  45642. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45643. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  45644. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  45645. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45646. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45647. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45648. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  45649. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  45650. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45651. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45652. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45653. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45654. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45655. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45656. /** @hidden */
  45657. export var backgroundPixelShader: {
  45658. name: string;
  45659. shader: string;
  45660. };
  45661. }
  45662. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  45663. /** @hidden */
  45664. export var backgroundVertexDeclaration: {
  45665. name: string;
  45666. shader: string;
  45667. };
  45668. }
  45669. declare module "babylonjs/Shaders/background.vertex" {
  45670. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  45671. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45672. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45673. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45674. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45675. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45676. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45677. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45678. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45679. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45680. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45681. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45682. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45683. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45684. /** @hidden */
  45685. export var backgroundVertexShader: {
  45686. name: string;
  45687. shader: string;
  45688. };
  45689. }
  45690. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  45691. import { Nullable, int, float } from "babylonjs/types";
  45692. import { Scene } from "babylonjs/scene";
  45693. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  45694. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45696. import { Mesh } from "babylonjs/Meshes/mesh";
  45697. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45698. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45699. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45700. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45701. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  45702. import "babylonjs/Shaders/background.fragment";
  45703. import "babylonjs/Shaders/background.vertex";
  45704. /**
  45705. * Background material used to create an efficient environement around your scene.
  45706. */
  45707. export class BackgroundMaterial extends PushMaterial {
  45708. /**
  45709. * Standard reflectance value at parallel view angle.
  45710. */
  45711. static StandardReflectance0: number;
  45712. /**
  45713. * Standard reflectance value at grazing angle.
  45714. */
  45715. static StandardReflectance90: number;
  45716. protected _primaryColor: Color3;
  45717. /**
  45718. * Key light Color (multiply against the environement texture)
  45719. */
  45720. primaryColor: Color3;
  45721. protected __perceptualColor: Nullable<Color3>;
  45722. /**
  45723. * Experimental Internal Use Only.
  45724. *
  45725. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45726. * This acts as a helper to set the primary color to a more "human friendly" value.
  45727. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45728. * output color as close as possible from the chosen value.
  45729. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45730. * part of lighting setup.)
  45731. */
  45732. _perceptualColor: Nullable<Color3>;
  45733. protected _primaryColorShadowLevel: float;
  45734. /**
  45735. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45736. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45737. */
  45738. primaryColorShadowLevel: float;
  45739. protected _primaryColorHighlightLevel: float;
  45740. /**
  45741. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45742. * The primary color is used at the level chosen to define what the white area would look.
  45743. */
  45744. primaryColorHighlightLevel: float;
  45745. protected _reflectionTexture: Nullable<BaseTexture>;
  45746. /**
  45747. * Reflection Texture used in the material.
  45748. * Should be author in a specific way for the best result (refer to the documentation).
  45749. */
  45750. reflectionTexture: Nullable<BaseTexture>;
  45751. protected _reflectionBlur: float;
  45752. /**
  45753. * Reflection Texture level of blur.
  45754. *
  45755. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45756. * texture twice.
  45757. */
  45758. reflectionBlur: float;
  45759. protected _diffuseTexture: Nullable<BaseTexture>;
  45760. /**
  45761. * Diffuse Texture used in the material.
  45762. * Should be author in a specific way for the best result (refer to the documentation).
  45763. */
  45764. diffuseTexture: Nullable<BaseTexture>;
  45765. protected _shadowLights: Nullable<IShadowLight[]>;
  45766. /**
  45767. * Specify the list of lights casting shadow on the material.
  45768. * All scene shadow lights will be included if null.
  45769. */
  45770. shadowLights: Nullable<IShadowLight[]>;
  45771. protected _shadowLevel: float;
  45772. /**
  45773. * Helps adjusting the shadow to a softer level if required.
  45774. * 0 means black shadows and 1 means no shadows.
  45775. */
  45776. shadowLevel: float;
  45777. protected _sceneCenter: Vector3;
  45778. /**
  45779. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45780. * It is usually zero but might be interesting to modify according to your setup.
  45781. */
  45782. sceneCenter: Vector3;
  45783. protected _opacityFresnel: boolean;
  45784. /**
  45785. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45786. * This helps ensuring a nice transition when the camera goes under the ground.
  45787. */
  45788. opacityFresnel: boolean;
  45789. protected _reflectionFresnel: boolean;
  45790. /**
  45791. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45792. * This helps adding a mirror texture on the ground.
  45793. */
  45794. reflectionFresnel: boolean;
  45795. protected _reflectionFalloffDistance: number;
  45796. /**
  45797. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45798. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45799. */
  45800. reflectionFalloffDistance: number;
  45801. protected _reflectionAmount: number;
  45802. /**
  45803. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45804. */
  45805. reflectionAmount: number;
  45806. protected _reflectionReflectance0: number;
  45807. /**
  45808. * This specifies the weight of the reflection at grazing angle.
  45809. */
  45810. reflectionReflectance0: number;
  45811. protected _reflectionReflectance90: number;
  45812. /**
  45813. * This specifies the weight of the reflection at a perpendicular point of view.
  45814. */
  45815. reflectionReflectance90: number;
  45816. /**
  45817. * Sets the reflection reflectance fresnel values according to the default standard
  45818. * empirically know to work well :-)
  45819. */
  45820. reflectionStandardFresnelWeight: number;
  45821. protected _useRGBColor: boolean;
  45822. /**
  45823. * Helps to directly use the maps channels instead of their level.
  45824. */
  45825. useRGBColor: boolean;
  45826. protected _enableNoise: boolean;
  45827. /**
  45828. * This helps reducing the banding effect that could occur on the background.
  45829. */
  45830. enableNoise: boolean;
  45831. /**
  45832. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45833. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45834. * Recommended to be keep at 1.0 except for special cases.
  45835. */
  45836. fovMultiplier: number;
  45837. private _fovMultiplier;
  45838. /**
  45839. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45840. */
  45841. useEquirectangularFOV: boolean;
  45842. private _maxSimultaneousLights;
  45843. /**
  45844. * Number of Simultaneous lights allowed on the material.
  45845. */
  45846. maxSimultaneousLights: int;
  45847. /**
  45848. * Default configuration related to image processing available in the Background Material.
  45849. */
  45850. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45851. /**
  45852. * Keep track of the image processing observer to allow dispose and replace.
  45853. */
  45854. private _imageProcessingObserver;
  45855. /**
  45856. * Attaches a new image processing configuration to the PBR Material.
  45857. * @param configuration (if null the scene configuration will be use)
  45858. */
  45859. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45860. /**
  45861. * Gets the image processing configuration used either in this material.
  45862. */
  45863. /**
  45864. * Sets the Default image processing configuration used either in the this material.
  45865. *
  45866. * If sets to null, the scene one is in use.
  45867. */
  45868. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45869. /**
  45870. * Gets wether the color curves effect is enabled.
  45871. */
  45872. /**
  45873. * Sets wether the color curves effect is enabled.
  45874. */
  45875. cameraColorCurvesEnabled: boolean;
  45876. /**
  45877. * Gets wether the color grading effect is enabled.
  45878. */
  45879. /**
  45880. * Gets wether the color grading effect is enabled.
  45881. */
  45882. cameraColorGradingEnabled: boolean;
  45883. /**
  45884. * Gets wether tonemapping is enabled or not.
  45885. */
  45886. /**
  45887. * Sets wether tonemapping is enabled or not
  45888. */
  45889. cameraToneMappingEnabled: boolean;
  45890. /**
  45891. * The camera exposure used on this material.
  45892. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45893. * This corresponds to a photographic exposure.
  45894. */
  45895. /**
  45896. * The camera exposure used on this material.
  45897. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45898. * This corresponds to a photographic exposure.
  45899. */
  45900. cameraExposure: float;
  45901. /**
  45902. * Gets The camera contrast used on this material.
  45903. */
  45904. /**
  45905. * Sets The camera contrast used on this material.
  45906. */
  45907. cameraContrast: float;
  45908. /**
  45909. * Gets the Color Grading 2D Lookup Texture.
  45910. */
  45911. /**
  45912. * Sets the Color Grading 2D Lookup Texture.
  45913. */
  45914. cameraColorGradingTexture: Nullable<BaseTexture>;
  45915. /**
  45916. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45917. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45918. * 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;
  45919. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45920. */
  45921. /**
  45922. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45923. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45924. * 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;
  45925. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45926. */
  45927. cameraColorCurves: Nullable<ColorCurves>;
  45928. /**
  45929. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45930. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45931. */
  45932. switchToBGR: boolean;
  45933. private _renderTargets;
  45934. private _reflectionControls;
  45935. private _white;
  45936. private _primaryShadowColor;
  45937. private _primaryHighlightColor;
  45938. /**
  45939. * Instantiates a Background Material in the given scene
  45940. * @param name The friendly name of the material
  45941. * @param scene The scene to add the material to
  45942. */
  45943. constructor(name: string, scene: Scene);
  45944. /**
  45945. * Gets a boolean indicating that current material needs to register RTT
  45946. */
  45947. readonly hasRenderTargetTextures: boolean;
  45948. /**
  45949. * The entire material has been created in order to prevent overdraw.
  45950. * @returns false
  45951. */
  45952. needAlphaTesting(): boolean;
  45953. /**
  45954. * The entire material has been created in order to prevent overdraw.
  45955. * @returns true if blending is enable
  45956. */
  45957. needAlphaBlending(): boolean;
  45958. /**
  45959. * Checks wether the material is ready to be rendered for a given mesh.
  45960. * @param mesh The mesh to render
  45961. * @param subMesh The submesh to check against
  45962. * @param useInstances Specify wether or not the material is used with instances
  45963. * @returns true if all the dependencies are ready (Textures, Effects...)
  45964. */
  45965. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45966. /**
  45967. * Compute the primary color according to the chosen perceptual color.
  45968. */
  45969. private _computePrimaryColorFromPerceptualColor;
  45970. /**
  45971. * Compute the highlights and shadow colors according to their chosen levels.
  45972. */
  45973. private _computePrimaryColors;
  45974. /**
  45975. * Build the uniform buffer used in the material.
  45976. */
  45977. buildUniformLayout(): void;
  45978. /**
  45979. * Unbind the material.
  45980. */
  45981. unbind(): void;
  45982. /**
  45983. * Bind only the world matrix to the material.
  45984. * @param world The world matrix to bind.
  45985. */
  45986. bindOnlyWorldMatrix(world: Matrix): void;
  45987. /**
  45988. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45989. * @param world The world matrix to bind.
  45990. * @param subMesh The submesh to bind for.
  45991. */
  45992. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45993. /**
  45994. * Dispose the material.
  45995. * @param forceDisposeEffect Force disposal of the associated effect.
  45996. * @param forceDisposeTextures Force disposal of the associated textures.
  45997. */
  45998. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45999. /**
  46000. * Clones the material.
  46001. * @param name The cloned name.
  46002. * @returns The cloned material.
  46003. */
  46004. clone(name: string): BackgroundMaterial;
  46005. /**
  46006. * Serializes the current material to its JSON representation.
  46007. * @returns The JSON representation.
  46008. */
  46009. serialize(): any;
  46010. /**
  46011. * Gets the class name of the material
  46012. * @returns "BackgroundMaterial"
  46013. */
  46014. getClassName(): string;
  46015. /**
  46016. * Parse a JSON input to create back a background material.
  46017. * @param source The JSON data to parse
  46018. * @param scene The scene to create the parsed material in
  46019. * @param rootUrl The root url of the assets the material depends upon
  46020. * @returns the instantiated BackgroundMaterial.
  46021. */
  46022. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46023. }
  46024. }
  46025. declare module "babylonjs/Helpers/environmentHelper" {
  46026. import { Observable } from "babylonjs/Misc/observable";
  46027. import { Nullable } from "babylonjs/types";
  46028. import { Scene } from "babylonjs/scene";
  46029. import { Vector3, Color3 } from "babylonjs/Maths/math";
  46030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46031. import { Mesh } from "babylonjs/Meshes/mesh";
  46032. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46033. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  46034. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46035. import "babylonjs/Meshes/Builders/planeBuilder";
  46036. import "babylonjs/Meshes/Builders/boxBuilder";
  46037. /**
  46038. * Represents the different options available during the creation of
  46039. * a Environment helper.
  46040. *
  46041. * This can control the default ground, skybox and image processing setup of your scene.
  46042. */
  46043. export interface IEnvironmentHelperOptions {
  46044. /**
  46045. * Specifies wether or not to create a ground.
  46046. * True by default.
  46047. */
  46048. createGround: boolean;
  46049. /**
  46050. * Specifies the ground size.
  46051. * 15 by default.
  46052. */
  46053. groundSize: number;
  46054. /**
  46055. * The texture used on the ground for the main color.
  46056. * Comes from the BabylonJS CDN by default.
  46057. *
  46058. * Remarks: Can be either a texture or a url.
  46059. */
  46060. groundTexture: string | BaseTexture;
  46061. /**
  46062. * The color mixed in the ground texture by default.
  46063. * BabylonJS clearColor by default.
  46064. */
  46065. groundColor: Color3;
  46066. /**
  46067. * Specifies the ground opacity.
  46068. * 1 by default.
  46069. */
  46070. groundOpacity: number;
  46071. /**
  46072. * Enables the ground to receive shadows.
  46073. * True by default.
  46074. */
  46075. enableGroundShadow: boolean;
  46076. /**
  46077. * Helps preventing the shadow to be fully black on the ground.
  46078. * 0.5 by default.
  46079. */
  46080. groundShadowLevel: number;
  46081. /**
  46082. * Creates a mirror texture attach to the ground.
  46083. * false by default.
  46084. */
  46085. enableGroundMirror: boolean;
  46086. /**
  46087. * Specifies the ground mirror size ratio.
  46088. * 0.3 by default as the default kernel is 64.
  46089. */
  46090. groundMirrorSizeRatio: number;
  46091. /**
  46092. * Specifies the ground mirror blur kernel size.
  46093. * 64 by default.
  46094. */
  46095. groundMirrorBlurKernel: number;
  46096. /**
  46097. * Specifies the ground mirror visibility amount.
  46098. * 1 by default
  46099. */
  46100. groundMirrorAmount: number;
  46101. /**
  46102. * Specifies the ground mirror reflectance weight.
  46103. * This uses the standard weight of the background material to setup the fresnel effect
  46104. * of the mirror.
  46105. * 1 by default.
  46106. */
  46107. groundMirrorFresnelWeight: number;
  46108. /**
  46109. * Specifies the ground mirror Falloff distance.
  46110. * This can helps reducing the size of the reflection.
  46111. * 0 by Default.
  46112. */
  46113. groundMirrorFallOffDistance: number;
  46114. /**
  46115. * Specifies the ground mirror texture type.
  46116. * Unsigned Int by Default.
  46117. */
  46118. groundMirrorTextureType: number;
  46119. /**
  46120. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46121. * the shown objects.
  46122. */
  46123. groundYBias: number;
  46124. /**
  46125. * Specifies wether or not to create a skybox.
  46126. * True by default.
  46127. */
  46128. createSkybox: boolean;
  46129. /**
  46130. * Specifies the skybox size.
  46131. * 20 by default.
  46132. */
  46133. skyboxSize: number;
  46134. /**
  46135. * The texture used on the skybox for the main color.
  46136. * Comes from the BabylonJS CDN by default.
  46137. *
  46138. * Remarks: Can be either a texture or a url.
  46139. */
  46140. skyboxTexture: string | BaseTexture;
  46141. /**
  46142. * The color mixed in the skybox texture by default.
  46143. * BabylonJS clearColor by default.
  46144. */
  46145. skyboxColor: Color3;
  46146. /**
  46147. * The background rotation around the Y axis of the scene.
  46148. * This helps aligning the key lights of your scene with the background.
  46149. * 0 by default.
  46150. */
  46151. backgroundYRotation: number;
  46152. /**
  46153. * Compute automatically the size of the elements to best fit with the scene.
  46154. */
  46155. sizeAuto: boolean;
  46156. /**
  46157. * Default position of the rootMesh if autoSize is not true.
  46158. */
  46159. rootPosition: Vector3;
  46160. /**
  46161. * Sets up the image processing in the scene.
  46162. * true by default.
  46163. */
  46164. setupImageProcessing: boolean;
  46165. /**
  46166. * The texture used as your environment texture in the scene.
  46167. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46168. *
  46169. * Remarks: Can be either a texture or a url.
  46170. */
  46171. environmentTexture: string | BaseTexture;
  46172. /**
  46173. * The value of the exposure to apply to the scene.
  46174. * 0.6 by default if setupImageProcessing is true.
  46175. */
  46176. cameraExposure: number;
  46177. /**
  46178. * The value of the contrast to apply to the scene.
  46179. * 1.6 by default if setupImageProcessing is true.
  46180. */
  46181. cameraContrast: number;
  46182. /**
  46183. * Specifies wether or not tonemapping should be enabled in the scene.
  46184. * true by default if setupImageProcessing is true.
  46185. */
  46186. toneMappingEnabled: boolean;
  46187. }
  46188. /**
  46189. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46190. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46191. * It also helps with the default setup of your imageProcessing configuration.
  46192. */
  46193. export class EnvironmentHelper {
  46194. /**
  46195. * Default ground texture URL.
  46196. */
  46197. private static _groundTextureCDNUrl;
  46198. /**
  46199. * Default skybox texture URL.
  46200. */
  46201. private static _skyboxTextureCDNUrl;
  46202. /**
  46203. * Default environment texture URL.
  46204. */
  46205. private static _environmentTextureCDNUrl;
  46206. /**
  46207. * Creates the default options for the helper.
  46208. */
  46209. private static _getDefaultOptions;
  46210. private _rootMesh;
  46211. /**
  46212. * Gets the root mesh created by the helper.
  46213. */
  46214. readonly rootMesh: Mesh;
  46215. private _skybox;
  46216. /**
  46217. * Gets the skybox created by the helper.
  46218. */
  46219. readonly skybox: Nullable<Mesh>;
  46220. private _skyboxTexture;
  46221. /**
  46222. * Gets the skybox texture created by the helper.
  46223. */
  46224. readonly skyboxTexture: Nullable<BaseTexture>;
  46225. private _skyboxMaterial;
  46226. /**
  46227. * Gets the skybox material created by the helper.
  46228. */
  46229. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46230. private _ground;
  46231. /**
  46232. * Gets the ground mesh created by the helper.
  46233. */
  46234. readonly ground: Nullable<Mesh>;
  46235. private _groundTexture;
  46236. /**
  46237. * Gets the ground texture created by the helper.
  46238. */
  46239. readonly groundTexture: Nullable<BaseTexture>;
  46240. private _groundMirror;
  46241. /**
  46242. * Gets the ground mirror created by the helper.
  46243. */
  46244. readonly groundMirror: Nullable<MirrorTexture>;
  46245. /**
  46246. * Gets the ground mirror render list to helps pushing the meshes
  46247. * you wish in the ground reflection.
  46248. */
  46249. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46250. private _groundMaterial;
  46251. /**
  46252. * Gets the ground material created by the helper.
  46253. */
  46254. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46255. /**
  46256. * Stores the creation options.
  46257. */
  46258. private readonly _scene;
  46259. private _options;
  46260. /**
  46261. * This observable will be notified with any error during the creation of the environment,
  46262. * mainly texture creation errors.
  46263. */
  46264. onErrorObservable: Observable<{
  46265. message?: string;
  46266. exception?: any;
  46267. }>;
  46268. /**
  46269. * constructor
  46270. * @param options Defines the options we want to customize the helper
  46271. * @param scene The scene to add the material to
  46272. */
  46273. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46274. /**
  46275. * Updates the background according to the new options
  46276. * @param options
  46277. */
  46278. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46279. /**
  46280. * Sets the primary color of all the available elements.
  46281. * @param color the main color to affect to the ground and the background
  46282. */
  46283. setMainColor(color: Color3): void;
  46284. /**
  46285. * Setup the image processing according to the specified options.
  46286. */
  46287. private _setupImageProcessing;
  46288. /**
  46289. * Setup the environment texture according to the specified options.
  46290. */
  46291. private _setupEnvironmentTexture;
  46292. /**
  46293. * Setup the background according to the specified options.
  46294. */
  46295. private _setupBackground;
  46296. /**
  46297. * Get the scene sizes according to the setup.
  46298. */
  46299. private _getSceneSize;
  46300. /**
  46301. * Setup the ground according to the specified options.
  46302. */
  46303. private _setupGround;
  46304. /**
  46305. * Setup the ground material according to the specified options.
  46306. */
  46307. private _setupGroundMaterial;
  46308. /**
  46309. * Setup the ground diffuse texture according to the specified options.
  46310. */
  46311. private _setupGroundDiffuseTexture;
  46312. /**
  46313. * Setup the ground mirror texture according to the specified options.
  46314. */
  46315. private _setupGroundMirrorTexture;
  46316. /**
  46317. * Setup the ground to receive the mirror texture.
  46318. */
  46319. private _setupMirrorInGroundMaterial;
  46320. /**
  46321. * Setup the skybox according to the specified options.
  46322. */
  46323. private _setupSkybox;
  46324. /**
  46325. * Setup the skybox material according to the specified options.
  46326. */
  46327. private _setupSkyboxMaterial;
  46328. /**
  46329. * Setup the skybox reflection texture according to the specified options.
  46330. */
  46331. private _setupSkyboxReflectionTexture;
  46332. private _errorHandler;
  46333. /**
  46334. * Dispose all the elements created by the Helper.
  46335. */
  46336. dispose(): void;
  46337. }
  46338. }
  46339. declare module "babylonjs/Helpers/photoDome" {
  46340. import { Observable } from "babylonjs/Misc/observable";
  46341. import { Nullable } from "babylonjs/types";
  46342. import { Scene } from "babylonjs/scene";
  46343. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46344. import { Mesh } from "babylonjs/Meshes/mesh";
  46345. import { Texture } from "babylonjs/Materials/Textures/texture";
  46346. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46347. import "babylonjs/Meshes/Builders/sphereBuilder";
  46348. /**
  46349. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46350. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46351. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46352. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46353. */
  46354. export class PhotoDome extends TransformNode {
  46355. /**
  46356. * Define the image as a Monoscopic panoramic 360 image.
  46357. */
  46358. static readonly MODE_MONOSCOPIC: number;
  46359. /**
  46360. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46361. */
  46362. static readonly MODE_TOPBOTTOM: number;
  46363. /**
  46364. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46365. */
  46366. static readonly MODE_SIDEBYSIDE: number;
  46367. private _useDirectMapping;
  46368. /**
  46369. * The texture being displayed on the sphere
  46370. */
  46371. protected _photoTexture: Texture;
  46372. /**
  46373. * Gets or sets the texture being displayed on the sphere
  46374. */
  46375. photoTexture: Texture;
  46376. /**
  46377. * Observable raised when an error occured while loading the 360 image
  46378. */
  46379. onLoadErrorObservable: Observable<string>;
  46380. /**
  46381. * The skybox material
  46382. */
  46383. protected _material: BackgroundMaterial;
  46384. /**
  46385. * The surface used for the skybox
  46386. */
  46387. protected _mesh: Mesh;
  46388. /**
  46389. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46390. * Also see the options.resolution property.
  46391. */
  46392. fovMultiplier: number;
  46393. private _imageMode;
  46394. /**
  46395. * Gets or set the current video mode for the video. It can be:
  46396. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46397. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46398. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46399. */
  46400. imageMode: number;
  46401. /**
  46402. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46403. * @param name Element's name, child elements will append suffixes for their own names.
  46404. * @param urlsOfPhoto defines the url of the photo to display
  46405. * @param options defines an object containing optional or exposed sub element properties
  46406. * @param onError defines a callback called when an error occured while loading the texture
  46407. */
  46408. constructor(name: string, urlOfPhoto: string, options: {
  46409. resolution?: number;
  46410. size?: number;
  46411. useDirectMapping?: boolean;
  46412. faceForward?: boolean;
  46413. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46414. private _onBeforeCameraRenderObserver;
  46415. private _changeImageMode;
  46416. /**
  46417. * Releases resources associated with this node.
  46418. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46419. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46420. */
  46421. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46422. }
  46423. }
  46424. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46425. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46426. /** @hidden */
  46427. export var rgbdDecodePixelShader: {
  46428. name: string;
  46429. shader: string;
  46430. };
  46431. }
  46432. declare module "babylonjs/Misc/brdfTextureTools" {
  46433. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46434. import { Scene } from "babylonjs/scene";
  46435. import "babylonjs/Shaders/rgbdDecode.fragment";
  46436. /**
  46437. * Class used to host texture specific utilities
  46438. */
  46439. export class BRDFTextureTools {
  46440. /**
  46441. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  46442. * @param texture the texture to expand.
  46443. */
  46444. private static _ExpandDefaultBRDFTexture;
  46445. /**
  46446. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46447. * @param scene defines the hosting scene
  46448. * @returns the environment BRDF texture
  46449. */
  46450. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46451. private static _environmentBRDFBase64Texture;
  46452. }
  46453. }
  46454. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  46455. import { Nullable } from "babylonjs/types";
  46456. import { IAnimatable } from "babylonjs/Misc/tools";
  46457. import { Color3 } from "babylonjs/Maths/math";
  46458. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46459. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46460. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46461. import { Engine } from "babylonjs/Engines/engine";
  46462. import { Scene } from "babylonjs/scene";
  46463. /**
  46464. * @hidden
  46465. */
  46466. export interface IMaterialClearCoatDefines {
  46467. CLEARCOAT: boolean;
  46468. CLEARCOAT_DEFAULTIOR: boolean;
  46469. CLEARCOAT_TEXTURE: boolean;
  46470. CLEARCOAT_TEXTUREDIRECTUV: number;
  46471. CLEARCOAT_BUMP: boolean;
  46472. CLEARCOAT_BUMPDIRECTUV: number;
  46473. CLEARCOAT_TINT: boolean;
  46474. CLEARCOAT_TINT_TEXTURE: boolean;
  46475. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46476. /** @hidden */
  46477. _areTexturesDirty: boolean;
  46478. }
  46479. /**
  46480. * Define the code related to the clear coat parameters of the pbr material.
  46481. */
  46482. export class PBRClearCoatConfiguration {
  46483. /**
  46484. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46485. * The default fits with a polyurethane material.
  46486. */
  46487. private static readonly _DefaultIndexOfRefraction;
  46488. private _isEnabled;
  46489. /**
  46490. * Defines if the clear coat is enabled in the material.
  46491. */
  46492. isEnabled: boolean;
  46493. /**
  46494. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46495. */
  46496. intensity: number;
  46497. /**
  46498. * Defines the clear coat layer roughness.
  46499. */
  46500. roughness: number;
  46501. private _indexOfRefraction;
  46502. /**
  46503. * Defines the index of refraction of the clear coat.
  46504. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46505. * The default fits with a polyurethane material.
  46506. * Changing the default value is more performance intensive.
  46507. */
  46508. indexOfRefraction: number;
  46509. private _texture;
  46510. /**
  46511. * Stores the clear coat values in a texture.
  46512. */
  46513. texture: Nullable<BaseTexture>;
  46514. private _bumpTexture;
  46515. /**
  46516. * Define the clear coat specific bump texture.
  46517. */
  46518. bumpTexture: Nullable<BaseTexture>;
  46519. private _isTintEnabled;
  46520. /**
  46521. * Defines if the clear coat tint is enabled in the material.
  46522. */
  46523. isTintEnabled: boolean;
  46524. /**
  46525. * Defines the clear coat tint of the material.
  46526. * This is only use if tint is enabled
  46527. */
  46528. tintColor: Color3;
  46529. /**
  46530. * Defines the distance at which the tint color should be found in the
  46531. * clear coat media.
  46532. * This is only use if tint is enabled
  46533. */
  46534. tintColorAtDistance: number;
  46535. /**
  46536. * Defines the clear coat layer thickness.
  46537. * This is only use if tint is enabled
  46538. */
  46539. tintThickness: number;
  46540. private _tintTexture;
  46541. /**
  46542. * Stores the clear tint values in a texture.
  46543. * rgb is tint
  46544. * a is a thickness factor
  46545. */
  46546. tintTexture: Nullable<BaseTexture>;
  46547. /** @hidden */
  46548. private _internalMarkAllSubMeshesAsTexturesDirty;
  46549. /** @hidden */
  46550. _markAllSubMeshesAsTexturesDirty(): void;
  46551. /**
  46552. * Instantiate a new istance of clear coat configuration.
  46553. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46554. */
  46555. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46556. /**
  46557. * Gets wehter the submesh is ready to be used or not.
  46558. * @param defines the list of "defines" to update.
  46559. * @param scene defines the scene the material belongs to.
  46560. * @param engine defines the engine the material belongs to.
  46561. * @param disableBumpMap defines wether the material disables bump or not.
  46562. * @returns - boolean indicating that the submesh is ready or not.
  46563. */
  46564. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46565. /**
  46566. * Checks to see if a texture is used in the material.
  46567. * @param defines the list of "defines" to update.
  46568. * @param scene defines the scene to the material belongs to.
  46569. */
  46570. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46571. /**
  46572. * Binds the material data.
  46573. * @param uniformBuffer defines the Uniform buffer to fill in.
  46574. * @param scene defines the scene the material belongs to.
  46575. * @param engine defines the engine the material belongs to.
  46576. * @param disableBumpMap defines wether the material disables bump or not.
  46577. * @param isFrozen defines wether the material is frozen or not.
  46578. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46579. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46580. */
  46581. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46582. /**
  46583. * Checks to see if a texture is used in the material.
  46584. * @param texture - Base texture to use.
  46585. * @returns - Boolean specifying if a texture is used in the material.
  46586. */
  46587. hasTexture(texture: BaseTexture): boolean;
  46588. /**
  46589. * Returns an array of the actively used textures.
  46590. * @param activeTextures Array of BaseTextures
  46591. */
  46592. getActiveTextures(activeTextures: BaseTexture[]): void;
  46593. /**
  46594. * Returns the animatable textures.
  46595. * @param animatables Array of animatable textures.
  46596. */
  46597. getAnimatables(animatables: IAnimatable[]): void;
  46598. /**
  46599. * Disposes the resources of the material.
  46600. * @param forceDisposeTextures - Forces the disposal of all textures.
  46601. */
  46602. dispose(forceDisposeTextures?: boolean): void;
  46603. /**
  46604. * Get the current class name of the texture useful for serialization or dynamic coding.
  46605. * @returns "PBRClearCoatConfiguration"
  46606. */
  46607. getClassName(): string;
  46608. /**
  46609. * Add fallbacks to the effect fallbacks list.
  46610. * @param defines defines the Base texture to use.
  46611. * @param fallbacks defines the current fallback list.
  46612. * @param currentRank defines the current fallback rank.
  46613. * @returns the new fallback rank.
  46614. */
  46615. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46616. /**
  46617. * Add the required uniforms to the current list.
  46618. * @param uniforms defines the current uniform list.
  46619. */
  46620. static AddUniforms(uniforms: string[]): void;
  46621. /**
  46622. * Add the required samplers to the current list.
  46623. * @param samplers defines the current sampler list.
  46624. */
  46625. static AddSamplers(samplers: string[]): void;
  46626. /**
  46627. * Add the required uniforms to the current buffer.
  46628. * @param uniformBuffer defines the current uniform buffer.
  46629. */
  46630. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46631. /**
  46632. * Makes a duplicate of the current configuration into another one.
  46633. * @param clearCoatConfiguration define the config where to copy the info
  46634. */
  46635. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46636. /**
  46637. * Serializes this clear coat configuration.
  46638. * @returns - An object with the serialized config.
  46639. */
  46640. serialize(): any;
  46641. /**
  46642. * Parses a anisotropy Configuration from a serialized object.
  46643. * @param source - Serialized object.
  46644. * @param scene Defines the scene we are parsing for
  46645. * @param rootUrl Defines the rootUrl to load from
  46646. */
  46647. parse(source: any, scene: Scene, rootUrl: string): void;
  46648. }
  46649. }
  46650. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  46651. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46652. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46653. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46654. import { Vector2 } from "babylonjs/Maths/math";
  46655. import { Scene } from "babylonjs/scene";
  46656. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46657. import { IAnimatable } from "babylonjs/Misc/tools";
  46658. import { Nullable } from "babylonjs/types";
  46659. /**
  46660. * @hidden
  46661. */
  46662. export interface IMaterialAnisotropicDefines {
  46663. ANISOTROPIC: boolean;
  46664. ANISOTROPIC_TEXTURE: boolean;
  46665. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46666. MAINUV1: boolean;
  46667. _areTexturesDirty: boolean;
  46668. _needUVs: boolean;
  46669. }
  46670. /**
  46671. * Define the code related to the anisotropic parameters of the pbr material.
  46672. */
  46673. export class PBRAnisotropicConfiguration {
  46674. private _isEnabled;
  46675. /**
  46676. * Defines if the anisotropy is enabled in the material.
  46677. */
  46678. isEnabled: boolean;
  46679. /**
  46680. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46681. */
  46682. intensity: number;
  46683. /**
  46684. * Defines if the effect is along the tangents, bitangents or in between.
  46685. * By default, the effect is "strectching" the highlights along the tangents.
  46686. */
  46687. direction: Vector2;
  46688. private _texture;
  46689. /**
  46690. * Stores the anisotropy values in a texture.
  46691. * rg is direction (like normal from -1 to 1)
  46692. * b is a intensity
  46693. */
  46694. texture: Nullable<BaseTexture>;
  46695. /** @hidden */
  46696. private _internalMarkAllSubMeshesAsTexturesDirty;
  46697. /** @hidden */
  46698. _markAllSubMeshesAsTexturesDirty(): void;
  46699. /**
  46700. * Instantiate a new istance of anisotropy configuration.
  46701. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46702. */
  46703. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46704. /**
  46705. * Specifies that the submesh is ready to be used.
  46706. * @param defines the list of "defines" to update.
  46707. * @param scene defines the scene the material belongs to.
  46708. * @returns - boolean indicating that the submesh is ready or not.
  46709. */
  46710. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46711. /**
  46712. * Checks to see if a texture is used in the material.
  46713. * @param defines the list of "defines" to update.
  46714. * @param mesh the mesh we are preparing the defines for.
  46715. * @param scene defines the scene the material belongs to.
  46716. */
  46717. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46718. /**
  46719. * Binds the material data.
  46720. * @param uniformBuffer defines the Uniform buffer to fill in.
  46721. * @param scene defines the scene the material belongs to.
  46722. * @param isFrozen defines wether the material is frozen or not.
  46723. */
  46724. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46725. /**
  46726. * Checks to see if a texture is used in the material.
  46727. * @param texture - Base texture to use.
  46728. * @returns - Boolean specifying if a texture is used in the material.
  46729. */
  46730. hasTexture(texture: BaseTexture): boolean;
  46731. /**
  46732. * Returns an array of the actively used textures.
  46733. * @param activeTextures Array of BaseTextures
  46734. */
  46735. getActiveTextures(activeTextures: BaseTexture[]): void;
  46736. /**
  46737. * Returns the animatable textures.
  46738. * @param animatables Array of animatable textures.
  46739. */
  46740. getAnimatables(animatables: IAnimatable[]): void;
  46741. /**
  46742. * Disposes the resources of the material.
  46743. * @param forceDisposeTextures - Forces the disposal of all textures.
  46744. */
  46745. dispose(forceDisposeTextures?: boolean): void;
  46746. /**
  46747. * Get the current class name of the texture useful for serialization or dynamic coding.
  46748. * @returns "PBRAnisotropicConfiguration"
  46749. */
  46750. getClassName(): string;
  46751. /**
  46752. * Add fallbacks to the effect fallbacks list.
  46753. * @param defines defines the Base texture to use.
  46754. * @param fallbacks defines the current fallback list.
  46755. * @param currentRank defines the current fallback rank.
  46756. * @returns the new fallback rank.
  46757. */
  46758. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46759. /**
  46760. * Add the required uniforms to the current list.
  46761. * @param uniforms defines the current uniform list.
  46762. */
  46763. static AddUniforms(uniforms: string[]): void;
  46764. /**
  46765. * Add the required uniforms to the current buffer.
  46766. * @param uniformBuffer defines the current uniform buffer.
  46767. */
  46768. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46769. /**
  46770. * Add the required samplers to the current list.
  46771. * @param samplers defines the current sampler list.
  46772. */
  46773. static AddSamplers(samplers: string[]): void;
  46774. /**
  46775. * Makes a duplicate of the current configuration into another one.
  46776. * @param anisotropicConfiguration define the config where to copy the info
  46777. */
  46778. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46779. /**
  46780. * Serializes this anisotropy configuration.
  46781. * @returns - An object with the serialized config.
  46782. */
  46783. serialize(): any;
  46784. /**
  46785. * Parses a anisotropy Configuration from a serialized object.
  46786. * @param source - Serialized object.
  46787. * @param scene Defines the scene we are parsing for
  46788. * @param rootUrl Defines the rootUrl to load from
  46789. */
  46790. parse(source: any, scene: Scene, rootUrl: string): void;
  46791. }
  46792. }
  46793. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  46794. import { Scene } from "babylonjs/scene";
  46795. /**
  46796. * @hidden
  46797. */
  46798. export interface IMaterialBRDFDefines {
  46799. BRDF_V_HEIGHT_CORRELATED: boolean;
  46800. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46801. SPHERICAL_HARMONICS: boolean;
  46802. /** @hidden */
  46803. _areMiscDirty: boolean;
  46804. }
  46805. /**
  46806. * Define the code related to the BRDF parameters of the pbr material.
  46807. */
  46808. export class PBRBRDFConfiguration {
  46809. /**
  46810. * Default value used for the energy conservation.
  46811. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46812. */
  46813. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46814. /**
  46815. * Default value used for the Smith Visibility Height Correlated mode.
  46816. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46817. */
  46818. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46819. /**
  46820. * Default value used for the IBL diffuse part.
  46821. * This can help switching back to the polynomials mode globally which is a tiny bit
  46822. * less GPU intensive at the drawback of a lower quality.
  46823. */
  46824. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46825. private _useEnergyConservation;
  46826. /**
  46827. * Defines if the material uses energy conservation.
  46828. */
  46829. useEnergyConservation: boolean;
  46830. private _useSmithVisibilityHeightCorrelated;
  46831. /**
  46832. * LEGACY Mode set to false
  46833. * Defines if the material uses height smith correlated visibility term.
  46834. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46835. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46836. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46837. * Not relying on height correlated will also disable energy conservation.
  46838. */
  46839. useSmithVisibilityHeightCorrelated: boolean;
  46840. private _useSphericalHarmonics;
  46841. /**
  46842. * LEGACY Mode set to false
  46843. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46844. * diffuse part of the IBL.
  46845. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46846. * to the ground truth.
  46847. */
  46848. useSphericalHarmonics: boolean;
  46849. /** @hidden */
  46850. private _internalMarkAllSubMeshesAsMiscDirty;
  46851. /** @hidden */
  46852. _markAllSubMeshesAsMiscDirty(): void;
  46853. /**
  46854. * Instantiate a new istance of clear coat configuration.
  46855. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46856. */
  46857. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46858. /**
  46859. * Checks to see if a texture is used in the material.
  46860. * @param defines the list of "defines" to update.
  46861. */
  46862. prepareDefines(defines: IMaterialBRDFDefines): void;
  46863. /**
  46864. * Get the current class name of the texture useful for serialization or dynamic coding.
  46865. * @returns "PBRClearCoatConfiguration"
  46866. */
  46867. getClassName(): string;
  46868. /**
  46869. * Makes a duplicate of the current configuration into another one.
  46870. * @param brdfConfiguration define the config where to copy the info
  46871. */
  46872. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46873. /**
  46874. * Serializes this BRDF configuration.
  46875. * @returns - An object with the serialized config.
  46876. */
  46877. serialize(): any;
  46878. /**
  46879. * Parses a anisotropy Configuration from a serialized object.
  46880. * @param source - Serialized object.
  46881. * @param scene Defines the scene we are parsing for
  46882. * @param rootUrl Defines the rootUrl to load from
  46883. */
  46884. parse(source: any, scene: Scene, rootUrl: string): void;
  46885. }
  46886. }
  46887. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  46888. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46889. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46890. import { Color3 } from "babylonjs/Maths/math";
  46891. import { Scene } from "babylonjs/scene";
  46892. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46893. import { IAnimatable } from "babylonjs/Misc/tools";
  46894. import { Nullable } from "babylonjs/types";
  46895. /**
  46896. * @hidden
  46897. */
  46898. export interface IMaterialSheenDefines {
  46899. SHEEN: boolean;
  46900. SHEEN_TEXTURE: boolean;
  46901. SHEEN_TEXTUREDIRECTUV: number;
  46902. SHEEN_LINKWITHALBEDO: boolean;
  46903. /** @hidden */
  46904. _areTexturesDirty: boolean;
  46905. }
  46906. /**
  46907. * Define the code related to the Sheen parameters of the pbr material.
  46908. */
  46909. export class PBRSheenConfiguration {
  46910. private _isEnabled;
  46911. /**
  46912. * Defines if the material uses sheen.
  46913. */
  46914. isEnabled: boolean;
  46915. private _linkSheenWithAlbedo;
  46916. /**
  46917. * Defines if the sheen is linked to the sheen color.
  46918. */
  46919. linkSheenWithAlbedo: boolean;
  46920. /**
  46921. * Defines the sheen intensity.
  46922. */
  46923. intensity: number;
  46924. /**
  46925. * Defines the sheen color.
  46926. */
  46927. color: Color3;
  46928. private _texture;
  46929. /**
  46930. * Stores the sheen tint values in a texture.
  46931. * rgb is tint
  46932. * a is a intensity
  46933. */
  46934. texture: Nullable<BaseTexture>;
  46935. /** @hidden */
  46936. private _internalMarkAllSubMeshesAsTexturesDirty;
  46937. /** @hidden */
  46938. _markAllSubMeshesAsTexturesDirty(): void;
  46939. /**
  46940. * Instantiate a new istance of clear coat configuration.
  46941. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46942. */
  46943. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46944. /**
  46945. * Specifies that the submesh is ready to be used.
  46946. * @param defines the list of "defines" to update.
  46947. * @param scene defines the scene the material belongs to.
  46948. * @returns - boolean indicating that the submesh is ready or not.
  46949. */
  46950. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46951. /**
  46952. * Checks to see if a texture is used in the material.
  46953. * @param defines the list of "defines" to update.
  46954. * @param scene defines the scene the material belongs to.
  46955. */
  46956. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46957. /**
  46958. * Binds the material data.
  46959. * @param uniformBuffer defines the Uniform buffer to fill in.
  46960. * @param scene defines the scene the material belongs to.
  46961. * @param isFrozen defines wether the material is frozen or not.
  46962. */
  46963. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46964. /**
  46965. * Checks to see if a texture is used in the material.
  46966. * @param texture - Base texture to use.
  46967. * @returns - Boolean specifying if a texture is used in the material.
  46968. */
  46969. hasTexture(texture: BaseTexture): boolean;
  46970. /**
  46971. * Returns an array of the actively used textures.
  46972. * @param activeTextures Array of BaseTextures
  46973. */
  46974. getActiveTextures(activeTextures: BaseTexture[]): void;
  46975. /**
  46976. * Returns the animatable textures.
  46977. * @param animatables Array of animatable textures.
  46978. */
  46979. getAnimatables(animatables: IAnimatable[]): void;
  46980. /**
  46981. * Disposes the resources of the material.
  46982. * @param forceDisposeTextures - Forces the disposal of all textures.
  46983. */
  46984. dispose(forceDisposeTextures?: boolean): void;
  46985. /**
  46986. * Get the current class name of the texture useful for serialization or dynamic coding.
  46987. * @returns "PBRSheenConfiguration"
  46988. */
  46989. getClassName(): string;
  46990. /**
  46991. * Add fallbacks to the effect fallbacks list.
  46992. * @param defines defines the Base texture to use.
  46993. * @param fallbacks defines the current fallback list.
  46994. * @param currentRank defines the current fallback rank.
  46995. * @returns the new fallback rank.
  46996. */
  46997. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46998. /**
  46999. * Add the required uniforms to the current list.
  47000. * @param uniforms defines the current uniform list.
  47001. */
  47002. static AddUniforms(uniforms: string[]): void;
  47003. /**
  47004. * Add the required uniforms to the current buffer.
  47005. * @param uniformBuffer defines the current uniform buffer.
  47006. */
  47007. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47008. /**
  47009. * Add the required samplers to the current list.
  47010. * @param samplers defines the current sampler list.
  47011. */
  47012. static AddSamplers(samplers: string[]): void;
  47013. /**
  47014. * Makes a duplicate of the current configuration into another one.
  47015. * @param sheenConfiguration define the config where to copy the info
  47016. */
  47017. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  47018. /**
  47019. * Serializes this BRDF configuration.
  47020. * @returns - An object with the serialized config.
  47021. */
  47022. serialize(): any;
  47023. /**
  47024. * Parses a anisotropy Configuration from a serialized object.
  47025. * @param source - Serialized object.
  47026. * @param scene Defines the scene we are parsing for
  47027. * @param rootUrl Defines the rootUrl to load from
  47028. */
  47029. parse(source: any, scene: Scene, rootUrl: string): void;
  47030. }
  47031. }
  47032. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  47033. import { Nullable } from "babylonjs/types";
  47034. import { IAnimatable } from "babylonjs/Misc/tools";
  47035. import { Color3 } from "babylonjs/Maths/math";
  47036. import { SmartArray } from "babylonjs/Misc/smartArray";
  47037. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47038. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47039. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  47040. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47041. import { Engine } from "babylonjs/Engines/engine";
  47042. import { Scene } from "babylonjs/scene";
  47043. /**
  47044. * @hidden
  47045. */
  47046. export interface IMaterialSubSurfaceDefines {
  47047. SUBSURFACE: boolean;
  47048. SS_REFRACTION: boolean;
  47049. SS_TRANSLUCENCY: boolean;
  47050. SS_SCATERRING: boolean;
  47051. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47052. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47053. SS_REFRACTIONMAP_3D: boolean;
  47054. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47055. SS_LODINREFRACTIONALPHA: boolean;
  47056. SS_GAMMAREFRACTION: boolean;
  47057. SS_RGBDREFRACTION: boolean;
  47058. SS_LINEARSPECULARREFRACTION: boolean;
  47059. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47060. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47061. /** @hidden */
  47062. _areTexturesDirty: boolean;
  47063. }
  47064. /**
  47065. * Define the code related to the sub surface parameters of the pbr material.
  47066. */
  47067. export class PBRSubSurfaceConfiguration {
  47068. private _isRefractionEnabled;
  47069. /**
  47070. * Defines if the refraction is enabled in the material.
  47071. */
  47072. isRefractionEnabled: boolean;
  47073. private _isTranslucencyEnabled;
  47074. /**
  47075. * Defines if the translucency is enabled in the material.
  47076. */
  47077. isTranslucencyEnabled: boolean;
  47078. private _isScatteringEnabled;
  47079. /**
  47080. * Defines the refraction intensity of the material.
  47081. * The refraction when enabled replaces the Diffuse part of the material.
  47082. * The intensity helps transitionning between diffuse and refraction.
  47083. */
  47084. refractionIntensity: number;
  47085. /**
  47086. * Defines the translucency intensity of the material.
  47087. * When translucency has been enabled, this defines how much of the "translucency"
  47088. * is addded to the diffuse part of the material.
  47089. */
  47090. translucencyIntensity: number;
  47091. /**
  47092. * Defines the scattering intensity of the material.
  47093. * When scattering has been enabled, this defines how much of the "scattered light"
  47094. * is addded to the diffuse part of the material.
  47095. */
  47096. scatteringIntensity: number;
  47097. private _thicknessTexture;
  47098. /**
  47099. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47100. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47101. * 0 would mean minimumThickness
  47102. * 1 would mean maximumThickness
  47103. * The other channels might be use as a mask to vary the different effects intensity.
  47104. */
  47105. thicknessTexture: Nullable<BaseTexture>;
  47106. private _refractionTexture;
  47107. /**
  47108. * Defines the texture to use for refraction.
  47109. */
  47110. refractionTexture: Nullable<BaseTexture>;
  47111. private _indexOfRefraction;
  47112. /**
  47113. * Defines the index of refraction used in the material.
  47114. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47115. */
  47116. indexOfRefraction: number;
  47117. private _invertRefractionY;
  47118. /**
  47119. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47120. */
  47121. invertRefractionY: boolean;
  47122. private _linkRefractionWithTransparency;
  47123. /**
  47124. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47125. * Materials half opaque for instance using refraction could benefit from this control.
  47126. */
  47127. linkRefractionWithTransparency: boolean;
  47128. /**
  47129. * Defines the minimum thickness stored in the thickness map.
  47130. * If no thickness map is defined, this value will be used to simulate thickness.
  47131. */
  47132. minimumThickness: number;
  47133. /**
  47134. * Defines the maximum thickness stored in the thickness map.
  47135. */
  47136. maximumThickness: number;
  47137. /**
  47138. * Defines the volume tint of the material.
  47139. * This is used for both translucency and scattering.
  47140. */
  47141. tintColor: Color3;
  47142. /**
  47143. * Defines the distance at which the tint color should be found in the media.
  47144. * This is used for refraction only.
  47145. */
  47146. tintColorAtDistance: number;
  47147. /**
  47148. * Defines how far each channel transmit through the media.
  47149. * It is defined as a color to simplify it selection.
  47150. */
  47151. diffusionDistance: Color3;
  47152. private _useMaskFromThicknessTexture;
  47153. /**
  47154. * Stores the intensity of the different subsurface effects in the thickness texture.
  47155. * * the green channel is the translucency intensity.
  47156. * * the blue channel is the scattering intensity.
  47157. * * the alpha channel is the refraction intensity.
  47158. */
  47159. useMaskFromThicknessTexture: boolean;
  47160. /** @hidden */
  47161. private _internalMarkAllSubMeshesAsTexturesDirty;
  47162. /** @hidden */
  47163. _markAllSubMeshesAsTexturesDirty(): void;
  47164. /**
  47165. * Instantiate a new istance of sub surface configuration.
  47166. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47167. */
  47168. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47169. /**
  47170. * Gets wehter the submesh is ready to be used or not.
  47171. * @param defines the list of "defines" to update.
  47172. * @param scene defines the scene the material belongs to.
  47173. * @returns - boolean indicating that the submesh is ready or not.
  47174. */
  47175. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47176. /**
  47177. * Checks to see if a texture is used in the material.
  47178. * @param defines the list of "defines" to update.
  47179. * @param scene defines the scene to the material belongs to.
  47180. */
  47181. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47182. /**
  47183. * Binds the material data.
  47184. * @param uniformBuffer defines the Uniform buffer to fill in.
  47185. * @param scene defines the scene the material belongs to.
  47186. * @param engine defines the engine the material belongs to.
  47187. * @param isFrozen defines wether the material is frozen or not.
  47188. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47189. */
  47190. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47191. /**
  47192. * Unbinds the material from the mesh.
  47193. * @param activeEffect defines the effect that should be unbound from.
  47194. * @returns true if unbound, otherwise false
  47195. */
  47196. unbind(activeEffect: Effect): boolean;
  47197. /**
  47198. * Returns the texture used for refraction or null if none is used.
  47199. * @param scene defines the scene the material belongs to.
  47200. * @returns - Refraction texture if present. If no refraction texture and refraction
  47201. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47202. */
  47203. private _getRefractionTexture;
  47204. /**
  47205. * Returns true if alpha blending should be disabled.
  47206. */
  47207. readonly disableAlphaBlending: boolean;
  47208. /**
  47209. * Fills the list of render target textures.
  47210. * @param renderTargets the list of render targets to update
  47211. */
  47212. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47213. /**
  47214. * Checks to see if a texture is used in the material.
  47215. * @param texture - Base texture to use.
  47216. * @returns - Boolean specifying if a texture is used in the material.
  47217. */
  47218. hasTexture(texture: BaseTexture): boolean;
  47219. /**
  47220. * Gets a boolean indicating that current material needs to register RTT
  47221. * @returns true if this uses a render target otherwise false.
  47222. */
  47223. hasRenderTargetTextures(): boolean;
  47224. /**
  47225. * Returns an array of the actively used textures.
  47226. * @param activeTextures Array of BaseTextures
  47227. */
  47228. getActiveTextures(activeTextures: BaseTexture[]): void;
  47229. /**
  47230. * Returns the animatable textures.
  47231. * @param animatables Array of animatable textures.
  47232. */
  47233. getAnimatables(animatables: IAnimatable[]): void;
  47234. /**
  47235. * Disposes the resources of the material.
  47236. * @param forceDisposeTextures - Forces the disposal of all textures.
  47237. */
  47238. dispose(forceDisposeTextures?: boolean): void;
  47239. /**
  47240. * Get the current class name of the texture useful for serialization or dynamic coding.
  47241. * @returns "PBRSubSurfaceConfiguration"
  47242. */
  47243. getClassName(): string;
  47244. /**
  47245. * Add fallbacks to the effect fallbacks list.
  47246. * @param defines defines the Base texture to use.
  47247. * @param fallbacks defines the current fallback list.
  47248. * @param currentRank defines the current fallback rank.
  47249. * @returns the new fallback rank.
  47250. */
  47251. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47252. /**
  47253. * Add the required uniforms to the current list.
  47254. * @param uniforms defines the current uniform list.
  47255. */
  47256. static AddUniforms(uniforms: string[]): void;
  47257. /**
  47258. * Add the required samplers to the current list.
  47259. * @param samplers defines the current sampler list.
  47260. */
  47261. static AddSamplers(samplers: string[]): void;
  47262. /**
  47263. * Add the required uniforms to the current buffer.
  47264. * @param uniformBuffer defines the current uniform buffer.
  47265. */
  47266. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47267. /**
  47268. * Makes a duplicate of the current configuration into another one.
  47269. * @param configuration define the config where to copy the info
  47270. */
  47271. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47272. /**
  47273. * Serializes this Sub Surface configuration.
  47274. * @returns - An object with the serialized config.
  47275. */
  47276. serialize(): any;
  47277. /**
  47278. * Parses a anisotropy Configuration from a serialized object.
  47279. * @param source - Serialized object.
  47280. * @param scene Defines the scene we are parsing for
  47281. * @param rootUrl Defines the rootUrl to load from
  47282. */
  47283. parse(source: any, scene: Scene, rootUrl: string): void;
  47284. }
  47285. }
  47286. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  47287. /** @hidden */
  47288. export var pbrFragmentDeclaration: {
  47289. name: string;
  47290. shader: string;
  47291. };
  47292. }
  47293. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  47294. /** @hidden */
  47295. export var pbrUboDeclaration: {
  47296. name: string;
  47297. shader: string;
  47298. };
  47299. }
  47300. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  47301. /** @hidden */
  47302. export var pbrFragmentExtraDeclaration: {
  47303. name: string;
  47304. shader: string;
  47305. };
  47306. }
  47307. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  47308. /** @hidden */
  47309. export var pbrFragmentSamplersDeclaration: {
  47310. name: string;
  47311. shader: string;
  47312. };
  47313. }
  47314. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  47315. /** @hidden */
  47316. export var pbrHelperFunctions: {
  47317. name: string;
  47318. shader: string;
  47319. };
  47320. }
  47321. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  47322. /** @hidden */
  47323. export var harmonicsFunctions: {
  47324. name: string;
  47325. shader: string;
  47326. };
  47327. }
  47328. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  47329. /** @hidden */
  47330. export var pbrDirectLightingSetupFunctions: {
  47331. name: string;
  47332. shader: string;
  47333. };
  47334. }
  47335. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  47336. /** @hidden */
  47337. export var pbrDirectLightingFalloffFunctions: {
  47338. name: string;
  47339. shader: string;
  47340. };
  47341. }
  47342. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  47343. /** @hidden */
  47344. export var pbrBRDFFunctions: {
  47345. name: string;
  47346. shader: string;
  47347. };
  47348. }
  47349. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  47350. /** @hidden */
  47351. export var pbrDirectLightingFunctions: {
  47352. name: string;
  47353. shader: string;
  47354. };
  47355. }
  47356. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  47357. /** @hidden */
  47358. export var pbrIBLFunctions: {
  47359. name: string;
  47360. shader: string;
  47361. };
  47362. }
  47363. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  47364. /** @hidden */
  47365. export var pbrDebug: {
  47366. name: string;
  47367. shader: string;
  47368. };
  47369. }
  47370. declare module "babylonjs/Shaders/pbr.fragment" {
  47371. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  47372. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47373. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  47374. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47375. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47376. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  47377. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47378. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47379. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47380. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47381. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47382. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  47383. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47384. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47385. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47386. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  47387. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  47388. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  47389. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  47390. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  47391. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  47392. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47393. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47394. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  47395. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  47396. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47397. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  47398. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47399. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  47400. /** @hidden */
  47401. export var pbrPixelShader: {
  47402. name: string;
  47403. shader: string;
  47404. };
  47405. }
  47406. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  47407. /** @hidden */
  47408. export var pbrVertexDeclaration: {
  47409. name: string;
  47410. shader: string;
  47411. };
  47412. }
  47413. declare module "babylonjs/Shaders/pbr.vertex" {
  47414. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  47415. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47416. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47417. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47418. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47419. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47420. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  47421. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47422. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47423. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47424. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47425. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  47426. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  47427. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47428. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  47429. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47430. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47431. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  47432. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47433. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47434. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47435. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  47436. /** @hidden */
  47437. export var pbrVertexShader: {
  47438. name: string;
  47439. shader: string;
  47440. };
  47441. }
  47442. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  47443. import { IAnimatable } from "babylonjs/Misc/tools";
  47444. import { Nullable } from "babylonjs/types";
  47445. import { Scene } from "babylonjs/scene";
  47446. import { Matrix, Color3 } from "babylonjs/Maths/math";
  47447. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47449. import { Mesh } from "babylonjs/Meshes/mesh";
  47450. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  47451. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  47452. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  47453. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  47454. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  47455. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  47456. import { Material } from "babylonjs/Materials/material";
  47457. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  47458. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47459. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47460. import "babylonjs/Shaders/pbr.fragment";
  47461. import "babylonjs/Shaders/pbr.vertex";
  47462. /**
  47463. * Manages the defines for the PBR Material.
  47464. * @hidden
  47465. */
  47466. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47467. PBR: boolean;
  47468. MAINUV1: boolean;
  47469. MAINUV2: boolean;
  47470. UV1: boolean;
  47471. UV2: boolean;
  47472. ALBEDO: boolean;
  47473. ALBEDODIRECTUV: number;
  47474. VERTEXCOLOR: boolean;
  47475. AMBIENT: boolean;
  47476. AMBIENTDIRECTUV: number;
  47477. AMBIENTINGRAYSCALE: boolean;
  47478. OPACITY: boolean;
  47479. VERTEXALPHA: boolean;
  47480. OPACITYDIRECTUV: number;
  47481. OPACITYRGB: boolean;
  47482. ALPHATEST: boolean;
  47483. DEPTHPREPASS: boolean;
  47484. ALPHABLEND: boolean;
  47485. ALPHAFROMALBEDO: boolean;
  47486. ALPHATESTVALUE: string;
  47487. SPECULAROVERALPHA: boolean;
  47488. RADIANCEOVERALPHA: boolean;
  47489. ALPHAFRESNEL: boolean;
  47490. LINEARALPHAFRESNEL: boolean;
  47491. PREMULTIPLYALPHA: boolean;
  47492. EMISSIVE: boolean;
  47493. EMISSIVEDIRECTUV: number;
  47494. REFLECTIVITY: boolean;
  47495. REFLECTIVITYDIRECTUV: number;
  47496. SPECULARTERM: boolean;
  47497. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47498. MICROSURFACEAUTOMATIC: boolean;
  47499. LODBASEDMICROSFURACE: boolean;
  47500. MICROSURFACEMAP: boolean;
  47501. MICROSURFACEMAPDIRECTUV: number;
  47502. METALLICWORKFLOW: boolean;
  47503. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47504. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47505. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47506. AOSTOREINMETALMAPRED: boolean;
  47507. ENVIRONMENTBRDF: boolean;
  47508. ENVIRONMENTBRDF_RGBD: boolean;
  47509. NORMAL: boolean;
  47510. TANGENT: boolean;
  47511. BUMP: boolean;
  47512. BUMPDIRECTUV: number;
  47513. OBJECTSPACE_NORMALMAP: boolean;
  47514. PARALLAX: boolean;
  47515. PARALLAXOCCLUSION: boolean;
  47516. NORMALXYSCALE: boolean;
  47517. LIGHTMAP: boolean;
  47518. LIGHTMAPDIRECTUV: number;
  47519. USELIGHTMAPASSHADOWMAP: boolean;
  47520. GAMMALIGHTMAP: boolean;
  47521. REFLECTION: boolean;
  47522. REFLECTIONMAP_3D: boolean;
  47523. REFLECTIONMAP_SPHERICAL: boolean;
  47524. REFLECTIONMAP_PLANAR: boolean;
  47525. REFLECTIONMAP_CUBIC: boolean;
  47526. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47527. REFLECTIONMAP_PROJECTION: boolean;
  47528. REFLECTIONMAP_SKYBOX: boolean;
  47529. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47530. REFLECTIONMAP_EXPLICIT: boolean;
  47531. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47532. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47533. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47534. INVERTCUBICMAP: boolean;
  47535. USESPHERICALFROMREFLECTIONMAP: boolean;
  47536. USEIRRADIANCEMAP: boolean;
  47537. SPHERICAL_HARMONICS: boolean;
  47538. USESPHERICALINVERTEX: boolean;
  47539. REFLECTIONMAP_OPPOSITEZ: boolean;
  47540. LODINREFLECTIONALPHA: boolean;
  47541. GAMMAREFLECTION: boolean;
  47542. RGBDREFLECTION: boolean;
  47543. LINEARSPECULARREFLECTION: boolean;
  47544. RADIANCEOCCLUSION: boolean;
  47545. HORIZONOCCLUSION: boolean;
  47546. INSTANCES: boolean;
  47547. NUM_BONE_INFLUENCERS: number;
  47548. BonesPerMesh: number;
  47549. BONETEXTURE: boolean;
  47550. NONUNIFORMSCALING: boolean;
  47551. MORPHTARGETS: boolean;
  47552. MORPHTARGETS_NORMAL: boolean;
  47553. MORPHTARGETS_TANGENT: boolean;
  47554. MORPHTARGETS_UV: boolean;
  47555. NUM_MORPH_INFLUENCERS: number;
  47556. IMAGEPROCESSING: boolean;
  47557. VIGNETTE: boolean;
  47558. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47559. VIGNETTEBLENDMODEOPAQUE: boolean;
  47560. TONEMAPPING: boolean;
  47561. TONEMAPPING_ACES: boolean;
  47562. CONTRAST: boolean;
  47563. COLORCURVES: boolean;
  47564. COLORGRADING: boolean;
  47565. COLORGRADING3D: boolean;
  47566. SAMPLER3DGREENDEPTH: boolean;
  47567. SAMPLER3DBGRMAP: boolean;
  47568. IMAGEPROCESSINGPOSTPROCESS: boolean;
  47569. EXPOSURE: boolean;
  47570. MULTIVIEW: boolean;
  47571. USEPHYSICALLIGHTFALLOFF: boolean;
  47572. USEGLTFLIGHTFALLOFF: boolean;
  47573. TWOSIDEDLIGHTING: boolean;
  47574. SHADOWFLOAT: boolean;
  47575. CLIPPLANE: boolean;
  47576. CLIPPLANE2: boolean;
  47577. CLIPPLANE3: boolean;
  47578. CLIPPLANE4: boolean;
  47579. POINTSIZE: boolean;
  47580. FOG: boolean;
  47581. LOGARITHMICDEPTH: boolean;
  47582. FORCENORMALFORWARD: boolean;
  47583. SPECULARAA: boolean;
  47584. CLEARCOAT: boolean;
  47585. CLEARCOAT_DEFAULTIOR: boolean;
  47586. CLEARCOAT_TEXTURE: boolean;
  47587. CLEARCOAT_TEXTUREDIRECTUV: number;
  47588. CLEARCOAT_BUMP: boolean;
  47589. CLEARCOAT_BUMPDIRECTUV: number;
  47590. CLEARCOAT_TINT: boolean;
  47591. CLEARCOAT_TINT_TEXTURE: boolean;
  47592. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47593. ANISOTROPIC: boolean;
  47594. ANISOTROPIC_TEXTURE: boolean;
  47595. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47596. BRDF_V_HEIGHT_CORRELATED: boolean;
  47597. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47598. SHEEN: boolean;
  47599. SHEEN_TEXTURE: boolean;
  47600. SHEEN_TEXTUREDIRECTUV: number;
  47601. SHEEN_LINKWITHALBEDO: boolean;
  47602. SUBSURFACE: boolean;
  47603. SS_REFRACTION: boolean;
  47604. SS_TRANSLUCENCY: boolean;
  47605. SS_SCATERRING: boolean;
  47606. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47607. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47608. SS_REFRACTIONMAP_3D: boolean;
  47609. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47610. SS_LODINREFRACTIONALPHA: boolean;
  47611. SS_GAMMAREFRACTION: boolean;
  47612. SS_RGBDREFRACTION: boolean;
  47613. SS_LINEARSPECULARREFRACTION: boolean;
  47614. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47615. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47616. UNLIT: boolean;
  47617. DEBUGMODE: number;
  47618. /**
  47619. * Initializes the PBR Material defines.
  47620. */
  47621. constructor();
  47622. /**
  47623. * Resets the PBR Material defines.
  47624. */
  47625. reset(): void;
  47626. }
  47627. /**
  47628. * The Physically based material base class of BJS.
  47629. *
  47630. * This offers the main features of a standard PBR material.
  47631. * For more information, please refer to the documentation :
  47632. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47633. */
  47634. export abstract class PBRBaseMaterial extends PushMaterial {
  47635. /**
  47636. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47637. */
  47638. static readonly PBRMATERIAL_OPAQUE: number;
  47639. /**
  47640. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47641. */
  47642. static readonly PBRMATERIAL_ALPHATEST: number;
  47643. /**
  47644. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47645. */
  47646. static readonly PBRMATERIAL_ALPHABLEND: number;
  47647. /**
  47648. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47649. * They are also discarded below the alpha cutoff threshold to improve performances.
  47650. */
  47651. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47652. /**
  47653. * Defines the default value of how much AO map is occluding the analytical lights
  47654. * (point spot...).
  47655. */
  47656. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47657. /**
  47658. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47659. */
  47660. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47661. /**
  47662. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47663. * to enhance interoperability with other engines.
  47664. */
  47665. static readonly LIGHTFALLOFF_GLTF: number;
  47666. /**
  47667. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47668. * to enhance interoperability with other materials.
  47669. */
  47670. static readonly LIGHTFALLOFF_STANDARD: number;
  47671. /**
  47672. * Intensity of the direct lights e.g. the four lights available in your scene.
  47673. * This impacts both the direct diffuse and specular highlights.
  47674. */
  47675. protected _directIntensity: number;
  47676. /**
  47677. * Intensity of the emissive part of the material.
  47678. * This helps controlling the emissive effect without modifying the emissive color.
  47679. */
  47680. protected _emissiveIntensity: number;
  47681. /**
  47682. * Intensity of the environment e.g. how much the environment will light the object
  47683. * either through harmonics for rough material or through the refelction for shiny ones.
  47684. */
  47685. protected _environmentIntensity: number;
  47686. /**
  47687. * This is a special control allowing the reduction of the specular highlights coming from the
  47688. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47689. */
  47690. protected _specularIntensity: number;
  47691. /**
  47692. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47693. */
  47694. private _lightingInfos;
  47695. /**
  47696. * Debug Control allowing disabling the bump map on this material.
  47697. */
  47698. protected _disableBumpMap: boolean;
  47699. /**
  47700. * AKA Diffuse Texture in standard nomenclature.
  47701. */
  47702. protected _albedoTexture: Nullable<BaseTexture>;
  47703. /**
  47704. * AKA Occlusion Texture in other nomenclature.
  47705. */
  47706. protected _ambientTexture: Nullable<BaseTexture>;
  47707. /**
  47708. * AKA Occlusion Texture Intensity in other nomenclature.
  47709. */
  47710. protected _ambientTextureStrength: number;
  47711. /**
  47712. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47713. * 1 means it completely occludes it
  47714. * 0 mean it has no impact
  47715. */
  47716. protected _ambientTextureImpactOnAnalyticalLights: number;
  47717. /**
  47718. * Stores the alpha values in a texture.
  47719. */
  47720. protected _opacityTexture: Nullable<BaseTexture>;
  47721. /**
  47722. * Stores the reflection values in a texture.
  47723. */
  47724. protected _reflectionTexture: Nullable<BaseTexture>;
  47725. /**
  47726. * Stores the emissive values in a texture.
  47727. */
  47728. protected _emissiveTexture: Nullable<BaseTexture>;
  47729. /**
  47730. * AKA Specular texture in other nomenclature.
  47731. */
  47732. protected _reflectivityTexture: Nullable<BaseTexture>;
  47733. /**
  47734. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47735. */
  47736. protected _metallicTexture: Nullable<BaseTexture>;
  47737. /**
  47738. * Specifies the metallic scalar of the metallic/roughness workflow.
  47739. * Can also be used to scale the metalness values of the metallic texture.
  47740. */
  47741. protected _metallic: Nullable<number>;
  47742. /**
  47743. * Specifies the roughness scalar of the metallic/roughness workflow.
  47744. * Can also be used to scale the roughness values of the metallic texture.
  47745. */
  47746. protected _roughness: Nullable<number>;
  47747. /**
  47748. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47749. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47750. */
  47751. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47752. /**
  47753. * Stores surface normal data used to displace a mesh in a texture.
  47754. */
  47755. protected _bumpTexture: Nullable<BaseTexture>;
  47756. /**
  47757. * Stores the pre-calculated light information of a mesh in a texture.
  47758. */
  47759. protected _lightmapTexture: Nullable<BaseTexture>;
  47760. /**
  47761. * The color of a material in ambient lighting.
  47762. */
  47763. protected _ambientColor: Color3;
  47764. /**
  47765. * AKA Diffuse Color in other nomenclature.
  47766. */
  47767. protected _albedoColor: Color3;
  47768. /**
  47769. * AKA Specular Color in other nomenclature.
  47770. */
  47771. protected _reflectivityColor: Color3;
  47772. /**
  47773. * The color applied when light is reflected from a material.
  47774. */
  47775. protected _reflectionColor: Color3;
  47776. /**
  47777. * The color applied when light is emitted from a material.
  47778. */
  47779. protected _emissiveColor: Color3;
  47780. /**
  47781. * AKA Glossiness in other nomenclature.
  47782. */
  47783. protected _microSurface: number;
  47784. /**
  47785. * Specifies that the material will use the light map as a show map.
  47786. */
  47787. protected _useLightmapAsShadowmap: boolean;
  47788. /**
  47789. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47790. * makes the reflect vector face the model (under horizon).
  47791. */
  47792. protected _useHorizonOcclusion: boolean;
  47793. /**
  47794. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47795. * too much the area relying on ambient texture to define their ambient occlusion.
  47796. */
  47797. protected _useRadianceOcclusion: boolean;
  47798. /**
  47799. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47800. */
  47801. protected _useAlphaFromAlbedoTexture: boolean;
  47802. /**
  47803. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47804. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47805. */
  47806. protected _useSpecularOverAlpha: boolean;
  47807. /**
  47808. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47809. */
  47810. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47811. /**
  47812. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47813. */
  47814. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47815. /**
  47816. * Specifies if the metallic texture contains the roughness information in its green channel.
  47817. */
  47818. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47819. /**
  47820. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47821. */
  47822. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47823. /**
  47824. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47825. */
  47826. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47827. /**
  47828. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47829. */
  47830. protected _useAmbientInGrayScale: boolean;
  47831. /**
  47832. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47833. * The material will try to infer what glossiness each pixel should be.
  47834. */
  47835. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47836. /**
  47837. * Defines the falloff type used in this material.
  47838. * It by default is Physical.
  47839. */
  47840. protected _lightFalloff: number;
  47841. /**
  47842. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47843. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47844. */
  47845. protected _useRadianceOverAlpha: boolean;
  47846. /**
  47847. * Allows using an object space normal map (instead of tangent space).
  47848. */
  47849. protected _useObjectSpaceNormalMap: boolean;
  47850. /**
  47851. * Allows using the bump map in parallax mode.
  47852. */
  47853. protected _useParallax: boolean;
  47854. /**
  47855. * Allows using the bump map in parallax occlusion mode.
  47856. */
  47857. protected _useParallaxOcclusion: boolean;
  47858. /**
  47859. * Controls the scale bias of the parallax mode.
  47860. */
  47861. protected _parallaxScaleBias: number;
  47862. /**
  47863. * If sets to true, disables all the lights affecting the material.
  47864. */
  47865. protected _disableLighting: boolean;
  47866. /**
  47867. * Number of Simultaneous lights allowed on the material.
  47868. */
  47869. protected _maxSimultaneousLights: number;
  47870. /**
  47871. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47872. */
  47873. protected _invertNormalMapX: boolean;
  47874. /**
  47875. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47876. */
  47877. protected _invertNormalMapY: boolean;
  47878. /**
  47879. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47880. */
  47881. protected _twoSidedLighting: boolean;
  47882. /**
  47883. * Defines the alpha limits in alpha test mode.
  47884. */
  47885. protected _alphaCutOff: number;
  47886. /**
  47887. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47888. */
  47889. protected _forceAlphaTest: boolean;
  47890. /**
  47891. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47892. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47893. */
  47894. protected _useAlphaFresnel: boolean;
  47895. /**
  47896. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47897. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47898. */
  47899. protected _useLinearAlphaFresnel: boolean;
  47900. /**
  47901. * The transparency mode of the material.
  47902. */
  47903. protected _transparencyMode: Nullable<number>;
  47904. /**
  47905. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47906. * from cos thetav and roughness:
  47907. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47908. */
  47909. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47910. /**
  47911. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47912. */
  47913. protected _forceIrradianceInFragment: boolean;
  47914. /**
  47915. * Force normal to face away from face.
  47916. */
  47917. protected _forceNormalForward: boolean;
  47918. /**
  47919. * Enables specular anti aliasing in the PBR shader.
  47920. * It will both interacts on the Geometry for analytical and IBL lighting.
  47921. * It also prefilter the roughness map based on the bump values.
  47922. */
  47923. protected _enableSpecularAntiAliasing: boolean;
  47924. /**
  47925. * Default configuration related to image processing available in the PBR Material.
  47926. */
  47927. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47928. /**
  47929. * Keep track of the image processing observer to allow dispose and replace.
  47930. */
  47931. private _imageProcessingObserver;
  47932. /**
  47933. * Attaches a new image processing configuration to the PBR Material.
  47934. * @param configuration
  47935. */
  47936. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47937. /**
  47938. * Stores the available render targets.
  47939. */
  47940. private _renderTargets;
  47941. /**
  47942. * Sets the global ambient color for the material used in lighting calculations.
  47943. */
  47944. private _globalAmbientColor;
  47945. /**
  47946. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47947. */
  47948. private _useLogarithmicDepth;
  47949. /**
  47950. * If set to true, no lighting calculations will be applied.
  47951. */
  47952. private _unlit;
  47953. private _debugMode;
  47954. /**
  47955. * @hidden
  47956. * This is reserved for the inspector.
  47957. * Defines the material debug mode.
  47958. * It helps seeing only some components of the material while troubleshooting.
  47959. */
  47960. debugMode: number;
  47961. /**
  47962. * @hidden
  47963. * This is reserved for the inspector.
  47964. * Specify from where on screen the debug mode should start.
  47965. * The value goes from -1 (full screen) to 1 (not visible)
  47966. * It helps with side by side comparison against the final render
  47967. * This defaults to -1
  47968. */
  47969. private debugLimit;
  47970. /**
  47971. * @hidden
  47972. * This is reserved for the inspector.
  47973. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47974. * You can use the factor to better multiply the final value.
  47975. */
  47976. private debugFactor;
  47977. /**
  47978. * Defines the clear coat layer parameters for the material.
  47979. */
  47980. readonly clearCoat: PBRClearCoatConfiguration;
  47981. /**
  47982. * Defines the anisotropic parameters for the material.
  47983. */
  47984. readonly anisotropy: PBRAnisotropicConfiguration;
  47985. /**
  47986. * Defines the BRDF parameters for the material.
  47987. */
  47988. readonly brdf: PBRBRDFConfiguration;
  47989. /**
  47990. * Defines the Sheen parameters for the material.
  47991. */
  47992. readonly sheen: PBRSheenConfiguration;
  47993. /**
  47994. * Defines the SubSurface parameters for the material.
  47995. */
  47996. readonly subSurface: PBRSubSurfaceConfiguration;
  47997. /**
  47998. * Custom callback helping to override the default shader used in the material.
  47999. */
  48000. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  48001. /**
  48002. * Instantiates a new PBRMaterial instance.
  48003. *
  48004. * @param name The material name
  48005. * @param scene The scene the material will be use in.
  48006. */
  48007. constructor(name: string, scene: Scene);
  48008. /**
  48009. * Gets a boolean indicating that current material needs to register RTT
  48010. */
  48011. readonly hasRenderTargetTextures: boolean;
  48012. /**
  48013. * Gets the name of the material class.
  48014. */
  48015. getClassName(): string;
  48016. /**
  48017. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48018. */
  48019. /**
  48020. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48021. */
  48022. useLogarithmicDepth: boolean;
  48023. /**
  48024. * Gets the current transparency mode.
  48025. */
  48026. /**
  48027. * Sets the transparency mode of the material.
  48028. *
  48029. * | Value | Type | Description |
  48030. * | ----- | ----------------------------------- | ----------- |
  48031. * | 0 | OPAQUE | |
  48032. * | 1 | ALPHATEST | |
  48033. * | 2 | ALPHABLEND | |
  48034. * | 3 | ALPHATESTANDBLEND | |
  48035. *
  48036. */
  48037. transparencyMode: Nullable<number>;
  48038. /**
  48039. * Returns true if alpha blending should be disabled.
  48040. */
  48041. private readonly _disableAlphaBlending;
  48042. /**
  48043. * Specifies whether or not this material should be rendered in alpha blend mode.
  48044. */
  48045. needAlphaBlending(): boolean;
  48046. /**
  48047. * Specifies if the mesh will require alpha blending.
  48048. * @param mesh - BJS mesh.
  48049. */
  48050. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48051. /**
  48052. * Specifies whether or not this material should be rendered in alpha test mode.
  48053. */
  48054. needAlphaTesting(): boolean;
  48055. /**
  48056. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48057. */
  48058. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48059. /**
  48060. * Gets the texture used for the alpha test.
  48061. */
  48062. getAlphaTestTexture(): Nullable<BaseTexture>;
  48063. /**
  48064. * Specifies that the submesh is ready to be used.
  48065. * @param mesh - BJS mesh.
  48066. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48067. * @param useInstances - Specifies that instances should be used.
  48068. * @returns - boolean indicating that the submesh is ready or not.
  48069. */
  48070. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48071. /**
  48072. * Specifies if the material uses metallic roughness workflow.
  48073. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48074. */
  48075. isMetallicWorkflow(): boolean;
  48076. private _prepareEffect;
  48077. private _prepareDefines;
  48078. /**
  48079. * Force shader compilation
  48080. */
  48081. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  48082. clipPlane: boolean;
  48083. }>): void;
  48084. /**
  48085. * Initializes the uniform buffer layout for the shader.
  48086. */
  48087. buildUniformLayout(): void;
  48088. /**
  48089. * Unbinds the material from the mesh
  48090. */
  48091. unbind(): void;
  48092. /**
  48093. * Binds the submesh data.
  48094. * @param world - The world matrix.
  48095. * @param mesh - The BJS mesh.
  48096. * @param subMesh - A submesh of the BJS mesh.
  48097. */
  48098. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48099. /**
  48100. * Returns the animatable textures.
  48101. * @returns - Array of animatable textures.
  48102. */
  48103. getAnimatables(): IAnimatable[];
  48104. /**
  48105. * Returns the texture used for reflections.
  48106. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  48107. */
  48108. private _getReflectionTexture;
  48109. /**
  48110. * Returns an array of the actively used textures.
  48111. * @returns - Array of BaseTextures
  48112. */
  48113. getActiveTextures(): BaseTexture[];
  48114. /**
  48115. * Checks to see if a texture is used in the material.
  48116. * @param texture - Base texture to use.
  48117. * @returns - Boolean specifying if a texture is used in the material.
  48118. */
  48119. hasTexture(texture: BaseTexture): boolean;
  48120. /**
  48121. * Disposes the resources of the material.
  48122. * @param forceDisposeEffect - Forces the disposal of effects.
  48123. * @param forceDisposeTextures - Forces the disposal of all textures.
  48124. */
  48125. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48126. }
  48127. }
  48128. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  48129. import { Nullable } from "babylonjs/types";
  48130. import { Scene } from "babylonjs/scene";
  48131. import { Color3 } from "babylonjs/Maths/math";
  48132. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48133. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48134. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48135. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48136. /**
  48137. * The Physically based material of BJS.
  48138. *
  48139. * This offers the main features of a standard PBR material.
  48140. * For more information, please refer to the documentation :
  48141. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48142. */
  48143. export class PBRMaterial extends PBRBaseMaterial {
  48144. /**
  48145. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48146. */
  48147. static readonly PBRMATERIAL_OPAQUE: number;
  48148. /**
  48149. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48150. */
  48151. static readonly PBRMATERIAL_ALPHATEST: number;
  48152. /**
  48153. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48154. */
  48155. static readonly PBRMATERIAL_ALPHABLEND: number;
  48156. /**
  48157. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48158. * They are also discarded below the alpha cutoff threshold to improve performances.
  48159. */
  48160. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48161. /**
  48162. * Defines the default value of how much AO map is occluding the analytical lights
  48163. * (point spot...).
  48164. */
  48165. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48166. /**
  48167. * Intensity of the direct lights e.g. the four lights available in your scene.
  48168. * This impacts both the direct diffuse and specular highlights.
  48169. */
  48170. directIntensity: number;
  48171. /**
  48172. * Intensity of the emissive part of the material.
  48173. * This helps controlling the emissive effect without modifying the emissive color.
  48174. */
  48175. emissiveIntensity: number;
  48176. /**
  48177. * Intensity of the environment e.g. how much the environment will light the object
  48178. * either through harmonics for rough material or through the refelction for shiny ones.
  48179. */
  48180. environmentIntensity: number;
  48181. /**
  48182. * This is a special control allowing the reduction of the specular highlights coming from the
  48183. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48184. */
  48185. specularIntensity: number;
  48186. /**
  48187. * Debug Control allowing disabling the bump map on this material.
  48188. */
  48189. disableBumpMap: boolean;
  48190. /**
  48191. * AKA Diffuse Texture in standard nomenclature.
  48192. */
  48193. albedoTexture: BaseTexture;
  48194. /**
  48195. * AKA Occlusion Texture in other nomenclature.
  48196. */
  48197. ambientTexture: BaseTexture;
  48198. /**
  48199. * AKA Occlusion Texture Intensity in other nomenclature.
  48200. */
  48201. ambientTextureStrength: number;
  48202. /**
  48203. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48204. * 1 means it completely occludes it
  48205. * 0 mean it has no impact
  48206. */
  48207. ambientTextureImpactOnAnalyticalLights: number;
  48208. /**
  48209. * Stores the alpha values in a texture.
  48210. */
  48211. opacityTexture: BaseTexture;
  48212. /**
  48213. * Stores the reflection values in a texture.
  48214. */
  48215. reflectionTexture: Nullable<BaseTexture>;
  48216. /**
  48217. * Stores the emissive values in a texture.
  48218. */
  48219. emissiveTexture: BaseTexture;
  48220. /**
  48221. * AKA Specular texture in other nomenclature.
  48222. */
  48223. reflectivityTexture: BaseTexture;
  48224. /**
  48225. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48226. */
  48227. metallicTexture: BaseTexture;
  48228. /**
  48229. * Specifies the metallic scalar of the metallic/roughness workflow.
  48230. * Can also be used to scale the metalness values of the metallic texture.
  48231. */
  48232. metallic: Nullable<number>;
  48233. /**
  48234. * Specifies the roughness scalar of the metallic/roughness workflow.
  48235. * Can also be used to scale the roughness values of the metallic texture.
  48236. */
  48237. roughness: Nullable<number>;
  48238. /**
  48239. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48240. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48241. */
  48242. microSurfaceTexture: BaseTexture;
  48243. /**
  48244. * Stores surface normal data used to displace a mesh in a texture.
  48245. */
  48246. bumpTexture: BaseTexture;
  48247. /**
  48248. * Stores the pre-calculated light information of a mesh in a texture.
  48249. */
  48250. lightmapTexture: BaseTexture;
  48251. /**
  48252. * Stores the refracted light information in a texture.
  48253. */
  48254. refractionTexture: Nullable<BaseTexture>;
  48255. /**
  48256. * The color of a material in ambient lighting.
  48257. */
  48258. ambientColor: Color3;
  48259. /**
  48260. * AKA Diffuse Color in other nomenclature.
  48261. */
  48262. albedoColor: Color3;
  48263. /**
  48264. * AKA Specular Color in other nomenclature.
  48265. */
  48266. reflectivityColor: Color3;
  48267. /**
  48268. * The color reflected from the material.
  48269. */
  48270. reflectionColor: Color3;
  48271. /**
  48272. * The color emitted from the material.
  48273. */
  48274. emissiveColor: Color3;
  48275. /**
  48276. * AKA Glossiness in other nomenclature.
  48277. */
  48278. microSurface: number;
  48279. /**
  48280. * source material index of refraction (IOR)' / 'destination material IOR.
  48281. */
  48282. indexOfRefraction: number;
  48283. /**
  48284. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48285. */
  48286. invertRefractionY: boolean;
  48287. /**
  48288. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48289. * Materials half opaque for instance using refraction could benefit from this control.
  48290. */
  48291. linkRefractionWithTransparency: boolean;
  48292. /**
  48293. * If true, the light map contains occlusion information instead of lighting info.
  48294. */
  48295. useLightmapAsShadowmap: boolean;
  48296. /**
  48297. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48298. */
  48299. useAlphaFromAlbedoTexture: boolean;
  48300. /**
  48301. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48302. */
  48303. forceAlphaTest: boolean;
  48304. /**
  48305. * Defines the alpha limits in alpha test mode.
  48306. */
  48307. alphaCutOff: number;
  48308. /**
  48309. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48310. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48311. */
  48312. useSpecularOverAlpha: boolean;
  48313. /**
  48314. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48315. */
  48316. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48317. /**
  48318. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48319. */
  48320. useRoughnessFromMetallicTextureAlpha: boolean;
  48321. /**
  48322. * Specifies if the metallic texture contains the roughness information in its green channel.
  48323. */
  48324. useRoughnessFromMetallicTextureGreen: boolean;
  48325. /**
  48326. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48327. */
  48328. useMetallnessFromMetallicTextureBlue: boolean;
  48329. /**
  48330. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48331. */
  48332. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48333. /**
  48334. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48335. */
  48336. useAmbientInGrayScale: boolean;
  48337. /**
  48338. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48339. * The material will try to infer what glossiness each pixel should be.
  48340. */
  48341. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48342. /**
  48343. * BJS is using an harcoded light falloff based on a manually sets up range.
  48344. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48345. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48346. */
  48347. /**
  48348. * BJS is using an harcoded light falloff based on a manually sets up range.
  48349. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48350. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48351. */
  48352. usePhysicalLightFalloff: boolean;
  48353. /**
  48354. * In order to support the falloff compatibility with gltf, a special mode has been added
  48355. * to reproduce the gltf light falloff.
  48356. */
  48357. /**
  48358. * In order to support the falloff compatibility with gltf, a special mode has been added
  48359. * to reproduce the gltf light falloff.
  48360. */
  48361. useGLTFLightFalloff: boolean;
  48362. /**
  48363. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48364. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48365. */
  48366. useRadianceOverAlpha: boolean;
  48367. /**
  48368. * Allows using an object space normal map (instead of tangent space).
  48369. */
  48370. useObjectSpaceNormalMap: boolean;
  48371. /**
  48372. * Allows using the bump map in parallax mode.
  48373. */
  48374. useParallax: boolean;
  48375. /**
  48376. * Allows using the bump map in parallax occlusion mode.
  48377. */
  48378. useParallaxOcclusion: boolean;
  48379. /**
  48380. * Controls the scale bias of the parallax mode.
  48381. */
  48382. parallaxScaleBias: number;
  48383. /**
  48384. * If sets to true, disables all the lights affecting the material.
  48385. */
  48386. disableLighting: boolean;
  48387. /**
  48388. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48389. */
  48390. forceIrradianceInFragment: boolean;
  48391. /**
  48392. * Number of Simultaneous lights allowed on the material.
  48393. */
  48394. maxSimultaneousLights: number;
  48395. /**
  48396. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48397. */
  48398. invertNormalMapX: boolean;
  48399. /**
  48400. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48401. */
  48402. invertNormalMapY: boolean;
  48403. /**
  48404. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48405. */
  48406. twoSidedLighting: boolean;
  48407. /**
  48408. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48409. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48410. */
  48411. useAlphaFresnel: boolean;
  48412. /**
  48413. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48414. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48415. */
  48416. useLinearAlphaFresnel: boolean;
  48417. /**
  48418. * Let user defines the brdf lookup texture used for IBL.
  48419. * A default 8bit version is embedded but you could point at :
  48420. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  48421. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48422. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  48423. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48424. */
  48425. environmentBRDFTexture: Nullable<BaseTexture>;
  48426. /**
  48427. * Force normal to face away from face.
  48428. */
  48429. forceNormalForward: boolean;
  48430. /**
  48431. * Enables specular anti aliasing in the PBR shader.
  48432. * It will both interacts on the Geometry for analytical and IBL lighting.
  48433. * It also prefilter the roughness map based on the bump values.
  48434. */
  48435. enableSpecularAntiAliasing: boolean;
  48436. /**
  48437. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48438. * makes the reflect vector face the model (under horizon).
  48439. */
  48440. useHorizonOcclusion: boolean;
  48441. /**
  48442. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48443. * too much the area relying on ambient texture to define their ambient occlusion.
  48444. */
  48445. useRadianceOcclusion: boolean;
  48446. /**
  48447. * If set to true, no lighting calculations will be applied.
  48448. */
  48449. unlit: boolean;
  48450. /**
  48451. * Gets the image processing configuration used either in this material.
  48452. */
  48453. /**
  48454. * Sets the Default image processing configuration used either in the this material.
  48455. *
  48456. * If sets to null, the scene one is in use.
  48457. */
  48458. imageProcessingConfiguration: ImageProcessingConfiguration;
  48459. /**
  48460. * Gets wether the color curves effect is enabled.
  48461. */
  48462. /**
  48463. * Sets wether the color curves effect is enabled.
  48464. */
  48465. cameraColorCurvesEnabled: boolean;
  48466. /**
  48467. * Gets wether the color grading effect is enabled.
  48468. */
  48469. /**
  48470. * Gets wether the color grading effect is enabled.
  48471. */
  48472. cameraColorGradingEnabled: boolean;
  48473. /**
  48474. * Gets wether tonemapping is enabled or not.
  48475. */
  48476. /**
  48477. * Sets wether tonemapping is enabled or not
  48478. */
  48479. cameraToneMappingEnabled: boolean;
  48480. /**
  48481. * The camera exposure used on this material.
  48482. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48483. * This corresponds to a photographic exposure.
  48484. */
  48485. /**
  48486. * The camera exposure used on this material.
  48487. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48488. * This corresponds to a photographic exposure.
  48489. */
  48490. cameraExposure: number;
  48491. /**
  48492. * Gets The camera contrast used on this material.
  48493. */
  48494. /**
  48495. * Sets The camera contrast used on this material.
  48496. */
  48497. cameraContrast: number;
  48498. /**
  48499. * Gets the Color Grading 2D Lookup Texture.
  48500. */
  48501. /**
  48502. * Sets the Color Grading 2D Lookup Texture.
  48503. */
  48504. cameraColorGradingTexture: Nullable<BaseTexture>;
  48505. /**
  48506. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48507. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48508. * 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;
  48509. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48510. */
  48511. /**
  48512. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48513. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48514. * 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;
  48515. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48516. */
  48517. cameraColorCurves: Nullable<ColorCurves>;
  48518. /**
  48519. * Instantiates a new PBRMaterial instance.
  48520. *
  48521. * @param name The material name
  48522. * @param scene The scene the material will be use in.
  48523. */
  48524. constructor(name: string, scene: Scene);
  48525. /**
  48526. * Returns the name of this material class.
  48527. */
  48528. getClassName(): string;
  48529. /**
  48530. * Makes a duplicate of the current material.
  48531. * @param name - name to use for the new material.
  48532. */
  48533. clone(name: string): PBRMaterial;
  48534. /**
  48535. * Serializes this PBR Material.
  48536. * @returns - An object with the serialized material.
  48537. */
  48538. serialize(): any;
  48539. /**
  48540. * Parses a PBR Material from a serialized object.
  48541. * @param source - Serialized object.
  48542. * @param scene - BJS scene instance.
  48543. * @param rootUrl - url for the scene object
  48544. * @returns - PBRMaterial
  48545. */
  48546. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  48547. }
  48548. }
  48549. declare module "babylonjs/Misc/dds" {
  48550. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48551. import { Engine } from "babylonjs/Engines/engine";
  48552. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48553. import { Nullable } from "babylonjs/types";
  48554. import { Scene } from "babylonjs/scene";
  48555. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  48556. /**
  48557. * Direct draw surface info
  48558. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48559. */
  48560. export interface DDSInfo {
  48561. /**
  48562. * Width of the texture
  48563. */
  48564. width: number;
  48565. /**
  48566. * Width of the texture
  48567. */
  48568. height: number;
  48569. /**
  48570. * Number of Mipmaps for the texture
  48571. * @see https://en.wikipedia.org/wiki/Mipmap
  48572. */
  48573. mipmapCount: number;
  48574. /**
  48575. * If the textures format is a known fourCC format
  48576. * @see https://www.fourcc.org/
  48577. */
  48578. isFourCC: boolean;
  48579. /**
  48580. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48581. */
  48582. isRGB: boolean;
  48583. /**
  48584. * If the texture is a lumincance format
  48585. */
  48586. isLuminance: boolean;
  48587. /**
  48588. * If this is a cube texture
  48589. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48590. */
  48591. isCube: boolean;
  48592. /**
  48593. * If the texture is a compressed format eg. FOURCC_DXT1
  48594. */
  48595. isCompressed: boolean;
  48596. /**
  48597. * The dxgiFormat of the texture
  48598. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48599. */
  48600. dxgiFormat: number;
  48601. /**
  48602. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48603. */
  48604. textureType: number;
  48605. /**
  48606. * Sphericle polynomial created for the dds texture
  48607. */
  48608. sphericalPolynomial?: SphericalPolynomial;
  48609. }
  48610. /**
  48611. * Class used to provide DDS decompression tools
  48612. */
  48613. export class DDSTools {
  48614. /**
  48615. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48616. */
  48617. static StoreLODInAlphaChannel: boolean;
  48618. /**
  48619. * Gets DDS information from an array buffer
  48620. * @param arrayBuffer defines the array buffer to read data from
  48621. * @returns the DDS information
  48622. */
  48623. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48624. private static _FloatView;
  48625. private static _Int32View;
  48626. private static _ToHalfFloat;
  48627. private static _FromHalfFloat;
  48628. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48629. private static _GetHalfFloatRGBAArrayBuffer;
  48630. private static _GetFloatRGBAArrayBuffer;
  48631. private static _GetFloatAsUIntRGBAArrayBuffer;
  48632. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48633. private static _GetRGBAArrayBuffer;
  48634. private static _ExtractLongWordOrder;
  48635. private static _GetRGBArrayBuffer;
  48636. private static _GetLuminanceArrayBuffer;
  48637. /**
  48638. * Uploads DDS Levels to a Babylon Texture
  48639. * @hidden
  48640. */
  48641. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48642. }
  48643. module "babylonjs/Engines/engine" {
  48644. interface Engine {
  48645. /**
  48646. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48647. * @param rootUrl defines the url where the file to load is located
  48648. * @param scene defines the current scene
  48649. * @param lodScale defines scale to apply to the mip map selection
  48650. * @param lodOffset defines offset to apply to the mip map selection
  48651. * @param onLoad defines an optional callback raised when the texture is loaded
  48652. * @param onError defines an optional callback raised if there is an issue to load the texture
  48653. * @param format defines the format of the data
  48654. * @param forcedExtension defines the extension to use to pick the right loader
  48655. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48656. * @returns the cube texture as an InternalTexture
  48657. */
  48658. 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;
  48659. }
  48660. }
  48661. }
  48662. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  48663. import { Nullable } from "babylonjs/types";
  48664. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48665. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48666. /**
  48667. * Implementation of the DDS Texture Loader.
  48668. * @hidden
  48669. */
  48670. export class _DDSTextureLoader implements IInternalTextureLoader {
  48671. /**
  48672. * Defines wether the loader supports cascade loading the different faces.
  48673. */
  48674. readonly supportCascades: boolean;
  48675. /**
  48676. * This returns if the loader support the current file information.
  48677. * @param extension defines the file extension of the file being loaded
  48678. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48679. * @param fallback defines the fallback internal texture if any
  48680. * @param isBase64 defines whether the texture is encoded as a base64
  48681. * @param isBuffer defines whether the texture data are stored as a buffer
  48682. * @returns true if the loader can load the specified file
  48683. */
  48684. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48685. /**
  48686. * Transform the url before loading if required.
  48687. * @param rootUrl the url of the texture
  48688. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48689. * @returns the transformed texture
  48690. */
  48691. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48692. /**
  48693. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48694. * @param rootUrl the url of the texture
  48695. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48696. * @returns the fallback texture
  48697. */
  48698. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48699. /**
  48700. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48701. * @param data contains the texture data
  48702. * @param texture defines the BabylonJS internal texture
  48703. * @param createPolynomials will be true if polynomials have been requested
  48704. * @param onLoad defines the callback to trigger once the texture is ready
  48705. * @param onError defines the callback to trigger in case of error
  48706. */
  48707. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48708. /**
  48709. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48710. * @param data contains the texture data
  48711. * @param texture defines the BabylonJS internal texture
  48712. * @param callback defines the method to call once ready to upload
  48713. */
  48714. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48715. }
  48716. }
  48717. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48718. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48719. /** @hidden */
  48720. export var rgbdEncodePixelShader: {
  48721. name: string;
  48722. shader: string;
  48723. };
  48724. }
  48725. declare module "babylonjs/Misc/environmentTextureTools" {
  48726. import { Nullable } from "babylonjs/types";
  48727. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48728. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48729. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48730. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48731. import "babylonjs/Shaders/rgbdEncode.fragment";
  48732. import "babylonjs/Shaders/rgbdDecode.fragment";
  48733. /**
  48734. * Raw texture data and descriptor sufficient for WebGL texture upload
  48735. */
  48736. export interface EnvironmentTextureInfo {
  48737. /**
  48738. * Version of the environment map
  48739. */
  48740. version: number;
  48741. /**
  48742. * Width of image
  48743. */
  48744. width: number;
  48745. /**
  48746. * Irradiance information stored in the file.
  48747. */
  48748. irradiance: any;
  48749. /**
  48750. * Specular information stored in the file.
  48751. */
  48752. specular: any;
  48753. }
  48754. /**
  48755. * Sets of helpers addressing the serialization and deserialization of environment texture
  48756. * stored in a BabylonJS env file.
  48757. * Those files are usually stored as .env files.
  48758. */
  48759. export class EnvironmentTextureTools {
  48760. /**
  48761. * Magic number identifying the env file.
  48762. */
  48763. private static _MagicBytes;
  48764. /**
  48765. * Gets the environment info from an env file.
  48766. * @param data The array buffer containing the .env bytes.
  48767. * @returns the environment file info (the json header) if successfully parsed.
  48768. */
  48769. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48770. /**
  48771. * Creates an environment texture from a loaded cube texture.
  48772. * @param texture defines the cube texture to convert in env file
  48773. * @return a promise containing the environment data if succesfull.
  48774. */
  48775. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48776. /**
  48777. * Creates a JSON representation of the spherical data.
  48778. * @param texture defines the texture containing the polynomials
  48779. * @return the JSON representation of the spherical info
  48780. */
  48781. private static _CreateEnvTextureIrradiance;
  48782. /**
  48783. * Uploads the texture info contained in the env file to the GPU.
  48784. * @param texture defines the internal texture to upload to
  48785. * @param arrayBuffer defines the buffer cotaining the data to load
  48786. * @param info defines the texture info retrieved through the GetEnvInfo method
  48787. * @returns a promise
  48788. */
  48789. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48790. /**
  48791. * Uploads the levels of image data to the GPU.
  48792. * @param texture defines the internal texture to upload to
  48793. * @param imageData defines the array buffer views of image data [mipmap][face]
  48794. * @returns a promise
  48795. */
  48796. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48797. /**
  48798. * Uploads spherical polynomials information to the texture.
  48799. * @param texture defines the texture we are trying to upload the information to
  48800. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48801. */
  48802. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48803. /** @hidden */
  48804. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48805. }
  48806. }
  48807. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48808. import { Nullable } from "babylonjs/types";
  48809. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48810. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48811. /**
  48812. * Implementation of the ENV Texture Loader.
  48813. * @hidden
  48814. */
  48815. export class _ENVTextureLoader implements IInternalTextureLoader {
  48816. /**
  48817. * Defines wether the loader supports cascade loading the different faces.
  48818. */
  48819. readonly supportCascades: boolean;
  48820. /**
  48821. * This returns if the loader support the current file information.
  48822. * @param extension defines the file extension of the file being loaded
  48823. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48824. * @param fallback defines the fallback internal texture if any
  48825. * @param isBase64 defines whether the texture is encoded as a base64
  48826. * @param isBuffer defines whether the texture data are stored as a buffer
  48827. * @returns true if the loader can load the specified file
  48828. */
  48829. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48830. /**
  48831. * Transform the url before loading if required.
  48832. * @param rootUrl the url of the texture
  48833. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48834. * @returns the transformed texture
  48835. */
  48836. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48837. /**
  48838. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48839. * @param rootUrl the url of the texture
  48840. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48841. * @returns the fallback texture
  48842. */
  48843. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48844. /**
  48845. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48846. * @param data contains the texture data
  48847. * @param texture defines the BabylonJS internal texture
  48848. * @param createPolynomials will be true if polynomials have been requested
  48849. * @param onLoad defines the callback to trigger once the texture is ready
  48850. * @param onError defines the callback to trigger in case of error
  48851. */
  48852. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48853. /**
  48854. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48855. * @param data contains the texture data
  48856. * @param texture defines the BabylonJS internal texture
  48857. * @param callback defines the method to call once ready to upload
  48858. */
  48859. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48860. }
  48861. }
  48862. declare module "babylonjs/Misc/khronosTextureContainer" {
  48863. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48864. /**
  48865. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48866. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48867. */
  48868. export class KhronosTextureContainer {
  48869. /** contents of the KTX container file */
  48870. arrayBuffer: any;
  48871. private static HEADER_LEN;
  48872. private static COMPRESSED_2D;
  48873. private static COMPRESSED_3D;
  48874. private static TEX_2D;
  48875. private static TEX_3D;
  48876. /**
  48877. * Gets the openGL type
  48878. */
  48879. glType: number;
  48880. /**
  48881. * Gets the openGL type size
  48882. */
  48883. glTypeSize: number;
  48884. /**
  48885. * Gets the openGL format
  48886. */
  48887. glFormat: number;
  48888. /**
  48889. * Gets the openGL internal format
  48890. */
  48891. glInternalFormat: number;
  48892. /**
  48893. * Gets the base internal format
  48894. */
  48895. glBaseInternalFormat: number;
  48896. /**
  48897. * Gets image width in pixel
  48898. */
  48899. pixelWidth: number;
  48900. /**
  48901. * Gets image height in pixel
  48902. */
  48903. pixelHeight: number;
  48904. /**
  48905. * Gets image depth in pixels
  48906. */
  48907. pixelDepth: number;
  48908. /**
  48909. * Gets the number of array elements
  48910. */
  48911. numberOfArrayElements: number;
  48912. /**
  48913. * Gets the number of faces
  48914. */
  48915. numberOfFaces: number;
  48916. /**
  48917. * Gets the number of mipmap levels
  48918. */
  48919. numberOfMipmapLevels: number;
  48920. /**
  48921. * Gets the bytes of key value data
  48922. */
  48923. bytesOfKeyValueData: number;
  48924. /**
  48925. * Gets the load type
  48926. */
  48927. loadType: number;
  48928. /**
  48929. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48930. */
  48931. isInvalid: boolean;
  48932. /**
  48933. * Creates a new KhronosTextureContainer
  48934. * @param arrayBuffer contents of the KTX container file
  48935. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48936. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48937. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48938. */
  48939. constructor(
  48940. /** contents of the KTX container file */
  48941. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48942. /**
  48943. * Uploads KTX content to a Babylon Texture.
  48944. * It is assumed that the texture has already been created & is currently bound
  48945. * @hidden
  48946. */
  48947. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48948. private _upload2DCompressedLevels;
  48949. }
  48950. }
  48951. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48952. import { Nullable } from "babylonjs/types";
  48953. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48954. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48955. /**
  48956. * Implementation of the KTX Texture Loader.
  48957. * @hidden
  48958. */
  48959. export class _KTXTextureLoader implements IInternalTextureLoader {
  48960. /**
  48961. * Defines wether the loader supports cascade loading the different faces.
  48962. */
  48963. readonly supportCascades: boolean;
  48964. /**
  48965. * This returns if the loader support the current file information.
  48966. * @param extension defines the file extension of the file being loaded
  48967. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48968. * @param fallback defines the fallback internal texture if any
  48969. * @param isBase64 defines whether the texture is encoded as a base64
  48970. * @param isBuffer defines whether the texture data are stored as a buffer
  48971. * @returns true if the loader can load the specified file
  48972. */
  48973. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48974. /**
  48975. * Transform the url before loading if required.
  48976. * @param rootUrl the url of the texture
  48977. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48978. * @returns the transformed texture
  48979. */
  48980. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48981. /**
  48982. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48983. * @param rootUrl the url of the texture
  48984. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48985. * @returns the fallback texture
  48986. */
  48987. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48988. /**
  48989. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48990. * @param data contains the texture data
  48991. * @param texture defines the BabylonJS internal texture
  48992. * @param createPolynomials will be true if polynomials have been requested
  48993. * @param onLoad defines the callback to trigger once the texture is ready
  48994. * @param onError defines the callback to trigger in case of error
  48995. */
  48996. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48997. /**
  48998. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48999. * @param data contains the texture data
  49000. * @param texture defines the BabylonJS internal texture
  49001. * @param callback defines the method to call once ready to upload
  49002. */
  49003. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  49004. }
  49005. }
  49006. declare module "babylonjs/Helpers/sceneHelpers" {
  49007. import { Nullable } from "babylonjs/types";
  49008. import { Mesh } from "babylonjs/Meshes/mesh";
  49009. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49010. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  49011. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  49012. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  49013. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49014. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49015. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49016. import "babylonjs/Meshes/Builders/boxBuilder";
  49017. /** @hidden */
  49018. export var _forceSceneHelpersToBundle: boolean;
  49019. module "babylonjs/scene" {
  49020. interface Scene {
  49021. /**
  49022. * Creates a default light for the scene.
  49023. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  49024. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  49025. */
  49026. createDefaultLight(replace?: boolean): void;
  49027. /**
  49028. * Creates a default camera for the scene.
  49029. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  49030. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49031. * @param replace has default false, when true replaces the active camera in the scene
  49032. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  49033. */
  49034. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49035. /**
  49036. * Creates a default camera and a default light.
  49037. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  49038. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49039. * @param replace has the default false, when true replaces the active camera/light in the scene
  49040. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  49041. */
  49042. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49043. /**
  49044. * Creates a new sky box
  49045. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  49046. * @param environmentTexture defines the texture to use as environment texture
  49047. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  49048. * @param scale defines the overall scale of the skybox
  49049. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  49050. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  49051. * @returns a new mesh holding the sky box
  49052. */
  49053. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  49054. /**
  49055. * Creates a new environment
  49056. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  49057. * @param options defines the options you can use to configure the environment
  49058. * @returns the new EnvironmentHelper
  49059. */
  49060. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  49061. /**
  49062. * Creates a new VREXperienceHelper
  49063. * @see http://doc.babylonjs.com/how_to/webvr_helper
  49064. * @param webVROptions defines the options used to create the new VREXperienceHelper
  49065. * @returns a new VREXperienceHelper
  49066. */
  49067. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  49068. /**
  49069. * Creates a new XREXperienceHelper
  49070. * @see http://doc.babylonjs.com/how_to/webxr
  49071. * @returns a promise for a new XREXperienceHelper
  49072. */
  49073. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  49074. }
  49075. }
  49076. }
  49077. declare module "babylonjs/Helpers/videoDome" {
  49078. import { Scene } from "babylonjs/scene";
  49079. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49080. import { Mesh } from "babylonjs/Meshes/mesh";
  49081. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  49082. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49083. import "babylonjs/Meshes/Builders/sphereBuilder";
  49084. /**
  49085. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  49086. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  49087. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  49088. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49089. */
  49090. export class VideoDome extends TransformNode {
  49091. /**
  49092. * Define the video source as a Monoscopic panoramic 360 video.
  49093. */
  49094. static readonly MODE_MONOSCOPIC: number;
  49095. /**
  49096. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49097. */
  49098. static readonly MODE_TOPBOTTOM: number;
  49099. /**
  49100. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49101. */
  49102. static readonly MODE_SIDEBYSIDE: number;
  49103. private _useDirectMapping;
  49104. /**
  49105. * The video texture being displayed on the sphere
  49106. */
  49107. protected _videoTexture: VideoTexture;
  49108. /**
  49109. * Gets the video texture being displayed on the sphere
  49110. */
  49111. readonly videoTexture: VideoTexture;
  49112. /**
  49113. * The skybox material
  49114. */
  49115. protected _material: BackgroundMaterial;
  49116. /**
  49117. * The surface used for the skybox
  49118. */
  49119. protected _mesh: Mesh;
  49120. /**
  49121. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49122. * Also see the options.resolution property.
  49123. */
  49124. fovMultiplier: number;
  49125. private _videoMode;
  49126. /**
  49127. * Gets or set the current video mode for the video. It can be:
  49128. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  49129. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49130. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49131. */
  49132. videoMode: number;
  49133. /**
  49134. * Oberserver used in Stereoscopic VR Mode.
  49135. */
  49136. private _onBeforeCameraRenderObserver;
  49137. /**
  49138. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  49139. * @param name Element's name, child elements will append suffixes for their own names.
  49140. * @param urlsOrVideo defines the url(s) or the video element to use
  49141. * @param options An object containing optional or exposed sub element properties
  49142. */
  49143. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  49144. resolution?: number;
  49145. clickToPlay?: boolean;
  49146. autoPlay?: boolean;
  49147. loop?: boolean;
  49148. size?: number;
  49149. poster?: string;
  49150. faceForward?: boolean;
  49151. useDirectMapping?: boolean;
  49152. }, scene: Scene);
  49153. private _changeVideoMode;
  49154. /**
  49155. * Releases resources associated with this node.
  49156. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49157. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49158. */
  49159. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49160. }
  49161. }
  49162. declare module "babylonjs/Helpers/index" {
  49163. export * from "babylonjs/Helpers/environmentHelper";
  49164. export * from "babylonjs/Helpers/photoDome";
  49165. export * from "babylonjs/Helpers/sceneHelpers";
  49166. export * from "babylonjs/Helpers/videoDome";
  49167. }
  49168. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  49169. import { PerfCounter } from "babylonjs/Misc/tools";
  49170. import { IDisposable } from "babylonjs/scene";
  49171. import { Engine } from "babylonjs/Engines/engine";
  49172. /**
  49173. * This class can be used to get instrumentation data from a Babylon engine
  49174. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49175. */
  49176. export class EngineInstrumentation implements IDisposable {
  49177. /**
  49178. * Define the instrumented engine.
  49179. */
  49180. engine: Engine;
  49181. private _captureGPUFrameTime;
  49182. private _gpuFrameTimeToken;
  49183. private _gpuFrameTime;
  49184. private _captureShaderCompilationTime;
  49185. private _shaderCompilationTime;
  49186. private _onBeginFrameObserver;
  49187. private _onEndFrameObserver;
  49188. private _onBeforeShaderCompilationObserver;
  49189. private _onAfterShaderCompilationObserver;
  49190. /**
  49191. * Gets the perf counter used for GPU frame time
  49192. */
  49193. readonly gpuFrameTimeCounter: PerfCounter;
  49194. /**
  49195. * Gets the GPU frame time capture status
  49196. */
  49197. /**
  49198. * Enable or disable the GPU frame time capture
  49199. */
  49200. captureGPUFrameTime: boolean;
  49201. /**
  49202. * Gets the perf counter used for shader compilation time
  49203. */
  49204. readonly shaderCompilationTimeCounter: PerfCounter;
  49205. /**
  49206. * Gets the shader compilation time capture status
  49207. */
  49208. /**
  49209. * Enable or disable the shader compilation time capture
  49210. */
  49211. captureShaderCompilationTime: boolean;
  49212. /**
  49213. * Instantiates a new engine instrumentation.
  49214. * This class can be used to get instrumentation data from a Babylon engine
  49215. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49216. * @param engine Defines the engine to instrument
  49217. */
  49218. constructor(
  49219. /**
  49220. * Define the instrumented engine.
  49221. */
  49222. engine: Engine);
  49223. /**
  49224. * Dispose and release associated resources.
  49225. */
  49226. dispose(): void;
  49227. }
  49228. }
  49229. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  49230. import { PerfCounter } from "babylonjs/Misc/tools";
  49231. import { Scene, IDisposable } from "babylonjs/scene";
  49232. /**
  49233. * This class can be used to get instrumentation data from a Babylon engine
  49234. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49235. */
  49236. export class SceneInstrumentation implements IDisposable {
  49237. /**
  49238. * Defines the scene to instrument
  49239. */
  49240. scene: Scene;
  49241. private _captureActiveMeshesEvaluationTime;
  49242. private _activeMeshesEvaluationTime;
  49243. private _captureRenderTargetsRenderTime;
  49244. private _renderTargetsRenderTime;
  49245. private _captureFrameTime;
  49246. private _frameTime;
  49247. private _captureRenderTime;
  49248. private _renderTime;
  49249. private _captureInterFrameTime;
  49250. private _interFrameTime;
  49251. private _captureParticlesRenderTime;
  49252. private _particlesRenderTime;
  49253. private _captureSpritesRenderTime;
  49254. private _spritesRenderTime;
  49255. private _capturePhysicsTime;
  49256. private _physicsTime;
  49257. private _captureAnimationsTime;
  49258. private _animationsTime;
  49259. private _captureCameraRenderTime;
  49260. private _cameraRenderTime;
  49261. private _onBeforeActiveMeshesEvaluationObserver;
  49262. private _onAfterActiveMeshesEvaluationObserver;
  49263. private _onBeforeRenderTargetsRenderObserver;
  49264. private _onAfterRenderTargetsRenderObserver;
  49265. private _onAfterRenderObserver;
  49266. private _onBeforeDrawPhaseObserver;
  49267. private _onAfterDrawPhaseObserver;
  49268. private _onBeforeAnimationsObserver;
  49269. private _onBeforeParticlesRenderingObserver;
  49270. private _onAfterParticlesRenderingObserver;
  49271. private _onBeforeSpritesRenderingObserver;
  49272. private _onAfterSpritesRenderingObserver;
  49273. private _onBeforePhysicsObserver;
  49274. private _onAfterPhysicsObserver;
  49275. private _onAfterAnimationsObserver;
  49276. private _onBeforeCameraRenderObserver;
  49277. private _onAfterCameraRenderObserver;
  49278. /**
  49279. * Gets the perf counter used for active meshes evaluation time
  49280. */
  49281. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49282. /**
  49283. * Gets the active meshes evaluation time capture status
  49284. */
  49285. /**
  49286. * Enable or disable the active meshes evaluation time capture
  49287. */
  49288. captureActiveMeshesEvaluationTime: boolean;
  49289. /**
  49290. * Gets the perf counter used for render targets render time
  49291. */
  49292. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49293. /**
  49294. * Gets the render targets render time capture status
  49295. */
  49296. /**
  49297. * Enable or disable the render targets render time capture
  49298. */
  49299. captureRenderTargetsRenderTime: boolean;
  49300. /**
  49301. * Gets the perf counter used for particles render time
  49302. */
  49303. readonly particlesRenderTimeCounter: PerfCounter;
  49304. /**
  49305. * Gets the particles render time capture status
  49306. */
  49307. /**
  49308. * Enable or disable the particles render time capture
  49309. */
  49310. captureParticlesRenderTime: boolean;
  49311. /**
  49312. * Gets the perf counter used for sprites render time
  49313. */
  49314. readonly spritesRenderTimeCounter: PerfCounter;
  49315. /**
  49316. * Gets the sprites render time capture status
  49317. */
  49318. /**
  49319. * Enable or disable the sprites render time capture
  49320. */
  49321. captureSpritesRenderTime: boolean;
  49322. /**
  49323. * Gets the perf counter used for physics time
  49324. */
  49325. readonly physicsTimeCounter: PerfCounter;
  49326. /**
  49327. * Gets the physics time capture status
  49328. */
  49329. /**
  49330. * Enable or disable the physics time capture
  49331. */
  49332. capturePhysicsTime: boolean;
  49333. /**
  49334. * Gets the perf counter used for animations time
  49335. */
  49336. readonly animationsTimeCounter: PerfCounter;
  49337. /**
  49338. * Gets the animations time capture status
  49339. */
  49340. /**
  49341. * Enable or disable the animations time capture
  49342. */
  49343. captureAnimationsTime: boolean;
  49344. /**
  49345. * Gets the perf counter used for frame time capture
  49346. */
  49347. readonly frameTimeCounter: PerfCounter;
  49348. /**
  49349. * Gets the frame time capture status
  49350. */
  49351. /**
  49352. * Enable or disable the frame time capture
  49353. */
  49354. captureFrameTime: boolean;
  49355. /**
  49356. * Gets the perf counter used for inter-frames time capture
  49357. */
  49358. readonly interFrameTimeCounter: PerfCounter;
  49359. /**
  49360. * Gets the inter-frames time capture status
  49361. */
  49362. /**
  49363. * Enable or disable the inter-frames time capture
  49364. */
  49365. captureInterFrameTime: boolean;
  49366. /**
  49367. * Gets the perf counter used for render time capture
  49368. */
  49369. readonly renderTimeCounter: PerfCounter;
  49370. /**
  49371. * Gets the render time capture status
  49372. */
  49373. /**
  49374. * Enable or disable the render time capture
  49375. */
  49376. captureRenderTime: boolean;
  49377. /**
  49378. * Gets the perf counter used for camera render time capture
  49379. */
  49380. readonly cameraRenderTimeCounter: PerfCounter;
  49381. /**
  49382. * Gets the camera render time capture status
  49383. */
  49384. /**
  49385. * Enable or disable the camera render time capture
  49386. */
  49387. captureCameraRenderTime: boolean;
  49388. /**
  49389. * Gets the perf counter used for draw calls
  49390. */
  49391. readonly drawCallsCounter: PerfCounter;
  49392. /**
  49393. * Instantiates a new scene instrumentation.
  49394. * This class can be used to get instrumentation data from a Babylon engine
  49395. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49396. * @param scene Defines the scene to instrument
  49397. */
  49398. constructor(
  49399. /**
  49400. * Defines the scene to instrument
  49401. */
  49402. scene: Scene);
  49403. /**
  49404. * Dispose and release associated resources.
  49405. */
  49406. dispose(): void;
  49407. }
  49408. }
  49409. declare module "babylonjs/Instrumentation/index" {
  49410. export * from "babylonjs/Instrumentation/engineInstrumentation";
  49411. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  49412. export * from "babylonjs/Instrumentation/timeToken";
  49413. }
  49414. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  49415. /** @hidden */
  49416. export var glowMapGenerationPixelShader: {
  49417. name: string;
  49418. shader: string;
  49419. };
  49420. }
  49421. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  49422. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49423. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49424. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49425. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49426. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49427. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49428. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49429. /** @hidden */
  49430. export var glowMapGenerationVertexShader: {
  49431. name: string;
  49432. shader: string;
  49433. };
  49434. }
  49435. declare module "babylonjs/Layers/effectLayer" {
  49436. import { Observable } from "babylonjs/Misc/observable";
  49437. import { Nullable } from "babylonjs/types";
  49438. import { Camera } from "babylonjs/Cameras/camera";
  49439. import { Scene } from "babylonjs/scene";
  49440. import { Color4, ISize } from "babylonjs/Maths/math";
  49441. import { Engine } from "babylonjs/Engines/engine";
  49442. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49443. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49444. import { Mesh } from "babylonjs/Meshes/mesh";
  49445. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  49446. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49447. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49448. import { Effect } from "babylonjs/Materials/effect";
  49449. import { Material } from "babylonjs/Materials/material";
  49450. import "babylonjs/Shaders/glowMapGeneration.fragment";
  49451. import "babylonjs/Shaders/glowMapGeneration.vertex";
  49452. /**
  49453. * Effect layer options. This helps customizing the behaviour
  49454. * of the effect layer.
  49455. */
  49456. export interface IEffectLayerOptions {
  49457. /**
  49458. * Multiplication factor apply to the canvas size to compute the render target size
  49459. * used to generated the objects (the smaller the faster).
  49460. */
  49461. mainTextureRatio: number;
  49462. /**
  49463. * Enforces a fixed size texture to ensure effect stability across devices.
  49464. */
  49465. mainTextureFixedSize?: number;
  49466. /**
  49467. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49468. */
  49469. alphaBlendingMode: number;
  49470. /**
  49471. * The camera attached to the layer.
  49472. */
  49473. camera: Nullable<Camera>;
  49474. /**
  49475. * The rendering group to draw the layer in.
  49476. */
  49477. renderingGroupId: number;
  49478. }
  49479. /**
  49480. * The effect layer Helps adding post process effect blended with the main pass.
  49481. *
  49482. * This can be for instance use to generate glow or higlight effects on the scene.
  49483. *
  49484. * The effect layer class can not be used directly and is intented to inherited from to be
  49485. * customized per effects.
  49486. */
  49487. export abstract class EffectLayer {
  49488. private _vertexBuffers;
  49489. private _indexBuffer;
  49490. private _cachedDefines;
  49491. private _effectLayerMapGenerationEffect;
  49492. private _effectLayerOptions;
  49493. private _mergeEffect;
  49494. protected _scene: Scene;
  49495. protected _engine: Engine;
  49496. protected _maxSize: number;
  49497. protected _mainTextureDesiredSize: ISize;
  49498. protected _mainTexture: RenderTargetTexture;
  49499. protected _shouldRender: boolean;
  49500. protected _postProcesses: PostProcess[];
  49501. protected _textures: BaseTexture[];
  49502. protected _emissiveTextureAndColor: {
  49503. texture: Nullable<BaseTexture>;
  49504. color: Color4;
  49505. };
  49506. /**
  49507. * The name of the layer
  49508. */
  49509. name: string;
  49510. /**
  49511. * The clear color of the texture used to generate the glow map.
  49512. */
  49513. neutralColor: Color4;
  49514. /**
  49515. * Specifies wether the highlight layer is enabled or not.
  49516. */
  49517. isEnabled: boolean;
  49518. /**
  49519. * Gets the camera attached to the layer.
  49520. */
  49521. readonly camera: Nullable<Camera>;
  49522. /**
  49523. * Gets the rendering group id the layer should render in.
  49524. */
  49525. renderingGroupId: number;
  49526. /**
  49527. * An event triggered when the effect layer has been disposed.
  49528. */
  49529. onDisposeObservable: Observable<EffectLayer>;
  49530. /**
  49531. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  49532. */
  49533. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  49534. /**
  49535. * An event triggered when the generated texture is being merged in the scene.
  49536. */
  49537. onBeforeComposeObservable: Observable<EffectLayer>;
  49538. /**
  49539. * An event triggered when the generated texture has been merged in the scene.
  49540. */
  49541. onAfterComposeObservable: Observable<EffectLayer>;
  49542. /**
  49543. * An event triggered when the efffect layer changes its size.
  49544. */
  49545. onSizeChangedObservable: Observable<EffectLayer>;
  49546. /** @hidden */
  49547. static _SceneComponentInitialization: (scene: Scene) => void;
  49548. /**
  49549. * Instantiates a new effect Layer and references it in the scene.
  49550. * @param name The name of the layer
  49551. * @param scene The scene to use the layer in
  49552. */
  49553. constructor(
  49554. /** The Friendly of the effect in the scene */
  49555. name: string, scene: Scene);
  49556. /**
  49557. * Get the effect name of the layer.
  49558. * @return The effect name
  49559. */
  49560. abstract getEffectName(): string;
  49561. /**
  49562. * Checks for the readiness of the element composing the layer.
  49563. * @param subMesh the mesh to check for
  49564. * @param useInstances specify wether or not to use instances to render the mesh
  49565. * @return true if ready otherwise, false
  49566. */
  49567. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49568. /**
  49569. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49570. * @returns true if the effect requires stencil during the main canvas render pass.
  49571. */
  49572. abstract needStencil(): boolean;
  49573. /**
  49574. * Create the merge effect. This is the shader use to blit the information back
  49575. * to the main canvas at the end of the scene rendering.
  49576. * @returns The effect containing the shader used to merge the effect on the main canvas
  49577. */
  49578. protected abstract _createMergeEffect(): Effect;
  49579. /**
  49580. * Creates the render target textures and post processes used in the effect layer.
  49581. */
  49582. protected abstract _createTextureAndPostProcesses(): void;
  49583. /**
  49584. * Implementation specific of rendering the generating effect on the main canvas.
  49585. * @param effect The effect used to render through
  49586. */
  49587. protected abstract _internalRender(effect: Effect): void;
  49588. /**
  49589. * Sets the required values for both the emissive texture and and the main color.
  49590. */
  49591. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49592. /**
  49593. * Free any resources and references associated to a mesh.
  49594. * Internal use
  49595. * @param mesh The mesh to free.
  49596. */
  49597. abstract _disposeMesh(mesh: Mesh): void;
  49598. /**
  49599. * Serializes this layer (Glow or Highlight for example)
  49600. * @returns a serialized layer object
  49601. */
  49602. abstract serialize?(): any;
  49603. /**
  49604. * Initializes the effect layer with the required options.
  49605. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  49606. */
  49607. protected _init(options: Partial<IEffectLayerOptions>): void;
  49608. /**
  49609. * Generates the index buffer of the full screen quad blending to the main canvas.
  49610. */
  49611. private _generateIndexBuffer;
  49612. /**
  49613. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  49614. */
  49615. private _generateVertexBuffer;
  49616. /**
  49617. * Sets the main texture desired size which is the closest power of two
  49618. * of the engine canvas size.
  49619. */
  49620. private _setMainTextureSize;
  49621. /**
  49622. * Creates the main texture for the effect layer.
  49623. */
  49624. protected _createMainTexture(): void;
  49625. /**
  49626. * Adds specific effects defines.
  49627. * @param defines The defines to add specifics to.
  49628. */
  49629. protected _addCustomEffectDefines(defines: string[]): void;
  49630. /**
  49631. * Checks for the readiness of the element composing the layer.
  49632. * @param subMesh the mesh to check for
  49633. * @param useInstances specify wether or not to use instances to render the mesh
  49634. * @param emissiveTexture the associated emissive texture used to generate the glow
  49635. * @return true if ready otherwise, false
  49636. */
  49637. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49638. /**
  49639. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49640. */
  49641. render(): void;
  49642. /**
  49643. * Determine if a given mesh will be used in the current effect.
  49644. * @param mesh mesh to test
  49645. * @returns true if the mesh will be used
  49646. */
  49647. hasMesh(mesh: AbstractMesh): boolean;
  49648. /**
  49649. * Returns true if the layer contains information to display, otherwise false.
  49650. * @returns true if the glow layer should be rendered
  49651. */
  49652. shouldRender(): boolean;
  49653. /**
  49654. * Returns true if the mesh should render, otherwise false.
  49655. * @param mesh The mesh to render
  49656. * @returns true if it should render otherwise false
  49657. */
  49658. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49659. /**
  49660. * Returns true if the mesh can be rendered, otherwise false.
  49661. * @param mesh The mesh to render
  49662. * @param material The material used on the mesh
  49663. * @returns true if it can be rendered otherwise false
  49664. */
  49665. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49666. /**
  49667. * Returns true if the mesh should render, otherwise false.
  49668. * @param mesh The mesh to render
  49669. * @returns true if it should render otherwise false
  49670. */
  49671. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49672. /**
  49673. * Renders the submesh passed in parameter to the generation map.
  49674. */
  49675. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49676. /**
  49677. * Rebuild the required buffers.
  49678. * @hidden Internal use only.
  49679. */
  49680. _rebuild(): void;
  49681. /**
  49682. * Dispose only the render target textures and post process.
  49683. */
  49684. private _disposeTextureAndPostProcesses;
  49685. /**
  49686. * Dispose the highlight layer and free resources.
  49687. */
  49688. dispose(): void;
  49689. /**
  49690. * Gets the class name of the effect layer
  49691. * @returns the string with the class name of the effect layer
  49692. */
  49693. getClassName(): string;
  49694. /**
  49695. * Creates an effect layer from parsed effect layer data
  49696. * @param parsedEffectLayer defines effect layer data
  49697. * @param scene defines the current scene
  49698. * @param rootUrl defines the root URL containing the effect layer information
  49699. * @returns a parsed effect Layer
  49700. */
  49701. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49702. }
  49703. }
  49704. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  49705. import { Scene } from "babylonjs/scene";
  49706. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49707. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49708. import { AbstractScene } from "babylonjs/abstractScene";
  49709. module "babylonjs/abstractScene" {
  49710. interface AbstractScene {
  49711. /**
  49712. * The list of effect layers (highlights/glow) added to the scene
  49713. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49714. * @see http://doc.babylonjs.com/how_to/glow_layer
  49715. */
  49716. effectLayers: Array<EffectLayer>;
  49717. /**
  49718. * Removes the given effect layer from this scene.
  49719. * @param toRemove defines the effect layer to remove
  49720. * @returns the index of the removed effect layer
  49721. */
  49722. removeEffectLayer(toRemove: EffectLayer): number;
  49723. /**
  49724. * Adds the given effect layer to this scene
  49725. * @param newEffectLayer defines the effect layer to add
  49726. */
  49727. addEffectLayer(newEffectLayer: EffectLayer): void;
  49728. }
  49729. }
  49730. /**
  49731. * Defines the layer scene component responsible to manage any effect layers
  49732. * in a given scene.
  49733. */
  49734. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49735. /**
  49736. * The component name helpfull to identify the component in the list of scene components.
  49737. */
  49738. readonly name: string;
  49739. /**
  49740. * The scene the component belongs to.
  49741. */
  49742. scene: Scene;
  49743. private _engine;
  49744. private _renderEffects;
  49745. private _needStencil;
  49746. private _previousStencilState;
  49747. /**
  49748. * Creates a new instance of the component for the given scene
  49749. * @param scene Defines the scene to register the component in
  49750. */
  49751. constructor(scene: Scene);
  49752. /**
  49753. * Registers the component in a given scene
  49754. */
  49755. register(): void;
  49756. /**
  49757. * Rebuilds the elements related to this component in case of
  49758. * context lost for instance.
  49759. */
  49760. rebuild(): void;
  49761. /**
  49762. * Serializes the component data to the specified json object
  49763. * @param serializationObject The object to serialize to
  49764. */
  49765. serialize(serializationObject: any): void;
  49766. /**
  49767. * Adds all the elements from the container to the scene
  49768. * @param container the container holding the elements
  49769. */
  49770. addFromContainer(container: AbstractScene): void;
  49771. /**
  49772. * Removes all the elements in the container from the scene
  49773. * @param container contains the elements to remove
  49774. * @param dispose if the removed element should be disposed (default: false)
  49775. */
  49776. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49777. /**
  49778. * Disposes the component and the associated ressources.
  49779. */
  49780. dispose(): void;
  49781. private _isReadyForMesh;
  49782. private _renderMainTexture;
  49783. private _setStencil;
  49784. private _setStencilBack;
  49785. private _draw;
  49786. private _drawCamera;
  49787. private _drawRenderingGroup;
  49788. }
  49789. }
  49790. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  49791. /** @hidden */
  49792. export var glowMapMergePixelShader: {
  49793. name: string;
  49794. shader: string;
  49795. };
  49796. }
  49797. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  49798. /** @hidden */
  49799. export var glowMapMergeVertexShader: {
  49800. name: string;
  49801. shader: string;
  49802. };
  49803. }
  49804. declare module "babylonjs/Layers/glowLayer" {
  49805. import { Nullable } from "babylonjs/types";
  49806. import { Camera } from "babylonjs/Cameras/camera";
  49807. import { Scene } from "babylonjs/scene";
  49808. import { Color4 } from "babylonjs/Maths/math";
  49809. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49810. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49811. import { Mesh } from "babylonjs/Meshes/mesh";
  49812. import { Texture } from "babylonjs/Materials/Textures/texture";
  49813. import { Effect } from "babylonjs/Materials/effect";
  49814. import { Material } from "babylonjs/Materials/material";
  49815. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49816. import "babylonjs/Shaders/glowMapMerge.fragment";
  49817. import "babylonjs/Shaders/glowMapMerge.vertex";
  49818. import "babylonjs/Layers/effectLayerSceneComponent";
  49819. module "babylonjs/abstractScene" {
  49820. interface AbstractScene {
  49821. /**
  49822. * Return a the first highlight layer of the scene with a given name.
  49823. * @param name The name of the highlight layer to look for.
  49824. * @return The highlight layer if found otherwise null.
  49825. */
  49826. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49827. }
  49828. }
  49829. /**
  49830. * Glow layer options. This helps customizing the behaviour
  49831. * of the glow layer.
  49832. */
  49833. export interface IGlowLayerOptions {
  49834. /**
  49835. * Multiplication factor apply to the canvas size to compute the render target size
  49836. * used to generated the glowing objects (the smaller the faster).
  49837. */
  49838. mainTextureRatio: number;
  49839. /**
  49840. * Enforces a fixed size texture to ensure resize independant blur.
  49841. */
  49842. mainTextureFixedSize?: number;
  49843. /**
  49844. * How big is the kernel of the blur texture.
  49845. */
  49846. blurKernelSize: number;
  49847. /**
  49848. * The camera attached to the layer.
  49849. */
  49850. camera: Nullable<Camera>;
  49851. /**
  49852. * Enable MSAA by chosing the number of samples.
  49853. */
  49854. mainTextureSamples?: number;
  49855. /**
  49856. * The rendering group to draw the layer in.
  49857. */
  49858. renderingGroupId: number;
  49859. }
  49860. /**
  49861. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49862. *
  49863. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49864. * glowy meshes to your scene.
  49865. *
  49866. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49867. */
  49868. export class GlowLayer extends EffectLayer {
  49869. /**
  49870. * Effect Name of the layer.
  49871. */
  49872. static readonly EffectName: string;
  49873. /**
  49874. * The default blur kernel size used for the glow.
  49875. */
  49876. static DefaultBlurKernelSize: number;
  49877. /**
  49878. * The default texture size ratio used for the glow.
  49879. */
  49880. static DefaultTextureRatio: number;
  49881. /**
  49882. * Sets the kernel size of the blur.
  49883. */
  49884. /**
  49885. * Gets the kernel size of the blur.
  49886. */
  49887. blurKernelSize: number;
  49888. /**
  49889. * Sets the glow intensity.
  49890. */
  49891. /**
  49892. * Gets the glow intensity.
  49893. */
  49894. intensity: number;
  49895. private _options;
  49896. private _intensity;
  49897. private _horizontalBlurPostprocess1;
  49898. private _verticalBlurPostprocess1;
  49899. private _horizontalBlurPostprocess2;
  49900. private _verticalBlurPostprocess2;
  49901. private _blurTexture1;
  49902. private _blurTexture2;
  49903. private _postProcesses1;
  49904. private _postProcesses2;
  49905. private _includedOnlyMeshes;
  49906. private _excludedMeshes;
  49907. /**
  49908. * Callback used to let the user override the color selection on a per mesh basis
  49909. */
  49910. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49911. /**
  49912. * Callback used to let the user override the texture selection on a per mesh basis
  49913. */
  49914. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49915. /**
  49916. * Instantiates a new glow Layer and references it to the scene.
  49917. * @param name The name of the layer
  49918. * @param scene The scene to use the layer in
  49919. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49920. */
  49921. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49922. /**
  49923. * Get the effect name of the layer.
  49924. * @return The effect name
  49925. */
  49926. getEffectName(): string;
  49927. /**
  49928. * Create the merge effect. This is the shader use to blit the information back
  49929. * to the main canvas at the end of the scene rendering.
  49930. */
  49931. protected _createMergeEffect(): Effect;
  49932. /**
  49933. * Creates the render target textures and post processes used in the glow layer.
  49934. */
  49935. protected _createTextureAndPostProcesses(): void;
  49936. /**
  49937. * Checks for the readiness of the element composing the layer.
  49938. * @param subMesh the mesh to check for
  49939. * @param useInstances specify wether or not to use instances to render the mesh
  49940. * @param emissiveTexture the associated emissive texture used to generate the glow
  49941. * @return true if ready otherwise, false
  49942. */
  49943. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49944. /**
  49945. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49946. */
  49947. needStencil(): boolean;
  49948. /**
  49949. * Returns true if the mesh can be rendered, otherwise false.
  49950. * @param mesh The mesh to render
  49951. * @param material The material used on the mesh
  49952. * @returns true if it can be rendered otherwise false
  49953. */
  49954. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49955. /**
  49956. * Implementation specific of rendering the generating effect on the main canvas.
  49957. * @param effect The effect used to render through
  49958. */
  49959. protected _internalRender(effect: Effect): void;
  49960. /**
  49961. * Sets the required values for both the emissive texture and and the main color.
  49962. */
  49963. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49964. /**
  49965. * Returns true if the mesh should render, otherwise false.
  49966. * @param mesh The mesh to render
  49967. * @returns true if it should render otherwise false
  49968. */
  49969. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49970. /**
  49971. * Adds specific effects defines.
  49972. * @param defines The defines to add specifics to.
  49973. */
  49974. protected _addCustomEffectDefines(defines: string[]): void;
  49975. /**
  49976. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49977. * @param mesh The mesh to exclude from the glow layer
  49978. */
  49979. addExcludedMesh(mesh: Mesh): void;
  49980. /**
  49981. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49982. * @param mesh The mesh to remove
  49983. */
  49984. removeExcludedMesh(mesh: Mesh): void;
  49985. /**
  49986. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49987. * @param mesh The mesh to include in the glow layer
  49988. */
  49989. addIncludedOnlyMesh(mesh: Mesh): void;
  49990. /**
  49991. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49992. * @param mesh The mesh to remove
  49993. */
  49994. removeIncludedOnlyMesh(mesh: Mesh): void;
  49995. /**
  49996. * Determine if a given mesh will be used in the glow layer
  49997. * @param mesh The mesh to test
  49998. * @returns true if the mesh will be highlighted by the current glow layer
  49999. */
  50000. hasMesh(mesh: AbstractMesh): boolean;
  50001. /**
  50002. * Free any resources and references associated to a mesh.
  50003. * Internal use
  50004. * @param mesh The mesh to free.
  50005. * @hidden
  50006. */
  50007. _disposeMesh(mesh: Mesh): void;
  50008. /**
  50009. * Gets the class name of the effect layer
  50010. * @returns the string with the class name of the effect layer
  50011. */
  50012. getClassName(): string;
  50013. /**
  50014. * Serializes this glow layer
  50015. * @returns a serialized glow layer object
  50016. */
  50017. serialize(): any;
  50018. /**
  50019. * Creates a Glow Layer from parsed glow layer data
  50020. * @param parsedGlowLayer defines glow layer data
  50021. * @param scene defines the current scene
  50022. * @param rootUrl defines the root URL containing the glow layer information
  50023. * @returns a parsed Glow Layer
  50024. */
  50025. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  50026. }
  50027. }
  50028. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  50029. /** @hidden */
  50030. export var glowBlurPostProcessPixelShader: {
  50031. name: string;
  50032. shader: string;
  50033. };
  50034. }
  50035. declare module "babylonjs/Layers/highlightLayer" {
  50036. import { Observable } from "babylonjs/Misc/observable";
  50037. import { Nullable } from "babylonjs/types";
  50038. import { Camera } from "babylonjs/Cameras/camera";
  50039. import { Scene } from "babylonjs/scene";
  50040. import { Color3, Color4 } from "babylonjs/Maths/math";
  50041. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50043. import { Mesh } from "babylonjs/Meshes/mesh";
  50044. import { Effect } from "babylonjs/Materials/effect";
  50045. import { Material } from "babylonjs/Materials/material";
  50046. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50047. import "babylonjs/Shaders/glowMapMerge.fragment";
  50048. import "babylonjs/Shaders/glowMapMerge.vertex";
  50049. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  50050. module "babylonjs/abstractScene" {
  50051. interface AbstractScene {
  50052. /**
  50053. * Return a the first highlight layer of the scene with a given name.
  50054. * @param name The name of the highlight layer to look for.
  50055. * @return The highlight layer if found otherwise null.
  50056. */
  50057. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  50058. }
  50059. }
  50060. /**
  50061. * Highlight layer options. This helps customizing the behaviour
  50062. * of the highlight layer.
  50063. */
  50064. export interface IHighlightLayerOptions {
  50065. /**
  50066. * Multiplication factor apply to the canvas size to compute the render target size
  50067. * used to generated the glowing objects (the smaller the faster).
  50068. */
  50069. mainTextureRatio: number;
  50070. /**
  50071. * Enforces a fixed size texture to ensure resize independant blur.
  50072. */
  50073. mainTextureFixedSize?: number;
  50074. /**
  50075. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  50076. * of the picture to blur (the smaller the faster).
  50077. */
  50078. blurTextureSizeRatio: number;
  50079. /**
  50080. * How big in texel of the blur texture is the vertical blur.
  50081. */
  50082. blurVerticalSize: number;
  50083. /**
  50084. * How big in texel of the blur texture is the horizontal blur.
  50085. */
  50086. blurHorizontalSize: number;
  50087. /**
  50088. * Alpha blending mode used to apply the blur. Default is combine.
  50089. */
  50090. alphaBlendingMode: number;
  50091. /**
  50092. * The camera attached to the layer.
  50093. */
  50094. camera: Nullable<Camera>;
  50095. /**
  50096. * Should we display highlight as a solid stroke?
  50097. */
  50098. isStroke?: boolean;
  50099. /**
  50100. * The rendering group to draw the layer in.
  50101. */
  50102. renderingGroupId: number;
  50103. }
  50104. /**
  50105. * The highlight layer Helps adding a glow effect around a mesh.
  50106. *
  50107. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50108. * glowy meshes to your scene.
  50109. *
  50110. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  50111. */
  50112. export class HighlightLayer extends EffectLayer {
  50113. name: string;
  50114. /**
  50115. * Effect Name of the highlight layer.
  50116. */
  50117. static readonly EffectName: string;
  50118. /**
  50119. * The neutral color used during the preparation of the glow effect.
  50120. * This is black by default as the blend operation is a blend operation.
  50121. */
  50122. static NeutralColor: Color4;
  50123. /**
  50124. * Stencil value used for glowing meshes.
  50125. */
  50126. static GlowingMeshStencilReference: number;
  50127. /**
  50128. * Stencil value used for the other meshes in the scene.
  50129. */
  50130. static NormalMeshStencilReference: number;
  50131. /**
  50132. * Specifies whether or not the inner glow is ACTIVE in the layer.
  50133. */
  50134. innerGlow: boolean;
  50135. /**
  50136. * Specifies whether or not the outer glow is ACTIVE in the layer.
  50137. */
  50138. outerGlow: boolean;
  50139. /**
  50140. * Specifies the horizontal size of the blur.
  50141. */
  50142. /**
  50143. * Gets the horizontal size of the blur.
  50144. */
  50145. blurHorizontalSize: number;
  50146. /**
  50147. * Specifies the vertical size of the blur.
  50148. */
  50149. /**
  50150. * Gets the vertical size of the blur.
  50151. */
  50152. blurVerticalSize: number;
  50153. /**
  50154. * An event triggered when the highlight layer is being blurred.
  50155. */
  50156. onBeforeBlurObservable: Observable<HighlightLayer>;
  50157. /**
  50158. * An event triggered when the highlight layer has been blurred.
  50159. */
  50160. onAfterBlurObservable: Observable<HighlightLayer>;
  50161. private _instanceGlowingMeshStencilReference;
  50162. private _options;
  50163. private _downSamplePostprocess;
  50164. private _horizontalBlurPostprocess;
  50165. private _verticalBlurPostprocess;
  50166. private _blurTexture;
  50167. private _meshes;
  50168. private _excludedMeshes;
  50169. /**
  50170. * Instantiates a new highlight Layer and references it to the scene..
  50171. * @param name The name of the layer
  50172. * @param scene The scene to use the layer in
  50173. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  50174. */
  50175. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  50176. /**
  50177. * Get the effect name of the layer.
  50178. * @return The effect name
  50179. */
  50180. getEffectName(): string;
  50181. /**
  50182. * Create the merge effect. This is the shader use to blit the information back
  50183. * to the main canvas at the end of the scene rendering.
  50184. */
  50185. protected _createMergeEffect(): Effect;
  50186. /**
  50187. * Creates the render target textures and post processes used in the highlight layer.
  50188. */
  50189. protected _createTextureAndPostProcesses(): void;
  50190. /**
  50191. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50192. */
  50193. needStencil(): boolean;
  50194. /**
  50195. * Checks for the readiness of the element composing the layer.
  50196. * @param subMesh the mesh to check for
  50197. * @param useInstances specify wether or not to use instances to render the mesh
  50198. * @param emissiveTexture the associated emissive texture used to generate the glow
  50199. * @return true if ready otherwise, false
  50200. */
  50201. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50202. /**
  50203. * Implementation specific of rendering the generating effect on the main canvas.
  50204. * @param effect The effect used to render through
  50205. */
  50206. protected _internalRender(effect: Effect): void;
  50207. /**
  50208. * Returns true if the layer contains information to display, otherwise false.
  50209. */
  50210. shouldRender(): boolean;
  50211. /**
  50212. * Returns true if the mesh should render, otherwise false.
  50213. * @param mesh The mesh to render
  50214. * @returns true if it should render otherwise false
  50215. */
  50216. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50217. /**
  50218. * Sets the required values for both the emissive texture and and the main color.
  50219. */
  50220. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50221. /**
  50222. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  50223. * @param mesh The mesh to exclude from the highlight layer
  50224. */
  50225. addExcludedMesh(mesh: Mesh): void;
  50226. /**
  50227. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  50228. * @param mesh The mesh to highlight
  50229. */
  50230. removeExcludedMesh(mesh: Mesh): void;
  50231. /**
  50232. * Determine if a given mesh will be highlighted by the current HighlightLayer
  50233. * @param mesh mesh to test
  50234. * @returns true if the mesh will be highlighted by the current HighlightLayer
  50235. */
  50236. hasMesh(mesh: AbstractMesh): boolean;
  50237. /**
  50238. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  50239. * @param mesh The mesh to highlight
  50240. * @param color The color of the highlight
  50241. * @param glowEmissiveOnly Extract the glow from the emissive texture
  50242. */
  50243. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  50244. /**
  50245. * Remove a mesh from the highlight layer in order to make it stop glowing.
  50246. * @param mesh The mesh to highlight
  50247. */
  50248. removeMesh(mesh: Mesh): void;
  50249. /**
  50250. * Force the stencil to the normal expected value for none glowing parts
  50251. */
  50252. private _defaultStencilReference;
  50253. /**
  50254. * Free any resources and references associated to a mesh.
  50255. * Internal use
  50256. * @param mesh The mesh to free.
  50257. * @hidden
  50258. */
  50259. _disposeMesh(mesh: Mesh): void;
  50260. /**
  50261. * Dispose the highlight layer and free resources.
  50262. */
  50263. dispose(): void;
  50264. /**
  50265. * Gets the class name of the effect layer
  50266. * @returns the string with the class name of the effect layer
  50267. */
  50268. getClassName(): string;
  50269. /**
  50270. * Serializes this Highlight layer
  50271. * @returns a serialized Highlight layer object
  50272. */
  50273. serialize(): any;
  50274. /**
  50275. * Creates a Highlight layer from parsed Highlight layer data
  50276. * @param parsedHightlightLayer defines the Highlight layer data
  50277. * @param scene defines the current scene
  50278. * @param rootUrl defines the root URL containing the Highlight layer information
  50279. * @returns a parsed Highlight layer
  50280. */
  50281. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50282. }
  50283. }
  50284. declare module "babylonjs/Layers/layerSceneComponent" {
  50285. import { Scene } from "babylonjs/scene";
  50286. import { ISceneComponent } from "babylonjs/sceneComponent";
  50287. import { Layer } from "babylonjs/Layers/layer";
  50288. import { AbstractScene } from "babylonjs/abstractScene";
  50289. module "babylonjs/abstractScene" {
  50290. interface AbstractScene {
  50291. /**
  50292. * The list of layers (background and foreground) of the scene
  50293. */
  50294. layers: Array<Layer>;
  50295. }
  50296. }
  50297. /**
  50298. * Defines the layer scene component responsible to manage any layers
  50299. * in a given scene.
  50300. */
  50301. export class LayerSceneComponent implements ISceneComponent {
  50302. /**
  50303. * The component name helpfull to identify the component in the list of scene components.
  50304. */
  50305. readonly name: string;
  50306. /**
  50307. * The scene the component belongs to.
  50308. */
  50309. scene: Scene;
  50310. private _engine;
  50311. /**
  50312. * Creates a new instance of the component for the given scene
  50313. * @param scene Defines the scene to register the component in
  50314. */
  50315. constructor(scene: Scene);
  50316. /**
  50317. * Registers the component in a given scene
  50318. */
  50319. register(): void;
  50320. /**
  50321. * Rebuilds the elements related to this component in case of
  50322. * context lost for instance.
  50323. */
  50324. rebuild(): void;
  50325. /**
  50326. * Disposes the component and the associated ressources.
  50327. */
  50328. dispose(): void;
  50329. private _draw;
  50330. private _drawCameraPredicate;
  50331. private _drawCameraBackground;
  50332. private _drawCameraForeground;
  50333. private _drawRenderTargetPredicate;
  50334. private _drawRenderTargetBackground;
  50335. private _drawRenderTargetForeground;
  50336. /**
  50337. * Adds all the elements from the container to the scene
  50338. * @param container the container holding the elements
  50339. */
  50340. addFromContainer(container: AbstractScene): void;
  50341. /**
  50342. * Removes all the elements in the container from the scene
  50343. * @param container contains the elements to remove
  50344. * @param dispose if the removed element should be disposed (default: false)
  50345. */
  50346. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50347. }
  50348. }
  50349. declare module "babylonjs/Shaders/layer.fragment" {
  50350. /** @hidden */
  50351. export var layerPixelShader: {
  50352. name: string;
  50353. shader: string;
  50354. };
  50355. }
  50356. declare module "babylonjs/Shaders/layer.vertex" {
  50357. /** @hidden */
  50358. export var layerVertexShader: {
  50359. name: string;
  50360. shader: string;
  50361. };
  50362. }
  50363. declare module "babylonjs/Layers/layer" {
  50364. import { Observable } from "babylonjs/Misc/observable";
  50365. import { Nullable } from "babylonjs/types";
  50366. import { Scene } from "babylonjs/scene";
  50367. import { Vector2, Color4 } from "babylonjs/Maths/math";
  50368. import { Texture } from "babylonjs/Materials/Textures/texture";
  50369. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50370. import "babylonjs/Shaders/layer.fragment";
  50371. import "babylonjs/Shaders/layer.vertex";
  50372. /**
  50373. * This represents a full screen 2d layer.
  50374. * This can be useful to display a picture in the background of your scene for instance.
  50375. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50376. */
  50377. export class Layer {
  50378. /**
  50379. * Define the name of the layer.
  50380. */
  50381. name: string;
  50382. /**
  50383. * Define the texture the layer should display.
  50384. */
  50385. texture: Nullable<Texture>;
  50386. /**
  50387. * Is the layer in background or foreground.
  50388. */
  50389. isBackground: boolean;
  50390. /**
  50391. * Define the color of the layer (instead of texture).
  50392. */
  50393. color: Color4;
  50394. /**
  50395. * Define the scale of the layer in order to zoom in out of the texture.
  50396. */
  50397. scale: Vector2;
  50398. /**
  50399. * Define an offset for the layer in order to shift the texture.
  50400. */
  50401. offset: Vector2;
  50402. /**
  50403. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50404. */
  50405. alphaBlendingMode: number;
  50406. /**
  50407. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50408. * Alpha test will not mix with the background color in case of transparency.
  50409. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50410. */
  50411. alphaTest: boolean;
  50412. /**
  50413. * Define a mask to restrict the layer to only some of the scene cameras.
  50414. */
  50415. layerMask: number;
  50416. /**
  50417. * Define the list of render target the layer is visible into.
  50418. */
  50419. renderTargetTextures: RenderTargetTexture[];
  50420. /**
  50421. * Define if the layer is only used in renderTarget or if it also
  50422. * renders in the main frame buffer of the canvas.
  50423. */
  50424. renderOnlyInRenderTargetTextures: boolean;
  50425. private _scene;
  50426. private _vertexBuffers;
  50427. private _indexBuffer;
  50428. private _effect;
  50429. private _alphaTestEffect;
  50430. /**
  50431. * An event triggered when the layer is disposed.
  50432. */
  50433. onDisposeObservable: Observable<Layer>;
  50434. private _onDisposeObserver;
  50435. /**
  50436. * Back compatibility with callback before the onDisposeObservable existed.
  50437. * The set callback will be triggered when the layer has been disposed.
  50438. */
  50439. onDispose: () => void;
  50440. /**
  50441. * An event triggered before rendering the scene
  50442. */
  50443. onBeforeRenderObservable: Observable<Layer>;
  50444. private _onBeforeRenderObserver;
  50445. /**
  50446. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50447. * The set callback will be triggered just before rendering the layer.
  50448. */
  50449. onBeforeRender: () => void;
  50450. /**
  50451. * An event triggered after rendering the scene
  50452. */
  50453. onAfterRenderObservable: Observable<Layer>;
  50454. private _onAfterRenderObserver;
  50455. /**
  50456. * Back compatibility with callback before the onAfterRenderObservable existed.
  50457. * The set callback will be triggered just after rendering the layer.
  50458. */
  50459. onAfterRender: () => void;
  50460. /**
  50461. * Instantiates a new layer.
  50462. * This represents a full screen 2d layer.
  50463. * This can be useful to display a picture in the background of your scene for instance.
  50464. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50465. * @param name Define the name of the layer in the scene
  50466. * @param imgUrl Define the url of the texture to display in the layer
  50467. * @param scene Define the scene the layer belongs to
  50468. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50469. * @param color Defines a color for the layer
  50470. */
  50471. constructor(
  50472. /**
  50473. * Define the name of the layer.
  50474. */
  50475. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50476. private _createIndexBuffer;
  50477. /** @hidden */
  50478. _rebuild(): void;
  50479. /**
  50480. * Renders the layer in the scene.
  50481. */
  50482. render(): void;
  50483. /**
  50484. * Disposes and releases the associated ressources.
  50485. */
  50486. dispose(): void;
  50487. }
  50488. }
  50489. declare module "babylonjs/Layers/index" {
  50490. export * from "babylonjs/Layers/effectLayer";
  50491. export * from "babylonjs/Layers/effectLayerSceneComponent";
  50492. export * from "babylonjs/Layers/glowLayer";
  50493. export * from "babylonjs/Layers/highlightLayer";
  50494. export * from "babylonjs/Layers/layer";
  50495. export * from "babylonjs/Layers/layerSceneComponent";
  50496. }
  50497. declare module "babylonjs/Shaders/lensFlare.fragment" {
  50498. /** @hidden */
  50499. export var lensFlarePixelShader: {
  50500. name: string;
  50501. shader: string;
  50502. };
  50503. }
  50504. declare module "babylonjs/Shaders/lensFlare.vertex" {
  50505. /** @hidden */
  50506. export var lensFlareVertexShader: {
  50507. name: string;
  50508. shader: string;
  50509. };
  50510. }
  50511. declare module "babylonjs/LensFlares/lensFlareSystem" {
  50512. import { Scene } from "babylonjs/scene";
  50513. import { Vector3, Viewport } from "babylonjs/Maths/math";
  50514. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50515. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  50516. import "babylonjs/Shaders/lensFlare.fragment";
  50517. import "babylonjs/Shaders/lensFlare.vertex";
  50518. /**
  50519. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50520. * It is usually composed of several `lensFlare`.
  50521. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50522. */
  50523. export class LensFlareSystem {
  50524. /**
  50525. * Define the name of the lens flare system
  50526. */
  50527. name: string;
  50528. /**
  50529. * List of lens flares used in this system.
  50530. */
  50531. lensFlares: LensFlare[];
  50532. /**
  50533. * Define a limit from the border the lens flare can be visible.
  50534. */
  50535. borderLimit: number;
  50536. /**
  50537. * Define a viewport border we do not want to see the lens flare in.
  50538. */
  50539. viewportBorder: number;
  50540. /**
  50541. * Define a predicate which could limit the list of meshes able to occlude the effect.
  50542. */
  50543. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50544. /**
  50545. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  50546. */
  50547. layerMask: number;
  50548. /**
  50549. * Define the id of the lens flare system in the scene.
  50550. * (equal to name by default)
  50551. */
  50552. id: string;
  50553. private _scene;
  50554. private _emitter;
  50555. private _vertexBuffers;
  50556. private _indexBuffer;
  50557. private _effect;
  50558. private _positionX;
  50559. private _positionY;
  50560. private _isEnabled;
  50561. /** @hidden */
  50562. static _SceneComponentInitialization: (scene: Scene) => void;
  50563. /**
  50564. * Instantiates a lens flare system.
  50565. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50566. * It is usually composed of several `lensFlare`.
  50567. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50568. * @param name Define the name of the lens flare system in the scene
  50569. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  50570. * @param scene Define the scene the lens flare system belongs to
  50571. */
  50572. constructor(
  50573. /**
  50574. * Define the name of the lens flare system
  50575. */
  50576. name: string, emitter: any, scene: Scene);
  50577. /**
  50578. * Define if the lens flare system is enabled.
  50579. */
  50580. isEnabled: boolean;
  50581. /**
  50582. * Get the scene the effects belongs to.
  50583. * @returns the scene holding the lens flare system
  50584. */
  50585. getScene(): Scene;
  50586. /**
  50587. * Get the emitter of the lens flare system.
  50588. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50589. * @returns the emitter of the lens flare system
  50590. */
  50591. getEmitter(): any;
  50592. /**
  50593. * Set the emitter of the lens flare system.
  50594. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50595. * @param newEmitter Define the new emitter of the system
  50596. */
  50597. setEmitter(newEmitter: any): void;
  50598. /**
  50599. * Get the lens flare system emitter position.
  50600. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  50601. * @returns the position
  50602. */
  50603. getEmitterPosition(): Vector3;
  50604. /**
  50605. * @hidden
  50606. */
  50607. computeEffectivePosition(globalViewport: Viewport): boolean;
  50608. /** @hidden */
  50609. _isVisible(): boolean;
  50610. /**
  50611. * @hidden
  50612. */
  50613. render(): boolean;
  50614. /**
  50615. * Dispose and release the lens flare with its associated resources.
  50616. */
  50617. dispose(): void;
  50618. /**
  50619. * Parse a lens flare system from a JSON repressentation
  50620. * @param parsedLensFlareSystem Define the JSON to parse
  50621. * @param scene Define the scene the parsed system should be instantiated in
  50622. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  50623. * @returns the parsed system
  50624. */
  50625. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  50626. /**
  50627. * Serialize the current Lens Flare System into a JSON representation.
  50628. * @returns the serialized JSON
  50629. */
  50630. serialize(): any;
  50631. }
  50632. }
  50633. declare module "babylonjs/LensFlares/lensFlare" {
  50634. import { Nullable } from "babylonjs/types";
  50635. import { Color3 } from "babylonjs/Maths/math";
  50636. import { Texture } from "babylonjs/Materials/Textures/texture";
  50637. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50638. /**
  50639. * This represents one of the lens effect in a `lensFlareSystem`.
  50640. * It controls one of the indiviual texture used in the effect.
  50641. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50642. */
  50643. export class LensFlare {
  50644. /**
  50645. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50646. */
  50647. size: number;
  50648. /**
  50649. * 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.
  50650. */
  50651. position: number;
  50652. /**
  50653. * Define the lens color.
  50654. */
  50655. color: Color3;
  50656. /**
  50657. * Define the lens texture.
  50658. */
  50659. texture: Nullable<Texture>;
  50660. /**
  50661. * Define the alpha mode to render this particular lens.
  50662. */
  50663. alphaMode: number;
  50664. private _system;
  50665. /**
  50666. * Creates a new Lens Flare.
  50667. * This represents one of the lens effect in a `lensFlareSystem`.
  50668. * It controls one of the indiviual texture used in the effect.
  50669. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50670. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  50671. * @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.
  50672. * @param color Define the lens color
  50673. * @param imgUrl Define the lens texture url
  50674. * @param system Define the `lensFlareSystem` this flare is part of
  50675. * @returns The newly created Lens Flare
  50676. */
  50677. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  50678. /**
  50679. * Instantiates a new Lens Flare.
  50680. * This represents one of the lens effect in a `lensFlareSystem`.
  50681. * It controls one of the indiviual texture used in the effect.
  50682. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50683. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  50684. * @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.
  50685. * @param color Define the lens color
  50686. * @param imgUrl Define the lens texture url
  50687. * @param system Define the `lensFlareSystem` this flare is part of
  50688. */
  50689. constructor(
  50690. /**
  50691. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50692. */
  50693. size: number,
  50694. /**
  50695. * 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.
  50696. */
  50697. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  50698. /**
  50699. * Dispose and release the lens flare with its associated resources.
  50700. */
  50701. dispose(): void;
  50702. }
  50703. }
  50704. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  50705. import { Nullable } from "babylonjs/types";
  50706. import { Scene } from "babylonjs/scene";
  50707. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50708. import { AbstractScene } from "babylonjs/abstractScene";
  50709. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50710. module "babylonjs/abstractScene" {
  50711. interface AbstractScene {
  50712. /**
  50713. * The list of lens flare system added to the scene
  50714. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50715. */
  50716. lensFlareSystems: Array<LensFlareSystem>;
  50717. /**
  50718. * Removes the given lens flare system from this scene.
  50719. * @param toRemove The lens flare system to remove
  50720. * @returns The index of the removed lens flare system
  50721. */
  50722. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  50723. /**
  50724. * Adds the given lens flare system to this scene
  50725. * @param newLensFlareSystem The lens flare system to add
  50726. */
  50727. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  50728. /**
  50729. * Gets a lens flare system using its name
  50730. * @param name defines the name to look for
  50731. * @returns the lens flare system or null if not found
  50732. */
  50733. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  50734. /**
  50735. * Gets a lens flare system using its id
  50736. * @param id defines the id to look for
  50737. * @returns the lens flare system or null if not found
  50738. */
  50739. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  50740. }
  50741. }
  50742. /**
  50743. * Defines the lens flare scene component responsible to manage any lens flares
  50744. * in a given scene.
  50745. */
  50746. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  50747. /**
  50748. * The component name helpfull to identify the component in the list of scene components.
  50749. */
  50750. readonly name: string;
  50751. /**
  50752. * The scene the component belongs to.
  50753. */
  50754. scene: Scene;
  50755. /**
  50756. * Creates a new instance of the component for the given scene
  50757. * @param scene Defines the scene to register the component in
  50758. */
  50759. constructor(scene: Scene);
  50760. /**
  50761. * Registers the component in a given scene
  50762. */
  50763. register(): void;
  50764. /**
  50765. * Rebuilds the elements related to this component in case of
  50766. * context lost for instance.
  50767. */
  50768. rebuild(): void;
  50769. /**
  50770. * Adds all the elements from the container to the scene
  50771. * @param container the container holding the elements
  50772. */
  50773. addFromContainer(container: AbstractScene): void;
  50774. /**
  50775. * Removes all the elements in the container from the scene
  50776. * @param container contains the elements to remove
  50777. * @param dispose if the removed element should be disposed (default: false)
  50778. */
  50779. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50780. /**
  50781. * Serializes the component data to the specified json object
  50782. * @param serializationObject The object to serialize to
  50783. */
  50784. serialize(serializationObject: any): void;
  50785. /**
  50786. * Disposes the component and the associated ressources.
  50787. */
  50788. dispose(): void;
  50789. private _draw;
  50790. }
  50791. }
  50792. declare module "babylonjs/LensFlares/index" {
  50793. export * from "babylonjs/LensFlares/lensFlare";
  50794. export * from "babylonjs/LensFlares/lensFlareSystem";
  50795. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  50796. }
  50797. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  50798. import { Scene } from "babylonjs/scene";
  50799. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50800. import { AbstractScene } from "babylonjs/abstractScene";
  50801. /**
  50802. * Defines the shadow generator component responsible to manage any shadow generators
  50803. * in a given scene.
  50804. */
  50805. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50806. /**
  50807. * The component name helpfull to identify the component in the list of scene components.
  50808. */
  50809. readonly name: string;
  50810. /**
  50811. * The scene the component belongs to.
  50812. */
  50813. scene: Scene;
  50814. /**
  50815. * Creates a new instance of the component for the given scene
  50816. * @param scene Defines the scene to register the component in
  50817. */
  50818. constructor(scene: Scene);
  50819. /**
  50820. * Registers the component in a given scene
  50821. */
  50822. register(): void;
  50823. /**
  50824. * Rebuilds the elements related to this component in case of
  50825. * context lost for instance.
  50826. */
  50827. rebuild(): void;
  50828. /**
  50829. * Serializes the component data to the specified json object
  50830. * @param serializationObject The object to serialize to
  50831. */
  50832. serialize(serializationObject: any): void;
  50833. /**
  50834. * Adds all the elements from the container to the scene
  50835. * @param container the container holding the elements
  50836. */
  50837. addFromContainer(container: AbstractScene): void;
  50838. /**
  50839. * Removes all the elements in the container from the scene
  50840. * @param container contains the elements to remove
  50841. * @param dispose if the removed element should be disposed (default: false)
  50842. */
  50843. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50844. /**
  50845. * Rebuilds the elements related to this component in case of
  50846. * context lost for instance.
  50847. */
  50848. dispose(): void;
  50849. private _gatherRenderTargets;
  50850. }
  50851. }
  50852. declare module "babylonjs/Lights/Shadows/index" {
  50853. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  50854. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  50855. }
  50856. declare module "babylonjs/Lights/pointLight" {
  50857. import { Scene } from "babylonjs/scene";
  50858. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50859. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50860. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50861. import { Effect } from "babylonjs/Materials/effect";
  50862. /**
  50863. * A point light is a light defined by an unique point in world space.
  50864. * The light is emitted in every direction from this point.
  50865. * A good example of a point light is a standard light bulb.
  50866. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50867. */
  50868. export class PointLight extends ShadowLight {
  50869. private _shadowAngle;
  50870. /**
  50871. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50872. * This specifies what angle the shadow will use to be created.
  50873. *
  50874. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50875. */
  50876. /**
  50877. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50878. * This specifies what angle the shadow will use to be created.
  50879. *
  50880. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50881. */
  50882. shadowAngle: number;
  50883. /**
  50884. * Gets the direction if it has been set.
  50885. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50886. */
  50887. /**
  50888. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50889. */
  50890. direction: Vector3;
  50891. /**
  50892. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50893. * A PointLight emits the light in every direction.
  50894. * It can cast shadows.
  50895. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50896. * ```javascript
  50897. * var pointLight = new PointLight("pl", camera.position, scene);
  50898. * ```
  50899. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50900. * @param name The light friendly name
  50901. * @param position The position of the point light in the scene
  50902. * @param scene The scene the lights belongs to
  50903. */
  50904. constructor(name: string, position: Vector3, scene: Scene);
  50905. /**
  50906. * Returns the string "PointLight"
  50907. * @returns the class name
  50908. */
  50909. getClassName(): string;
  50910. /**
  50911. * Returns the integer 0.
  50912. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50913. */
  50914. getTypeID(): number;
  50915. /**
  50916. * Specifies wether or not the shadowmap should be a cube texture.
  50917. * @returns true if the shadowmap needs to be a cube texture.
  50918. */
  50919. needCube(): boolean;
  50920. /**
  50921. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50922. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50923. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50924. */
  50925. getShadowDirection(faceIndex?: number): Vector3;
  50926. /**
  50927. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50928. * - fov = PI / 2
  50929. * - aspect ratio : 1.0
  50930. * - z-near and far equal to the active camera minZ and maxZ.
  50931. * Returns the PointLight.
  50932. */
  50933. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50934. protected _buildUniformLayout(): void;
  50935. /**
  50936. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50937. * @param effect The effect to update
  50938. * @param lightIndex The index of the light in the effect to update
  50939. * @returns The point light
  50940. */
  50941. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50942. /**
  50943. * Prepares the list of defines specific to the light type.
  50944. * @param defines the list of defines
  50945. * @param lightIndex defines the index of the light for the effect
  50946. */
  50947. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50948. }
  50949. }
  50950. declare module "babylonjs/Lights/index" {
  50951. export * from "babylonjs/Lights/light";
  50952. export * from "babylonjs/Lights/shadowLight";
  50953. export * from "babylonjs/Lights/Shadows/index";
  50954. export * from "babylonjs/Lights/directionalLight";
  50955. export * from "babylonjs/Lights/hemisphericLight";
  50956. export * from "babylonjs/Lights/pointLight";
  50957. export * from "babylonjs/Lights/spotLight";
  50958. }
  50959. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  50960. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  50961. /**
  50962. * Header information of HDR texture files.
  50963. */
  50964. export interface HDRInfo {
  50965. /**
  50966. * The height of the texture in pixels.
  50967. */
  50968. height: number;
  50969. /**
  50970. * The width of the texture in pixels.
  50971. */
  50972. width: number;
  50973. /**
  50974. * The index of the beginning of the data in the binary file.
  50975. */
  50976. dataPosition: number;
  50977. }
  50978. /**
  50979. * This groups tools to convert HDR texture to native colors array.
  50980. */
  50981. export class HDRTools {
  50982. private static Ldexp;
  50983. private static Rgbe2float;
  50984. private static readStringLine;
  50985. /**
  50986. * Reads header information from an RGBE texture stored in a native array.
  50987. * More information on this format are available here:
  50988. * https://en.wikipedia.org/wiki/RGBE_image_format
  50989. *
  50990. * @param uint8array The binary file stored in native array.
  50991. * @return The header information.
  50992. */
  50993. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50994. /**
  50995. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50996. * This RGBE texture needs to store the information as a panorama.
  50997. *
  50998. * More information on this format are available here:
  50999. * https://en.wikipedia.org/wiki/RGBE_image_format
  51000. *
  51001. * @param buffer The binary file stored in an array buffer.
  51002. * @param size The expected size of the extracted cubemap.
  51003. * @return The Cube Map information.
  51004. */
  51005. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  51006. /**
  51007. * Returns the pixels data extracted from an RGBE texture.
  51008. * This pixels will be stored left to right up to down in the R G B order in one array.
  51009. *
  51010. * More information on this format are available here:
  51011. * https://en.wikipedia.org/wiki/RGBE_image_format
  51012. *
  51013. * @param uint8array The binary file stored in an array buffer.
  51014. * @param hdrInfo The header information of the file.
  51015. * @return The pixels data in RGB right to left up to down order.
  51016. */
  51017. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  51018. private static RGBE_ReadPixels_RLE;
  51019. }
  51020. }
  51021. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  51022. import { Nullable } from "babylonjs/types";
  51023. import { Scene } from "babylonjs/scene";
  51024. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  51025. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51026. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51027. /**
  51028. * This represents a texture coming from an HDR input.
  51029. *
  51030. * The only supported format is currently panorama picture stored in RGBE format.
  51031. * Example of such files can be found on HDRLib: http://hdrlib.com/
  51032. */
  51033. export class HDRCubeTexture extends BaseTexture {
  51034. private static _facesMapping;
  51035. private _generateHarmonics;
  51036. private _noMipmap;
  51037. private _textureMatrix;
  51038. private _size;
  51039. private _onLoad;
  51040. private _onError;
  51041. /**
  51042. * The texture URL.
  51043. */
  51044. url: string;
  51045. /**
  51046. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  51047. */
  51048. coordinatesMode: number;
  51049. protected _isBlocking: boolean;
  51050. /**
  51051. * Sets wether or not the texture is blocking during loading.
  51052. */
  51053. /**
  51054. * Gets wether or not the texture is blocking during loading.
  51055. */
  51056. isBlocking: boolean;
  51057. protected _rotationY: number;
  51058. /**
  51059. * Sets texture matrix rotation angle around Y axis in radians.
  51060. */
  51061. /**
  51062. * Gets texture matrix rotation angle around Y axis radians.
  51063. */
  51064. rotationY: number;
  51065. /**
  51066. * Gets or sets the center of the bounding box associated with the cube texture
  51067. * It must define where the camera used to render the texture was set
  51068. */
  51069. boundingBoxPosition: Vector3;
  51070. private _boundingBoxSize;
  51071. /**
  51072. * Gets or sets the size of the bounding box associated with the cube texture
  51073. * When defined, the cubemap will switch to local mode
  51074. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  51075. * @example https://www.babylonjs-playground.com/#RNASML
  51076. */
  51077. boundingBoxSize: Vector3;
  51078. /**
  51079. * Instantiates an HDRTexture from the following parameters.
  51080. *
  51081. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  51082. * @param scene The scene the texture will be used in
  51083. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51084. * @param noMipmap Forces to not generate the mipmap if true
  51085. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  51086. * @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)
  51087. * @param reserved Reserved flag for internal use.
  51088. */
  51089. 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>);
  51090. /**
  51091. * Get the current class name of the texture useful for serialization or dynamic coding.
  51092. * @returns "HDRCubeTexture"
  51093. */
  51094. getClassName(): string;
  51095. /**
  51096. * Occurs when the file is raw .hdr file.
  51097. */
  51098. private loadTexture;
  51099. clone(): HDRCubeTexture;
  51100. delayLoad(): void;
  51101. /**
  51102. * Get the texture reflection matrix used to rotate/transform the reflection.
  51103. * @returns the reflection matrix
  51104. */
  51105. getReflectionTextureMatrix(): Matrix;
  51106. /**
  51107. * Set the texture reflection matrix used to rotate/transform the reflection.
  51108. * @param value Define the reflection matrix to set
  51109. */
  51110. setReflectionTextureMatrix(value: Matrix): void;
  51111. /**
  51112. * Parses a JSON representation of an HDR Texture in order to create the texture
  51113. * @param parsedTexture Define the JSON representation
  51114. * @param scene Define the scene the texture should be created in
  51115. * @param rootUrl Define the root url in case we need to load relative dependencies
  51116. * @returns the newly created texture after parsing
  51117. */
  51118. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  51119. serialize(): any;
  51120. }
  51121. }
  51122. declare module "babylonjs/Physics/physicsEngine" {
  51123. import { Nullable } from "babylonjs/types";
  51124. import { Vector3 } from "babylonjs/Maths/math";
  51125. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51126. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  51127. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  51128. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51129. /**
  51130. * Class used to control physics engine
  51131. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51132. */
  51133. export class PhysicsEngine implements IPhysicsEngine {
  51134. private _physicsPlugin;
  51135. /**
  51136. * Global value used to control the smallest number supported by the simulation
  51137. */
  51138. static Epsilon: number;
  51139. private _impostors;
  51140. private _joints;
  51141. /**
  51142. * Gets the gravity vector used by the simulation
  51143. */
  51144. gravity: Vector3;
  51145. /**
  51146. * Factory used to create the default physics plugin.
  51147. * @returns The default physics plugin
  51148. */
  51149. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  51150. /**
  51151. * Creates a new Physics Engine
  51152. * @param gravity defines the gravity vector used by the simulation
  51153. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  51154. */
  51155. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  51156. /**
  51157. * Sets the gravity vector used by the simulation
  51158. * @param gravity defines the gravity vector to use
  51159. */
  51160. setGravity(gravity: Vector3): void;
  51161. /**
  51162. * Set the time step of the physics engine.
  51163. * Default is 1/60.
  51164. * To slow it down, enter 1/600 for example.
  51165. * To speed it up, 1/30
  51166. * @param newTimeStep defines the new timestep to apply to this world.
  51167. */
  51168. setTimeStep(newTimeStep?: number): void;
  51169. /**
  51170. * Get the time step of the physics engine.
  51171. * @returns the current time step
  51172. */
  51173. getTimeStep(): number;
  51174. /**
  51175. * Release all resources
  51176. */
  51177. dispose(): void;
  51178. /**
  51179. * Gets the name of the current physics plugin
  51180. * @returns the name of the plugin
  51181. */
  51182. getPhysicsPluginName(): string;
  51183. /**
  51184. * Adding a new impostor for the impostor tracking.
  51185. * This will be done by the impostor itself.
  51186. * @param impostor the impostor to add
  51187. */
  51188. addImpostor(impostor: PhysicsImpostor): void;
  51189. /**
  51190. * Remove an impostor from the engine.
  51191. * This impostor and its mesh will not longer be updated by the physics engine.
  51192. * @param impostor the impostor to remove
  51193. */
  51194. removeImpostor(impostor: PhysicsImpostor): void;
  51195. /**
  51196. * Add a joint to the physics engine
  51197. * @param mainImpostor defines the main impostor to which the joint is added.
  51198. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  51199. * @param joint defines the joint that will connect both impostors.
  51200. */
  51201. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51202. /**
  51203. * Removes a joint from the simulation
  51204. * @param mainImpostor defines the impostor used with the joint
  51205. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  51206. * @param joint defines the joint to remove
  51207. */
  51208. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51209. /**
  51210. * Called by the scene. No need to call it.
  51211. * @param delta defines the timespam between frames
  51212. */
  51213. _step(delta: number): void;
  51214. /**
  51215. * Gets the current plugin used to run the simulation
  51216. * @returns current plugin
  51217. */
  51218. getPhysicsPlugin(): IPhysicsEnginePlugin;
  51219. /**
  51220. * Gets the list of physic impostors
  51221. * @returns an array of PhysicsImpostor
  51222. */
  51223. getImpostors(): Array<PhysicsImpostor>;
  51224. /**
  51225. * Gets the impostor for a physics enabled object
  51226. * @param object defines the object impersonated by the impostor
  51227. * @returns the PhysicsImpostor or null if not found
  51228. */
  51229. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  51230. /**
  51231. * Gets the impostor for a physics body object
  51232. * @param body defines physics body used by the impostor
  51233. * @returns the PhysicsImpostor or null if not found
  51234. */
  51235. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  51236. /**
  51237. * Does a raycast in the physics world
  51238. * @param from when should the ray start?
  51239. * @param to when should the ray end?
  51240. * @returns PhysicsRaycastResult
  51241. */
  51242. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51243. }
  51244. }
  51245. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  51246. import { Nullable } from "babylonjs/types";
  51247. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  51248. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51249. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51250. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51251. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51252. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51253. /** @hidden */
  51254. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  51255. private _useDeltaForWorldStep;
  51256. world: any;
  51257. name: string;
  51258. private _physicsMaterials;
  51259. private _fixedTimeStep;
  51260. private _cannonRaycastResult;
  51261. private _raycastResult;
  51262. private _physicsBodysToRemoveAfterStep;
  51263. BJSCANNON: any;
  51264. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  51265. setGravity(gravity: Vector3): void;
  51266. setTimeStep(timeStep: number): void;
  51267. getTimeStep(): number;
  51268. executeStep(delta: number): void;
  51269. private _removeMarkedPhysicsBodiesFromWorld;
  51270. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51271. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51272. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51273. private _processChildMeshes;
  51274. removePhysicsBody(impostor: PhysicsImpostor): void;
  51275. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51276. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51277. private _addMaterial;
  51278. private _checkWithEpsilon;
  51279. private _createShape;
  51280. private _createHeightmap;
  51281. private _minus90X;
  51282. private _plus90X;
  51283. private _tmpPosition;
  51284. private _tmpDeltaPosition;
  51285. private _tmpUnityRotation;
  51286. private _updatePhysicsBodyTransformation;
  51287. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51288. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51289. isSupported(): boolean;
  51290. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51291. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51292. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51293. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51294. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51295. getBodyMass(impostor: PhysicsImpostor): number;
  51296. getBodyFriction(impostor: PhysicsImpostor): number;
  51297. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51298. getBodyRestitution(impostor: PhysicsImpostor): number;
  51299. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51300. sleepBody(impostor: PhysicsImpostor): void;
  51301. wakeUpBody(impostor: PhysicsImpostor): void;
  51302. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  51303. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51304. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51305. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51306. getRadius(impostor: PhysicsImpostor): number;
  51307. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51308. dispose(): void;
  51309. private _extendNamespace;
  51310. /**
  51311. * Does a raycast in the physics world
  51312. * @param from when should the ray start?
  51313. * @param to when should the ray end?
  51314. * @returns PhysicsRaycastResult
  51315. */
  51316. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51317. }
  51318. }
  51319. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  51320. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51321. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51322. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51324. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  51325. import { Nullable } from "babylonjs/types";
  51326. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51327. /** @hidden */
  51328. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  51329. world: any;
  51330. name: string;
  51331. BJSOIMO: any;
  51332. private _raycastResult;
  51333. constructor(iterations?: number, oimoInjection?: any);
  51334. setGravity(gravity: Vector3): void;
  51335. setTimeStep(timeStep: number): void;
  51336. getTimeStep(): number;
  51337. private _tmpImpostorsArray;
  51338. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51339. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51340. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51341. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51342. private _tmpPositionVector;
  51343. removePhysicsBody(impostor: PhysicsImpostor): void;
  51344. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51345. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51346. isSupported(): boolean;
  51347. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51348. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51349. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51350. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51351. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51352. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51353. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51354. getBodyMass(impostor: PhysicsImpostor): number;
  51355. getBodyFriction(impostor: PhysicsImpostor): number;
  51356. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51357. getBodyRestitution(impostor: PhysicsImpostor): number;
  51358. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51359. sleepBody(impostor: PhysicsImpostor): void;
  51360. wakeUpBody(impostor: PhysicsImpostor): void;
  51361. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51362. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51363. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51364. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51365. getRadius(impostor: PhysicsImpostor): number;
  51366. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51367. dispose(): void;
  51368. /**
  51369. * Does a raycast in the physics world
  51370. * @param from when should the ray start?
  51371. * @param to when should the ray end?
  51372. * @returns PhysicsRaycastResult
  51373. */
  51374. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51375. }
  51376. }
  51377. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  51378. import { Nullable } from "babylonjs/types";
  51379. import { Scene } from "babylonjs/scene";
  51380. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  51381. import { Mesh } from "babylonjs/Meshes/mesh";
  51382. /**
  51383. * Class containing static functions to help procedurally build meshes
  51384. */
  51385. export class RibbonBuilder {
  51386. /**
  51387. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51388. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51389. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51390. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51391. * * 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
  51392. * * 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
  51393. * * 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
  51394. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51395. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51396. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51397. * * 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
  51398. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51399. * * 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
  51400. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51402. * @param name defines the name of the mesh
  51403. * @param options defines the options used to create the mesh
  51404. * @param scene defines the hosting scene
  51405. * @returns the ribbon mesh
  51406. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51407. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51408. */
  51409. static CreateRibbon(name: string, options: {
  51410. pathArray: Vector3[][];
  51411. closeArray?: boolean;
  51412. closePath?: boolean;
  51413. offset?: number;
  51414. updatable?: boolean;
  51415. sideOrientation?: number;
  51416. frontUVs?: Vector4;
  51417. backUVs?: Vector4;
  51418. instance?: Mesh;
  51419. invertUV?: boolean;
  51420. uvs?: Vector2[];
  51421. colors?: Color4[];
  51422. }, scene?: Nullable<Scene>): Mesh;
  51423. }
  51424. }
  51425. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  51426. import { Nullable } from "babylonjs/types";
  51427. import { Scene } from "babylonjs/scene";
  51428. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  51429. import { Mesh } from "babylonjs/Meshes/mesh";
  51430. /**
  51431. * Class containing static functions to help procedurally build meshes
  51432. */
  51433. export class ShapeBuilder {
  51434. /**
  51435. * 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.
  51436. * * 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.
  51437. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51438. * * 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.
  51439. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51440. * * 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
  51441. * * 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
  51442. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51443. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51444. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51445. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51447. * @param name defines the name of the mesh
  51448. * @param options defines the options used to create the mesh
  51449. * @param scene defines the hosting scene
  51450. * @returns the extruded shape mesh
  51451. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51452. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51453. */
  51454. static ExtrudeShape(name: string, options: {
  51455. shape: Vector3[];
  51456. path: Vector3[];
  51457. scale?: number;
  51458. rotation?: number;
  51459. cap?: number;
  51460. updatable?: boolean;
  51461. sideOrientation?: number;
  51462. frontUVs?: Vector4;
  51463. backUVs?: Vector4;
  51464. instance?: Mesh;
  51465. invertUV?: boolean;
  51466. }, scene?: Nullable<Scene>): Mesh;
  51467. /**
  51468. * Creates an custom extruded shape mesh.
  51469. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51470. * * 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.
  51471. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51472. * * 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
  51473. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51474. * * 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
  51475. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51476. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51477. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51478. * * 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
  51479. * * 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
  51480. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51481. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51482. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51483. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51485. * @param name defines the name of the mesh
  51486. * @param options defines the options used to create the mesh
  51487. * @param scene defines the hosting scene
  51488. * @returns the custom extruded shape mesh
  51489. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51490. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51491. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51492. */
  51493. static ExtrudeShapeCustom(name: string, options: {
  51494. shape: Vector3[];
  51495. path: Vector3[];
  51496. scaleFunction?: any;
  51497. rotationFunction?: any;
  51498. ribbonCloseArray?: boolean;
  51499. ribbonClosePath?: boolean;
  51500. cap?: number;
  51501. updatable?: boolean;
  51502. sideOrientation?: number;
  51503. frontUVs?: Vector4;
  51504. backUVs?: Vector4;
  51505. instance?: Mesh;
  51506. invertUV?: boolean;
  51507. }, scene?: Nullable<Scene>): Mesh;
  51508. private static _ExtrudeShapeGeneric;
  51509. }
  51510. }
  51511. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  51512. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  51513. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51514. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51515. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51516. import { Nullable } from "babylonjs/types";
  51517. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51518. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51519. /**
  51520. * AmmoJS Physics plugin
  51521. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51522. * @see https://github.com/kripken/ammo.js/
  51523. */
  51524. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51525. private _useDeltaForWorldStep;
  51526. /**
  51527. * Reference to the Ammo library
  51528. */
  51529. bjsAMMO: any;
  51530. /**
  51531. * Created ammoJS world which physics bodies are added to
  51532. */
  51533. world: any;
  51534. /**
  51535. * Name of the plugin
  51536. */
  51537. name: string;
  51538. private _timeStep;
  51539. private _fixedTimeStep;
  51540. private _maxSteps;
  51541. private _tmpQuaternion;
  51542. private _tmpAmmoTransform;
  51543. private _tmpAmmoQuaternion;
  51544. private _tmpAmmoConcreteContactResultCallback;
  51545. private _collisionConfiguration;
  51546. private _dispatcher;
  51547. private _overlappingPairCache;
  51548. private _solver;
  51549. private _softBodySolver;
  51550. private _tmpAmmoVectorA;
  51551. private _tmpAmmoVectorB;
  51552. private _tmpAmmoVectorC;
  51553. private _tmpAmmoVectorD;
  51554. private _tmpContactCallbackResult;
  51555. private _tmpAmmoVectorRCA;
  51556. private _tmpAmmoVectorRCB;
  51557. private _raycastResult;
  51558. private static readonly DISABLE_COLLISION_FLAG;
  51559. private static readonly KINEMATIC_FLAG;
  51560. private static readonly DISABLE_DEACTIVATION_FLAG;
  51561. /**
  51562. * Initializes the ammoJS plugin
  51563. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51564. * @param ammoInjection can be used to inject your own ammo reference
  51565. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  51566. */
  51567. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  51568. /**
  51569. * Sets the gravity of the physics world (m/(s^2))
  51570. * @param gravity Gravity to set
  51571. */
  51572. setGravity(gravity: Vector3): void;
  51573. /**
  51574. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51575. * @param timeStep timestep to use in seconds
  51576. */
  51577. setTimeStep(timeStep: number): void;
  51578. /**
  51579. * 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)
  51580. * @param fixedTimeStep fixedTimeStep to use in seconds
  51581. */
  51582. setFixedTimeStep(fixedTimeStep: number): void;
  51583. /**
  51584. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51585. * @param maxSteps the maximum number of steps by the physics engine per frame
  51586. */
  51587. setMaxSteps(maxSteps: number): void;
  51588. /**
  51589. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51590. * @returns the current timestep in seconds
  51591. */
  51592. getTimeStep(): number;
  51593. private _isImpostorInContact;
  51594. private _isImpostorPairInContact;
  51595. private _stepSimulation;
  51596. /**
  51597. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51598. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51599. * After the step the babylon meshes are set to the position of the physics imposters
  51600. * @param delta amount of time to step forward
  51601. * @param impostors array of imposters to update before/after the step
  51602. */
  51603. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51604. /**
  51605. * Update babylon mesh to match physics world object
  51606. * @param impostor imposter to match
  51607. */
  51608. private _afterSoftStep;
  51609. /**
  51610. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51611. * @param impostor imposter to match
  51612. */
  51613. private _ropeStep;
  51614. /**
  51615. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51616. * @param impostor imposter to match
  51617. */
  51618. private _softbodyOrClothStep;
  51619. private _tmpVector;
  51620. private _tmpMatrix;
  51621. /**
  51622. * Applies an impulse on the imposter
  51623. * @param impostor imposter to apply impulse to
  51624. * @param force amount of force to be applied to the imposter
  51625. * @param contactPoint the location to apply the impulse on the imposter
  51626. */
  51627. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51628. /**
  51629. * Applies a force on the imposter
  51630. * @param impostor imposter to apply force
  51631. * @param force amount of force to be applied to the imposter
  51632. * @param contactPoint the location to apply the force on the imposter
  51633. */
  51634. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51635. /**
  51636. * Creates a physics body using the plugin
  51637. * @param impostor the imposter to create the physics body on
  51638. */
  51639. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51640. /**
  51641. * Removes the physics body from the imposter and disposes of the body's memory
  51642. * @param impostor imposter to remove the physics body from
  51643. */
  51644. removePhysicsBody(impostor: PhysicsImpostor): void;
  51645. /**
  51646. * Generates a joint
  51647. * @param impostorJoint the imposter joint to create the joint with
  51648. */
  51649. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51650. /**
  51651. * Removes a joint
  51652. * @param impostorJoint the imposter joint to remove the joint from
  51653. */
  51654. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51655. private _addMeshVerts;
  51656. /**
  51657. * Initialise the soft body vertices to match its object's (mesh) vertices
  51658. * Softbody vertices (nodes) are in world space and to match this
  51659. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51660. * @param impostor to create the softbody for
  51661. */
  51662. private _softVertexData;
  51663. /**
  51664. * Create an impostor's soft body
  51665. * @param impostor to create the softbody for
  51666. */
  51667. private _createSoftbody;
  51668. /**
  51669. * Create cloth for an impostor
  51670. * @param impostor to create the softbody for
  51671. */
  51672. private _createCloth;
  51673. /**
  51674. * Create rope for an impostor
  51675. * @param impostor to create the softbody for
  51676. */
  51677. private _createRope;
  51678. private _addHullVerts;
  51679. private _createShape;
  51680. /**
  51681. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51682. * @param impostor imposter containing the physics body and babylon object
  51683. */
  51684. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51685. /**
  51686. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51687. * @param impostor imposter containing the physics body and babylon object
  51688. * @param newPosition new position
  51689. * @param newRotation new rotation
  51690. */
  51691. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51692. /**
  51693. * If this plugin is supported
  51694. * @returns true if its supported
  51695. */
  51696. isSupported(): boolean;
  51697. /**
  51698. * Sets the linear velocity of the physics body
  51699. * @param impostor imposter to set the velocity on
  51700. * @param velocity velocity to set
  51701. */
  51702. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51703. /**
  51704. * Sets the angular velocity of the physics body
  51705. * @param impostor imposter to set the velocity on
  51706. * @param velocity velocity to set
  51707. */
  51708. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51709. /**
  51710. * gets the linear velocity
  51711. * @param impostor imposter to get linear velocity from
  51712. * @returns linear velocity
  51713. */
  51714. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51715. /**
  51716. * gets the angular velocity
  51717. * @param impostor imposter to get angular velocity from
  51718. * @returns angular velocity
  51719. */
  51720. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51721. /**
  51722. * Sets the mass of physics body
  51723. * @param impostor imposter to set the mass on
  51724. * @param mass mass to set
  51725. */
  51726. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51727. /**
  51728. * Gets the mass of the physics body
  51729. * @param impostor imposter to get the mass from
  51730. * @returns mass
  51731. */
  51732. getBodyMass(impostor: PhysicsImpostor): number;
  51733. /**
  51734. * Gets friction of the impostor
  51735. * @param impostor impostor to get friction from
  51736. * @returns friction value
  51737. */
  51738. getBodyFriction(impostor: PhysicsImpostor): number;
  51739. /**
  51740. * Sets friction of the impostor
  51741. * @param impostor impostor to set friction on
  51742. * @param friction friction value
  51743. */
  51744. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51745. /**
  51746. * Gets restitution of the impostor
  51747. * @param impostor impostor to get restitution from
  51748. * @returns restitution value
  51749. */
  51750. getBodyRestitution(impostor: PhysicsImpostor): number;
  51751. /**
  51752. * Sets resitution of the impostor
  51753. * @param impostor impostor to set resitution on
  51754. * @param restitution resitution value
  51755. */
  51756. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51757. /**
  51758. * Gets pressure inside the impostor
  51759. * @param impostor impostor to get pressure from
  51760. * @returns pressure value
  51761. */
  51762. getBodyPressure(impostor: PhysicsImpostor): number;
  51763. /**
  51764. * Sets pressure inside a soft body impostor
  51765. * Cloth and rope must remain 0 pressure
  51766. * @param impostor impostor to set pressure on
  51767. * @param pressure pressure value
  51768. */
  51769. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51770. /**
  51771. * Gets stiffness of the impostor
  51772. * @param impostor impostor to get stiffness from
  51773. * @returns pressure value
  51774. */
  51775. getBodyStiffness(impostor: PhysicsImpostor): number;
  51776. /**
  51777. * Sets stiffness of the impostor
  51778. * @param impostor impostor to set stiffness on
  51779. * @param stiffness stiffness value from 0 to 1
  51780. */
  51781. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  51782. /**
  51783. * Gets velocityIterations of the impostor
  51784. * @param impostor impostor to get velocity iterations from
  51785. * @returns velocityIterations value
  51786. */
  51787. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  51788. /**
  51789. * Sets velocityIterations of the impostor
  51790. * @param impostor impostor to set velocity iterations on
  51791. * @param velocityIterations velocityIterations value
  51792. */
  51793. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  51794. /**
  51795. * Gets positionIterations of the impostor
  51796. * @param impostor impostor to get position iterations from
  51797. * @returns positionIterations value
  51798. */
  51799. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51800. /**
  51801. * Sets positionIterations of the impostor
  51802. * @param impostor impostor to set position on
  51803. * @param positionIterations positionIterations value
  51804. */
  51805. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51806. /**
  51807. * Append an anchor to a cloth object
  51808. * @param impostor is the cloth impostor to add anchor to
  51809. * @param otherImpostor is the rigid impostor to anchor to
  51810. * @param width ratio across width from 0 to 1
  51811. * @param height ratio up height from 0 to 1
  51812. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51813. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51814. */
  51815. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51816. /**
  51817. * Append an hook to a rope object
  51818. * @param impostor is the rope impostor to add hook to
  51819. * @param otherImpostor is the rigid impostor to hook to
  51820. * @param length ratio along the rope from 0 to 1
  51821. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51822. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51823. */
  51824. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51825. /**
  51826. * Sleeps the physics body and stops it from being active
  51827. * @param impostor impostor to sleep
  51828. */
  51829. sleepBody(impostor: PhysicsImpostor): void;
  51830. /**
  51831. * Activates the physics body
  51832. * @param impostor impostor to activate
  51833. */
  51834. wakeUpBody(impostor: PhysicsImpostor): void;
  51835. /**
  51836. * Updates the distance parameters of the joint
  51837. * @param joint joint to update
  51838. * @param maxDistance maximum distance of the joint
  51839. * @param minDistance minimum distance of the joint
  51840. */
  51841. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51842. /**
  51843. * Sets a motor on the joint
  51844. * @param joint joint to set motor on
  51845. * @param speed speed of the motor
  51846. * @param maxForce maximum force of the motor
  51847. * @param motorIndex index of the motor
  51848. */
  51849. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51850. /**
  51851. * Sets the motors limit
  51852. * @param joint joint to set limit on
  51853. * @param upperLimit upper limit
  51854. * @param lowerLimit lower limit
  51855. */
  51856. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51857. /**
  51858. * Syncs the position and rotation of a mesh with the impostor
  51859. * @param mesh mesh to sync
  51860. * @param impostor impostor to update the mesh with
  51861. */
  51862. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51863. /**
  51864. * Gets the radius of the impostor
  51865. * @param impostor impostor to get radius from
  51866. * @returns the radius
  51867. */
  51868. getRadius(impostor: PhysicsImpostor): number;
  51869. /**
  51870. * Gets the box size of the impostor
  51871. * @param impostor impostor to get box size from
  51872. * @param result the resulting box size
  51873. */
  51874. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51875. /**
  51876. * Disposes of the impostor
  51877. */
  51878. dispose(): void;
  51879. /**
  51880. * Does a raycast in the physics world
  51881. * @param from when should the ray start?
  51882. * @param to when should the ray end?
  51883. * @returns PhysicsRaycastResult
  51884. */
  51885. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51886. }
  51887. }
  51888. declare module "babylonjs/Probes/reflectionProbe" {
  51889. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51890. import { Vector3 } from "babylonjs/Maths/math";
  51891. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51892. import { Nullable } from "babylonjs/types";
  51893. import { Scene } from "babylonjs/scene";
  51894. module "babylonjs/abstractScene" {
  51895. interface AbstractScene {
  51896. /**
  51897. * The list of reflection probes added to the scene
  51898. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51899. */
  51900. reflectionProbes: Array<ReflectionProbe>;
  51901. /**
  51902. * Removes the given reflection probe from this scene.
  51903. * @param toRemove The reflection probe to remove
  51904. * @returns The index of the removed reflection probe
  51905. */
  51906. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51907. /**
  51908. * Adds the given reflection probe to this scene.
  51909. * @param newReflectionProbe The reflection probe to add
  51910. */
  51911. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51912. }
  51913. }
  51914. /**
  51915. * Class used to generate realtime reflection / refraction cube textures
  51916. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51917. */
  51918. export class ReflectionProbe {
  51919. /** defines the name of the probe */
  51920. name: string;
  51921. private _scene;
  51922. private _renderTargetTexture;
  51923. private _projectionMatrix;
  51924. private _viewMatrix;
  51925. private _target;
  51926. private _add;
  51927. private _attachedMesh;
  51928. private _invertYAxis;
  51929. /** Gets or sets probe position (center of the cube map) */
  51930. position: Vector3;
  51931. /**
  51932. * Creates a new reflection probe
  51933. * @param name defines the name of the probe
  51934. * @param size defines the texture resolution (for each face)
  51935. * @param scene defines the hosting scene
  51936. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51937. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51938. */
  51939. constructor(
  51940. /** defines the name of the probe */
  51941. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51942. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51943. samples: number;
  51944. /** Gets or sets the refresh rate to use (on every frame by default) */
  51945. refreshRate: number;
  51946. /**
  51947. * Gets the hosting scene
  51948. * @returns a Scene
  51949. */
  51950. getScene(): Scene;
  51951. /** Gets the internal CubeTexture used to render to */
  51952. readonly cubeTexture: RenderTargetTexture;
  51953. /** Gets the list of meshes to render */
  51954. readonly renderList: Nullable<AbstractMesh[]>;
  51955. /**
  51956. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51957. * @param mesh defines the mesh to attach to
  51958. */
  51959. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51960. /**
  51961. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51962. * @param renderingGroupId The rendering group id corresponding to its index
  51963. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51964. */
  51965. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51966. /**
  51967. * Clean all associated resources
  51968. */
  51969. dispose(): void;
  51970. /**
  51971. * Converts the reflection probe information to a readable string for debug purpose.
  51972. * @param fullDetails Supports for multiple levels of logging within scene loading
  51973. * @returns the human readable reflection probe info
  51974. */
  51975. toString(fullDetails?: boolean): string;
  51976. /**
  51977. * Get the class name of the relfection probe.
  51978. * @returns "ReflectionProbe"
  51979. */
  51980. getClassName(): string;
  51981. /**
  51982. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51983. * @returns The JSON representation of the texture
  51984. */
  51985. serialize(): any;
  51986. /**
  51987. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51988. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51989. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51990. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51991. * @returns The parsed reflection probe if successful
  51992. */
  51993. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51994. }
  51995. }
  51996. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  51997. /** @hidden */
  51998. export var _BabylonLoaderRegistered: boolean;
  51999. }
  52000. declare module "babylonjs/Loading/Plugins/index" {
  52001. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  52002. }
  52003. declare module "babylonjs/Loading/index" {
  52004. export * from "babylonjs/Loading/loadingScreen";
  52005. export * from "babylonjs/Loading/Plugins/index";
  52006. export * from "babylonjs/Loading/sceneLoader";
  52007. export * from "babylonjs/Loading/sceneLoaderFlags";
  52008. }
  52009. declare module "babylonjs/Materials/Background/index" {
  52010. export * from "babylonjs/Materials/Background/backgroundMaterial";
  52011. }
  52012. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  52013. import { Scene } from "babylonjs/scene";
  52014. import { Color3 } from "babylonjs/Maths/math";
  52015. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52016. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52017. /**
  52018. * The Physically based simple base material of BJS.
  52019. *
  52020. * This enables better naming and convention enforcements on top of the pbrMaterial.
  52021. * It is used as the base class for both the specGloss and metalRough conventions.
  52022. */
  52023. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  52024. /**
  52025. * Number of Simultaneous lights allowed on the material.
  52026. */
  52027. maxSimultaneousLights: number;
  52028. /**
  52029. * If sets to true, disables all the lights affecting the material.
  52030. */
  52031. disableLighting: boolean;
  52032. /**
  52033. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  52034. */
  52035. environmentTexture: BaseTexture;
  52036. /**
  52037. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52038. */
  52039. invertNormalMapX: boolean;
  52040. /**
  52041. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52042. */
  52043. invertNormalMapY: boolean;
  52044. /**
  52045. * Normal map used in the model.
  52046. */
  52047. normalTexture: BaseTexture;
  52048. /**
  52049. * Emissivie color used to self-illuminate the model.
  52050. */
  52051. emissiveColor: Color3;
  52052. /**
  52053. * Emissivie texture used to self-illuminate the model.
  52054. */
  52055. emissiveTexture: BaseTexture;
  52056. /**
  52057. * Occlusion Channel Strenght.
  52058. */
  52059. occlusionStrength: number;
  52060. /**
  52061. * Occlusion Texture of the material (adding extra occlusion effects).
  52062. */
  52063. occlusionTexture: BaseTexture;
  52064. /**
  52065. * Defines the alpha limits in alpha test mode.
  52066. */
  52067. alphaCutOff: number;
  52068. /**
  52069. * Gets the current double sided mode.
  52070. */
  52071. /**
  52072. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52073. */
  52074. doubleSided: boolean;
  52075. /**
  52076. * Stores the pre-calculated light information of a mesh in a texture.
  52077. */
  52078. lightmapTexture: BaseTexture;
  52079. /**
  52080. * If true, the light map contains occlusion information instead of lighting info.
  52081. */
  52082. useLightmapAsShadowmap: boolean;
  52083. /**
  52084. * Instantiates a new PBRMaterial instance.
  52085. *
  52086. * @param name The material name
  52087. * @param scene The scene the material will be use in.
  52088. */
  52089. constructor(name: string, scene: Scene);
  52090. getClassName(): string;
  52091. }
  52092. }
  52093. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  52094. import { Scene } from "babylonjs/scene";
  52095. import { Color3 } from "babylonjs/Maths/math";
  52096. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52097. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52098. /**
  52099. * The PBR material of BJS following the metal roughness convention.
  52100. *
  52101. * This fits to the PBR convention in the GLTF definition:
  52102. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  52103. */
  52104. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  52105. /**
  52106. * The base color has two different interpretations depending on the value of metalness.
  52107. * When the material is a metal, the base color is the specific measured reflectance value
  52108. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  52109. * of the material.
  52110. */
  52111. baseColor: Color3;
  52112. /**
  52113. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  52114. * well as opacity information in the alpha channel.
  52115. */
  52116. baseTexture: BaseTexture;
  52117. /**
  52118. * Specifies the metallic scalar value of the material.
  52119. * Can also be used to scale the metalness values of the metallic texture.
  52120. */
  52121. metallic: number;
  52122. /**
  52123. * Specifies the roughness scalar value of the material.
  52124. * Can also be used to scale the roughness values of the metallic texture.
  52125. */
  52126. roughness: number;
  52127. /**
  52128. * Texture containing both the metallic value in the B channel and the
  52129. * roughness value in the G channel to keep better precision.
  52130. */
  52131. metallicRoughnessTexture: BaseTexture;
  52132. /**
  52133. * Instantiates a new PBRMetalRoughnessMaterial instance.
  52134. *
  52135. * @param name The material name
  52136. * @param scene The scene the material will be use in.
  52137. */
  52138. constructor(name: string, scene: Scene);
  52139. /**
  52140. * Return the currrent class name of the material.
  52141. */
  52142. getClassName(): string;
  52143. /**
  52144. * Makes a duplicate of the current material.
  52145. * @param name - name to use for the new material.
  52146. */
  52147. clone(name: string): PBRMetallicRoughnessMaterial;
  52148. /**
  52149. * Serialize the material to a parsable JSON object.
  52150. */
  52151. serialize(): any;
  52152. /**
  52153. * Parses a JSON object correponding to the serialize function.
  52154. */
  52155. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  52156. }
  52157. }
  52158. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  52159. import { Scene } from "babylonjs/scene";
  52160. import { Color3 } from "babylonjs/Maths/math";
  52161. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52162. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52163. /**
  52164. * The PBR material of BJS following the specular glossiness convention.
  52165. *
  52166. * This fits to the PBR convention in the GLTF definition:
  52167. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  52168. */
  52169. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  52170. /**
  52171. * Specifies the diffuse color of the material.
  52172. */
  52173. diffuseColor: Color3;
  52174. /**
  52175. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  52176. * channel.
  52177. */
  52178. diffuseTexture: BaseTexture;
  52179. /**
  52180. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  52181. */
  52182. specularColor: Color3;
  52183. /**
  52184. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  52185. */
  52186. glossiness: number;
  52187. /**
  52188. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  52189. */
  52190. specularGlossinessTexture: BaseTexture;
  52191. /**
  52192. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  52193. *
  52194. * @param name The material name
  52195. * @param scene The scene the material will be use in.
  52196. */
  52197. constructor(name: string, scene: Scene);
  52198. /**
  52199. * Return the currrent class name of the material.
  52200. */
  52201. getClassName(): string;
  52202. /**
  52203. * Makes a duplicate of the current material.
  52204. * @param name - name to use for the new material.
  52205. */
  52206. clone(name: string): PBRSpecularGlossinessMaterial;
  52207. /**
  52208. * Serialize the material to a parsable JSON object.
  52209. */
  52210. serialize(): any;
  52211. /**
  52212. * Parses a JSON object correponding to the serialize function.
  52213. */
  52214. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  52215. }
  52216. }
  52217. declare module "babylonjs/Materials/PBR/index" {
  52218. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52219. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52220. export * from "babylonjs/Materials/PBR/pbrMaterial";
  52221. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  52222. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  52223. }
  52224. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  52225. import { Nullable } from "babylonjs/types";
  52226. import { Scene } from "babylonjs/scene";
  52227. import { Matrix } from "babylonjs/Maths/math";
  52228. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52229. /**
  52230. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  52231. * It can help converting any input color in a desired output one. This can then be used to create effects
  52232. * from sepia, black and white to sixties or futuristic rendering...
  52233. *
  52234. * The only supported format is currently 3dl.
  52235. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  52236. */
  52237. export class ColorGradingTexture extends BaseTexture {
  52238. /**
  52239. * The current texture matrix. (will always be identity in color grading texture)
  52240. */
  52241. private _textureMatrix;
  52242. /**
  52243. * The texture URL.
  52244. */
  52245. url: string;
  52246. /**
  52247. * Empty line regex stored for GC.
  52248. */
  52249. private static _noneEmptyLineRegex;
  52250. private _engine;
  52251. /**
  52252. * Instantiates a ColorGradingTexture from the following parameters.
  52253. *
  52254. * @param url The location of the color gradind data (currently only supporting 3dl)
  52255. * @param scene The scene the texture will be used in
  52256. */
  52257. constructor(url: string, scene: Scene);
  52258. /**
  52259. * Returns the texture matrix used in most of the material.
  52260. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  52261. */
  52262. getTextureMatrix(): Matrix;
  52263. /**
  52264. * Occurs when the file being loaded is a .3dl LUT file.
  52265. */
  52266. private load3dlTexture;
  52267. /**
  52268. * Starts the loading process of the texture.
  52269. */
  52270. private loadTexture;
  52271. /**
  52272. * Clones the color gradind texture.
  52273. */
  52274. clone(): ColorGradingTexture;
  52275. /**
  52276. * Called during delayed load for textures.
  52277. */
  52278. delayLoad(): void;
  52279. /**
  52280. * Parses a color grading texture serialized by Babylon.
  52281. * @param parsedTexture The texture information being parsedTexture
  52282. * @param scene The scene to load the texture in
  52283. * @param rootUrl The root url of the data assets to load
  52284. * @return A color gradind texture
  52285. */
  52286. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  52287. /**
  52288. * Serializes the LUT texture to json format.
  52289. */
  52290. serialize(): any;
  52291. }
  52292. }
  52293. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  52294. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52295. import { Scene } from "babylonjs/scene";
  52296. import { Nullable } from "babylonjs/types";
  52297. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52298. /**
  52299. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  52300. */
  52301. export class EquiRectangularCubeTexture extends BaseTexture {
  52302. /** The six faces of the cube. */
  52303. private static _FacesMapping;
  52304. private _noMipmap;
  52305. private _onLoad;
  52306. private _onError;
  52307. /** The size of the cubemap. */
  52308. private _size;
  52309. /** The buffer of the image. */
  52310. private _buffer;
  52311. /** The width of the input image. */
  52312. private _width;
  52313. /** The height of the input image. */
  52314. private _height;
  52315. /** The URL to the image. */
  52316. url: string;
  52317. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  52318. coordinatesMode: number;
  52319. /**
  52320. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  52321. * @param url The location of the image
  52322. * @param scene The scene the texture will be used in
  52323. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52324. * @param noMipmap Forces to not generate the mipmap if true
  52325. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  52326. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  52327. * @param onLoad — defines a callback called when texture is loaded
  52328. * @param onError — defines a callback called if there is an error
  52329. */
  52330. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52331. /**
  52332. * Load the image data, by putting the image on a canvas and extracting its buffer.
  52333. */
  52334. private loadImage;
  52335. /**
  52336. * Convert the image buffer into a cubemap and create a CubeTexture.
  52337. */
  52338. private loadTexture;
  52339. /**
  52340. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  52341. * @param buffer The ArrayBuffer that should be converted.
  52342. * @returns The buffer as Float32Array.
  52343. */
  52344. private getFloat32ArrayFromArrayBuffer;
  52345. /**
  52346. * Get the current class name of the texture useful for serialization or dynamic coding.
  52347. * @returns "EquiRectangularCubeTexture"
  52348. */
  52349. getClassName(): string;
  52350. /**
  52351. * Create a clone of the current EquiRectangularCubeTexture and return it.
  52352. * @returns A clone of the current EquiRectangularCubeTexture.
  52353. */
  52354. clone(): EquiRectangularCubeTexture;
  52355. }
  52356. }
  52357. declare module "babylonjs/Misc/tga" {
  52358. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52359. /**
  52360. * Based on jsTGALoader - Javascript loader for TGA file
  52361. * By Vincent Thibault
  52362. * @see http://blog.robrowser.com/javascript-tga-loader.html
  52363. */
  52364. export class TGATools {
  52365. private static _TYPE_INDEXED;
  52366. private static _TYPE_RGB;
  52367. private static _TYPE_GREY;
  52368. private static _TYPE_RLE_INDEXED;
  52369. private static _TYPE_RLE_RGB;
  52370. private static _TYPE_RLE_GREY;
  52371. private static _ORIGIN_MASK;
  52372. private static _ORIGIN_SHIFT;
  52373. private static _ORIGIN_BL;
  52374. private static _ORIGIN_BR;
  52375. private static _ORIGIN_UL;
  52376. private static _ORIGIN_UR;
  52377. /**
  52378. * Gets the header of a TGA file
  52379. * @param data defines the TGA data
  52380. * @returns the header
  52381. */
  52382. static GetTGAHeader(data: Uint8Array): any;
  52383. /**
  52384. * Uploads TGA content to a Babylon Texture
  52385. * @hidden
  52386. */
  52387. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  52388. /** @hidden */
  52389. 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;
  52390. /** @hidden */
  52391. 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;
  52392. /** @hidden */
  52393. 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;
  52394. /** @hidden */
  52395. 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;
  52396. /** @hidden */
  52397. 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;
  52398. /** @hidden */
  52399. 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;
  52400. }
  52401. }
  52402. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  52403. import { Nullable } from "babylonjs/types";
  52404. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52405. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52406. /**
  52407. * Implementation of the TGA Texture Loader.
  52408. * @hidden
  52409. */
  52410. export class _TGATextureLoader implements IInternalTextureLoader {
  52411. /**
  52412. * Defines wether the loader supports cascade loading the different faces.
  52413. */
  52414. readonly supportCascades: boolean;
  52415. /**
  52416. * This returns if the loader support the current file information.
  52417. * @param extension defines the file extension of the file being loaded
  52418. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52419. * @param fallback defines the fallback internal texture if any
  52420. * @param isBase64 defines whether the texture is encoded as a base64
  52421. * @param isBuffer defines whether the texture data are stored as a buffer
  52422. * @returns true if the loader can load the specified file
  52423. */
  52424. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52425. /**
  52426. * Transform the url before loading if required.
  52427. * @param rootUrl the url of the texture
  52428. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52429. * @returns the transformed texture
  52430. */
  52431. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52432. /**
  52433. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52434. * @param rootUrl the url of the texture
  52435. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52436. * @returns the fallback texture
  52437. */
  52438. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52439. /**
  52440. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52441. * @param data contains the texture data
  52442. * @param texture defines the BabylonJS internal texture
  52443. * @param createPolynomials will be true if polynomials have been requested
  52444. * @param onLoad defines the callback to trigger once the texture is ready
  52445. * @param onError defines the callback to trigger in case of error
  52446. */
  52447. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52448. /**
  52449. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52450. * @param data contains the texture data
  52451. * @param texture defines the BabylonJS internal texture
  52452. * @param callback defines the method to call once ready to upload
  52453. */
  52454. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52455. }
  52456. }
  52457. declare module "babylonjs/Misc/basis" {
  52458. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52459. /**
  52460. * Info about the .basis files
  52461. */
  52462. class BasisFileInfo {
  52463. /**
  52464. * If the file has alpha
  52465. */
  52466. hasAlpha: boolean;
  52467. /**
  52468. * Info about each image of the basis file
  52469. */
  52470. images: Array<{
  52471. levels: Array<{
  52472. width: number;
  52473. height: number;
  52474. transcodedPixels: ArrayBufferView;
  52475. }>;
  52476. }>;
  52477. }
  52478. /**
  52479. * Result of transcoding a basis file
  52480. */
  52481. class TranscodeResult {
  52482. /**
  52483. * Info about the .basis file
  52484. */
  52485. fileInfo: BasisFileInfo;
  52486. /**
  52487. * Format to use when loading the file
  52488. */
  52489. format: number;
  52490. }
  52491. /**
  52492. * Configuration options for the Basis transcoder
  52493. */
  52494. export class BasisTranscodeConfiguration {
  52495. /**
  52496. * Supported compression formats used to determine the supported output format of the transcoder
  52497. */
  52498. supportedCompressionFormats?: {
  52499. /**
  52500. * etc1 compression format
  52501. */
  52502. etc1?: boolean;
  52503. /**
  52504. * s3tc compression format
  52505. */
  52506. s3tc?: boolean;
  52507. /**
  52508. * pvrtc compression format
  52509. */
  52510. pvrtc?: boolean;
  52511. /**
  52512. * etc2 compression format
  52513. */
  52514. etc2?: boolean;
  52515. };
  52516. /**
  52517. * If mipmap levels should be loaded for transcoded images (Default: true)
  52518. */
  52519. loadMipmapLevels?: boolean;
  52520. /**
  52521. * Index of a single image to load (Default: all images)
  52522. */
  52523. loadSingleImage?: number;
  52524. }
  52525. /**
  52526. * Used to load .Basis files
  52527. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  52528. */
  52529. export class BasisTools {
  52530. private static _IgnoreSupportedFormats;
  52531. /**
  52532. * URL to use when loading the basis transcoder
  52533. */
  52534. static JSModuleURL: string;
  52535. /**
  52536. * URL to use when loading the wasm module for the transcoder
  52537. */
  52538. static WasmModuleURL: string;
  52539. /**
  52540. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  52541. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  52542. * @returns internal format corresponding to the Basis format
  52543. */
  52544. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  52545. private static _WorkerPromise;
  52546. private static _Worker;
  52547. private static _actionId;
  52548. private static _CreateWorkerAsync;
  52549. /**
  52550. * Transcodes a loaded image file to compressed pixel data
  52551. * @param imageData image data to transcode
  52552. * @param config configuration options for the transcoding
  52553. * @returns a promise resulting in the transcoded image
  52554. */
  52555. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  52556. /**
  52557. * Loads a texture from the transcode result
  52558. * @param texture texture load to
  52559. * @param transcodeResult the result of transcoding the basis file to load from
  52560. */
  52561. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  52562. }
  52563. }
  52564. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  52565. import { Nullable } from "babylonjs/types";
  52566. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52567. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52568. /**
  52569. * Loader for .basis file format
  52570. */
  52571. export class _BasisTextureLoader implements IInternalTextureLoader {
  52572. /**
  52573. * Defines whether the loader supports cascade loading the different faces.
  52574. */
  52575. readonly supportCascades: boolean;
  52576. /**
  52577. * This returns if the loader support the current file information.
  52578. * @param extension defines the file extension of the file being loaded
  52579. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52580. * @param fallback defines the fallback internal texture if any
  52581. * @param isBase64 defines whether the texture is encoded as a base64
  52582. * @param isBuffer defines whether the texture data are stored as a buffer
  52583. * @returns true if the loader can load the specified file
  52584. */
  52585. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52586. /**
  52587. * Transform the url before loading if required.
  52588. * @param rootUrl the url of the texture
  52589. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52590. * @returns the transformed texture
  52591. */
  52592. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52593. /**
  52594. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52595. * @param rootUrl the url of the texture
  52596. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52597. * @returns the fallback texture
  52598. */
  52599. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52600. /**
  52601. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  52602. * @param data contains the texture data
  52603. * @param texture defines the BabylonJS internal texture
  52604. * @param createPolynomials will be true if polynomials have been requested
  52605. * @param onLoad defines the callback to trigger once the texture is ready
  52606. * @param onError defines the callback to trigger in case of error
  52607. */
  52608. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52609. /**
  52610. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52611. * @param data contains the texture data
  52612. * @param texture defines the BabylonJS internal texture
  52613. * @param callback defines the method to call once ready to upload
  52614. */
  52615. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52616. }
  52617. }
  52618. declare module "babylonjs/Materials/Textures/Loaders/index" {
  52619. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  52620. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  52621. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  52622. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  52623. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  52624. }
  52625. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  52626. import { Scene } from "babylonjs/scene";
  52627. import { Texture } from "babylonjs/Materials/Textures/texture";
  52628. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52629. /**
  52630. * 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.
  52631. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52632. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52633. */
  52634. export class CustomProceduralTexture extends ProceduralTexture {
  52635. private _animate;
  52636. private _time;
  52637. private _config;
  52638. private _texturePath;
  52639. /**
  52640. * Instantiates a new Custom Procedural Texture.
  52641. * 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.
  52642. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52643. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52644. * @param name Define the name of the texture
  52645. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52646. * @param size Define the size of the texture to create
  52647. * @param scene Define the scene the texture belongs to
  52648. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52649. * @param generateMipMaps Define if the texture should creates mip maps or not
  52650. */
  52651. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52652. private _loadJson;
  52653. /**
  52654. * Is the texture ready to be used ? (rendered at least once)
  52655. * @returns true if ready, otherwise, false.
  52656. */
  52657. isReady(): boolean;
  52658. /**
  52659. * Render the texture to its associated render target.
  52660. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52661. */
  52662. render(useCameraPostProcess?: boolean): void;
  52663. /**
  52664. * Update the list of dependant textures samplers in the shader.
  52665. */
  52666. updateTextures(): void;
  52667. /**
  52668. * Update the uniform values of the procedural texture in the shader.
  52669. */
  52670. updateShaderUniforms(): void;
  52671. /**
  52672. * Define if the texture animates or not.
  52673. */
  52674. animate: boolean;
  52675. }
  52676. }
  52677. declare module "babylonjs/Shaders/noise.fragment" {
  52678. /** @hidden */
  52679. export var noisePixelShader: {
  52680. name: string;
  52681. shader: string;
  52682. };
  52683. }
  52684. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  52685. import { Nullable } from "babylonjs/types";
  52686. import { Scene } from "babylonjs/scene";
  52687. import { Texture } from "babylonjs/Materials/Textures/texture";
  52688. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52689. import "babylonjs/Shaders/noise.fragment";
  52690. /**
  52691. * Class used to generate noise procedural textures
  52692. */
  52693. export class NoiseProceduralTexture extends ProceduralTexture {
  52694. private _time;
  52695. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  52696. brightness: number;
  52697. /** Defines the number of octaves to process */
  52698. octaves: number;
  52699. /** Defines the level of persistence (0.8 by default) */
  52700. persistence: number;
  52701. /** Gets or sets animation speed factor (default is 1) */
  52702. animationSpeedFactor: number;
  52703. /**
  52704. * Creates a new NoiseProceduralTexture
  52705. * @param name defines the name fo the texture
  52706. * @param size defines the size of the texture (default is 256)
  52707. * @param scene defines the hosting scene
  52708. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  52709. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  52710. */
  52711. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52712. private _updateShaderUniforms;
  52713. protected _getDefines(): string;
  52714. /** Generate the current state of the procedural texture */
  52715. render(useCameraPostProcess?: boolean): void;
  52716. /**
  52717. * Serializes this noise procedural texture
  52718. * @returns a serialized noise procedural texture object
  52719. */
  52720. serialize(): any;
  52721. /**
  52722. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  52723. * @param parsedTexture defines parsed texture data
  52724. * @param scene defines the current scene
  52725. * @param rootUrl defines the root URL containing noise procedural texture information
  52726. * @returns a parsed NoiseProceduralTexture
  52727. */
  52728. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  52729. }
  52730. }
  52731. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  52732. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  52733. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  52734. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52735. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  52736. }
  52737. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  52738. import { Nullable } from "babylonjs/types";
  52739. import { Scene } from "babylonjs/scene";
  52740. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  52741. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52742. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  52743. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52744. /**
  52745. * Raw cube texture where the raw buffers are passed in
  52746. */
  52747. export class RawCubeTexture extends CubeTexture {
  52748. /**
  52749. * Creates a cube texture where the raw buffers are passed in.
  52750. * @param scene defines the scene the texture is attached to
  52751. * @param data defines the array of data to use to create each face
  52752. * @param size defines the size of the textures
  52753. * @param format defines the format of the data
  52754. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  52755. * @param generateMipMaps defines if the engine should generate the mip levels
  52756. * @param invertY defines if data must be stored with Y axis inverted
  52757. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  52758. * @param compression defines the compression used (null by default)
  52759. */
  52760. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  52761. /**
  52762. * Updates the raw cube texture.
  52763. * @param data defines the data to store
  52764. * @param format defines the data format
  52765. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52766. * @param invertY defines if data must be stored with Y axis inverted
  52767. * @param compression defines the compression used (null by default)
  52768. * @param level defines which level of the texture to update
  52769. */
  52770. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  52771. /**
  52772. * Updates a raw cube texture with RGBD encoded data.
  52773. * @param data defines the array of data [mipmap][face] to use to create each face
  52774. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  52775. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52776. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52777. * @returns a promsie that resolves when the operation is complete
  52778. */
  52779. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  52780. /**
  52781. * Clones the raw cube texture.
  52782. * @return a new cube texture
  52783. */
  52784. clone(): CubeTexture;
  52785. /** @hidden */
  52786. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52787. }
  52788. }
  52789. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  52790. import { Scene } from "babylonjs/scene";
  52791. import { Texture } from "babylonjs/Materials/Textures/texture";
  52792. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52793. /**
  52794. * Class used to store 3D textures containing user data
  52795. */
  52796. export class RawTexture3D extends Texture {
  52797. /** Gets or sets the texture format to use */
  52798. format: number;
  52799. private _engine;
  52800. /**
  52801. * Create a new RawTexture3D
  52802. * @param data defines the data of the texture
  52803. * @param width defines the width of the texture
  52804. * @param height defines the height of the texture
  52805. * @param depth defines the depth of the texture
  52806. * @param format defines the texture format to use
  52807. * @param scene defines the hosting scene
  52808. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  52809. * @param invertY defines if texture must be stored with Y axis inverted
  52810. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52811. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  52812. */
  52813. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  52814. /** Gets or sets the texture format to use */
  52815. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  52816. /**
  52817. * Update the texture with new data
  52818. * @param data defines the data to store in the texture
  52819. */
  52820. update(data: ArrayBufferView): void;
  52821. }
  52822. }
  52823. declare module "babylonjs/Materials/Textures/refractionTexture" {
  52824. import { Scene } from "babylonjs/scene";
  52825. import { Plane } from "babylonjs/Maths/math";
  52826. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52827. /**
  52828. * Creates a refraction texture used by refraction channel of the standard material.
  52829. * It is like a mirror but to see through a material.
  52830. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52831. */
  52832. export class RefractionTexture extends RenderTargetTexture {
  52833. /**
  52834. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  52835. * 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.
  52836. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52837. */
  52838. refractionPlane: Plane;
  52839. /**
  52840. * Define how deep under the surface we should see.
  52841. */
  52842. depth: number;
  52843. /**
  52844. * Creates a refraction texture used by refraction channel of the standard material.
  52845. * It is like a mirror but to see through a material.
  52846. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52847. * @param name Define the texture name
  52848. * @param size Define the size of the underlying texture
  52849. * @param scene Define the scene the refraction belongs to
  52850. * @param generateMipMaps Define if we need to generate mips level for the refraction
  52851. */
  52852. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  52853. /**
  52854. * Clone the refraction texture.
  52855. * @returns the cloned texture
  52856. */
  52857. clone(): RefractionTexture;
  52858. /**
  52859. * Serialize the texture to a JSON representation you could use in Parse later on
  52860. * @returns the serialized JSON representation
  52861. */
  52862. serialize(): any;
  52863. }
  52864. }
  52865. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  52866. import { Nullable } from "babylonjs/types";
  52867. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52868. import { Matrix } from "babylonjs/Maths/math";
  52869. import { Engine } from "babylonjs/Engines/engine";
  52870. import { Scene } from "babylonjs/scene";
  52871. /**
  52872. * Defines the options related to the creation of an HtmlElementTexture
  52873. */
  52874. export interface IHtmlElementTextureOptions {
  52875. /**
  52876. * Defines wether mip maps should be created or not.
  52877. */
  52878. generateMipMaps?: boolean;
  52879. /**
  52880. * Defines the sampling mode of the texture.
  52881. */
  52882. samplingMode?: number;
  52883. /**
  52884. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  52885. */
  52886. engine: Nullable<Engine>;
  52887. /**
  52888. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  52889. */
  52890. scene: Nullable<Scene>;
  52891. }
  52892. /**
  52893. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  52894. * To be as efficient as possible depending on your constraints nothing aside the first upload
  52895. * is automatically managed.
  52896. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  52897. * in your application.
  52898. *
  52899. * As the update is not automatic, you need to call them manually.
  52900. */
  52901. export class HtmlElementTexture extends BaseTexture {
  52902. /**
  52903. * The texture URL.
  52904. */
  52905. element: HTMLVideoElement | HTMLCanvasElement;
  52906. private static readonly DefaultOptions;
  52907. private _textureMatrix;
  52908. private _engine;
  52909. private _isVideo;
  52910. private _generateMipMaps;
  52911. private _samplingMode;
  52912. /**
  52913. * Instantiates a HtmlElementTexture from the following parameters.
  52914. *
  52915. * @param name Defines the name of the texture
  52916. * @param element Defines the video or canvas the texture is filled with
  52917. * @param options Defines the other none mandatory texture creation options
  52918. */
  52919. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  52920. private _createInternalTexture;
  52921. /**
  52922. * Returns the texture matrix used in most of the material.
  52923. */
  52924. getTextureMatrix(): Matrix;
  52925. /**
  52926. * Updates the content of the texture.
  52927. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  52928. */
  52929. update(invertY?: Nullable<boolean>): void;
  52930. }
  52931. }
  52932. declare module "babylonjs/Materials/Textures/index" {
  52933. export * from "babylonjs/Materials/Textures/baseTexture";
  52934. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  52935. export * from "babylonjs/Materials/Textures/cubeTexture";
  52936. export * from "babylonjs/Materials/Textures/dynamicTexture";
  52937. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  52938. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  52939. export * from "babylonjs/Materials/Textures/internalTexture";
  52940. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  52941. export * from "babylonjs/Materials/Textures/Loaders/index";
  52942. export * from "babylonjs/Materials/Textures/mirrorTexture";
  52943. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  52944. export * from "babylonjs/Materials/Textures/Procedurals/index";
  52945. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  52946. export * from "babylonjs/Materials/Textures/rawTexture";
  52947. export * from "babylonjs/Materials/Textures/rawTexture3D";
  52948. export * from "babylonjs/Materials/Textures/refractionTexture";
  52949. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  52950. export * from "babylonjs/Materials/Textures/texture";
  52951. export * from "babylonjs/Materials/Textures/videoTexture";
  52952. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  52953. }
  52954. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  52955. /**
  52956. * Enum used to define the target of a block
  52957. */
  52958. export enum NodeMaterialBlockTargets {
  52959. /** Vertex shader */
  52960. Vertex = 1,
  52961. /** Fragment shader */
  52962. Fragment = 2,
  52963. /** Vertex and Fragment */
  52964. VertexAndFragment = 3
  52965. }
  52966. }
  52967. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  52968. /**
  52969. * Defines the kind of connection point for node based material
  52970. */
  52971. export enum NodeMaterialBlockConnectionPointTypes {
  52972. /** Float */
  52973. Float = 1,
  52974. /** Int */
  52975. Int = 2,
  52976. /** Vector2 */
  52977. Vector2 = 4,
  52978. /** Vector3 */
  52979. Vector3 = 8,
  52980. /** Vector4 */
  52981. Vector4 = 16,
  52982. /** Color3 */
  52983. Color3 = 32,
  52984. /** Color4 */
  52985. Color4 = 64,
  52986. /** Matrix */
  52987. Matrix = 128,
  52988. /** Texture */
  52989. Texture = 256,
  52990. /** Texture3D */
  52991. Texture3D = 512,
  52992. /** Vector3 or Color3 */
  52993. Vector3OrColor3 = 40,
  52994. /** Vector3 or Vector4 */
  52995. Vector3OrVector4 = 24,
  52996. /** Vector4 or Color4 */
  52997. Vector4OrColor4 = 80,
  52998. /** Color3 or Color4 */
  52999. Color3OrColor4 = 96,
  53000. /** Vector3 or Color3 */
  53001. Vector3OrColor3OrVector4OrColor4 = 120,
  53002. /** Detect type based on connection */
  53003. AutoDetect = 1024,
  53004. /** Output type that will be defined by input type */
  53005. BasedOnInput = 2048,
  53006. /** Light */
  53007. Light = 4096
  53008. }
  53009. }
  53010. declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
  53011. /**
  53012. * Enum used to define well known values e.g. values automatically provided by the system
  53013. */
  53014. export enum NodeMaterialWellKnownValues {
  53015. /** World */
  53016. World = 1,
  53017. /** View */
  53018. View = 2,
  53019. /** Projection */
  53020. Projection = 3,
  53021. /** ViewProjection */
  53022. ViewProjection = 4,
  53023. /** WorldView */
  53024. WorldView = 5,
  53025. /** WorldViewProjection */
  53026. WorldViewProjection = 6,
  53027. /** CameraPosition */
  53028. CameraPosition = 7,
  53029. /** Will be filled by the block itself */
  53030. Automatic = 8
  53031. }
  53032. }
  53033. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  53034. /**
  53035. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  53036. */
  53037. export enum NodeMaterialBlockConnectionPointMode {
  53038. /** Value is an uniform */
  53039. Uniform = 0,
  53040. /** Value is a mesh attribute */
  53041. Attribute = 1,
  53042. /** Value is a varying between vertex and fragment shaders */
  53043. Varying = 2,
  53044. /** Mode is undefined */
  53045. Undefined = 3
  53046. }
  53047. }
  53048. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  53049. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53050. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53051. /**
  53052. * Class used to store shared data between 2 NodeMaterialBuildState
  53053. */
  53054. export class NodeMaterialBuildStateSharedData {
  53055. /**
  53056. * Gets the list of emitted varyings
  53057. */
  53058. varyings: string[];
  53059. /**
  53060. * Gets the varying declaration string
  53061. */
  53062. varyingDeclaration: string;
  53063. /**
  53064. * Uniform connection points
  53065. */
  53066. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  53067. /**
  53068. * Bindable blocks (Blocks that need to set data to the effect)
  53069. */
  53070. bindableBlocks: NodeMaterialBlock[];
  53071. /**
  53072. * List of blocks that can provide a compilation fallback
  53073. */
  53074. blocksWithFallbacks: NodeMaterialBlock[];
  53075. /**
  53076. * List of blocks that can provide a define update
  53077. */
  53078. blocksWithDefines: NodeMaterialBlock[];
  53079. /**
  53080. * List of blocks that can provide a repeatable content
  53081. */
  53082. repeatableContentBlocks: NodeMaterialBlock[];
  53083. /**
  53084. * List of blocks that can provide a dynamic list of uniforms
  53085. */
  53086. dynamicUniformBlocks: NodeMaterialBlock[];
  53087. /**
  53088. * List of blocks that can block the isReady function for the material
  53089. */
  53090. blockingBlocks: NodeMaterialBlock[];
  53091. /**
  53092. * Build Id used to avoid multiple recompilations
  53093. */
  53094. buildId: number;
  53095. /** List of emitted variables */
  53096. variableNames: {
  53097. [key: string]: number;
  53098. };
  53099. /** List of emitted defines */
  53100. defineNames: {
  53101. [key: string]: number;
  53102. };
  53103. /** Should emit comments? */
  53104. emitComments: boolean;
  53105. /** Emit build activity */
  53106. verbose: boolean;
  53107. /**
  53108. * Gets the compilation hints emitted at compilation time
  53109. */
  53110. hints: {
  53111. needWorldViewMatrix: boolean;
  53112. needWorldViewProjectionMatrix: boolean;
  53113. needAlphaBlending: boolean;
  53114. needAlphaTesting: boolean;
  53115. };
  53116. /**
  53117. * List of compilation checks
  53118. */
  53119. checks: {
  53120. emitVertex: boolean;
  53121. emitFragment: boolean;
  53122. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  53123. };
  53124. /** Creates a new shared data */
  53125. constructor();
  53126. /**
  53127. * Emits console errors and exceptions if there is a failing check
  53128. */
  53129. emitErrors(): void;
  53130. }
  53131. }
  53132. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  53133. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53134. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53135. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53136. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  53137. import { Nullable } from "babylonjs/types";
  53138. /**
  53139. * Class used to store node based material build state
  53140. */
  53141. export class NodeMaterialBuildState {
  53142. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  53143. supportUniformBuffers: boolean;
  53144. /**
  53145. * Gets the list of emitted attributes
  53146. */
  53147. attributes: string[];
  53148. /**
  53149. * Gets the list of emitted uniforms
  53150. */
  53151. uniforms: string[];
  53152. /**
  53153. * Gets the list of emitted uniform buffers
  53154. */
  53155. uniformBuffers: string[];
  53156. /**
  53157. * Gets the list of emitted samplers
  53158. */
  53159. samplers: string[];
  53160. /**
  53161. * Gets the list of emitted functions
  53162. */
  53163. functions: {
  53164. [key: string]: string;
  53165. };
  53166. /**
  53167. * Gets the target of the compilation state
  53168. */
  53169. target: NodeMaterialBlockTargets;
  53170. /**
  53171. * Gets the list of emitted counters
  53172. */
  53173. counters: {
  53174. [key: string]: number;
  53175. };
  53176. /**
  53177. * Shared data between multiple NodeMaterialBuildState instances
  53178. */
  53179. sharedData: NodeMaterialBuildStateSharedData;
  53180. /** @hidden */
  53181. _vertexState: NodeMaterialBuildState;
  53182. private _attributeDeclaration;
  53183. private _uniformDeclaration;
  53184. private _samplerDeclaration;
  53185. private _varyingTransfer;
  53186. private _repeatableContentAnchorIndex;
  53187. /** @hidden */
  53188. _builtCompilationString: string;
  53189. /**
  53190. * Gets the emitted compilation strings
  53191. */
  53192. compilationString: string;
  53193. /**
  53194. * Finalize the compilation strings
  53195. * @param state defines the current compilation state
  53196. */
  53197. finalize(state: NodeMaterialBuildState): void;
  53198. /** @hidden */
  53199. readonly _repeatableContentAnchor: string;
  53200. /** @hidden */
  53201. _getFreeVariableName(prefix: string): string;
  53202. /** @hidden */
  53203. _getFreeDefineName(prefix: string): string;
  53204. /** @hidden */
  53205. _excludeVariableName(name: string): void;
  53206. /** @hidden */
  53207. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  53208. /** @hidden */
  53209. _emitFunction(name: string, code: string, comments: string): void;
  53210. /** @hidden */
  53211. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  53212. replaceStrings?: {
  53213. search: RegExp;
  53214. replace: string;
  53215. }[];
  53216. repeatKey?: string;
  53217. }): string;
  53218. /** @hidden */
  53219. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  53220. repeatKey?: string;
  53221. removeAttributes?: boolean;
  53222. removeUniforms?: boolean;
  53223. removeVaryings?: boolean;
  53224. removeIfDef?: boolean;
  53225. replaceStrings?: {
  53226. search: RegExp;
  53227. replace: string;
  53228. }[];
  53229. }, storeKey?: string): void;
  53230. /** @hidden */
  53231. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string, type?: Nullable<NodeMaterialBlockConnectionPointTypes>): void;
  53232. private _emitDefine;
  53233. /** @hidden */
  53234. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  53235. }
  53236. }
  53237. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  53238. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53239. /**
  53240. * Root class for all node material optimizers
  53241. */
  53242. export class NodeMaterialOptimizer {
  53243. /**
  53244. * Function used to optimize a NodeMaterial graph
  53245. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  53246. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  53247. */
  53248. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  53249. }
  53250. }
  53251. declare module "babylonjs/Materials/Node/Blocks/vector4TransformBlock" {
  53252. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53253. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53254. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53255. /**
  53256. * Block used to transform a vector4 with a matrix
  53257. */
  53258. export class Vector4TransformBlock extends NodeMaterialBlock {
  53259. /**
  53260. * Defines the value to use to complement Vector3 to transform it to a Vector4
  53261. */
  53262. complementW: number;
  53263. /**
  53264. * Creates a new Vector4TransformBlock
  53265. * @param name defines the block name
  53266. */
  53267. constructor(name: string);
  53268. /**
  53269. * Gets the current class name
  53270. * @returns the class name
  53271. */
  53272. getClassName(): string;
  53273. /**
  53274. * Gets the vector input
  53275. */
  53276. readonly vector: NodeMaterialConnectionPoint;
  53277. /**
  53278. * Gets the output component
  53279. */
  53280. readonly output: NodeMaterialConnectionPoint;
  53281. /**
  53282. * Gets the matrix transform input
  53283. */
  53284. readonly transform: NodeMaterialConnectionPoint;
  53285. protected _buildBlock(state: NodeMaterialBuildState): this;
  53286. }
  53287. }
  53288. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  53289. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53290. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53291. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53292. /**
  53293. * Block used to output the vertex position
  53294. */
  53295. export class VertexOutputBlock extends NodeMaterialBlock {
  53296. /**
  53297. * Creates a new VertexOutputBlock
  53298. * @param name defines the block name
  53299. */
  53300. constructor(name: string);
  53301. /**
  53302. * Gets the current class name
  53303. * @returns the class name
  53304. */
  53305. getClassName(): string;
  53306. /**
  53307. * Gets the vector input component
  53308. */
  53309. readonly vector: NodeMaterialConnectionPoint;
  53310. protected _buildBlock(state: NodeMaterialBuildState): this;
  53311. }
  53312. }
  53313. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  53314. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53315. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53316. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53317. /**
  53318. * Block used to output the final color
  53319. */
  53320. export class FragmentOutputBlock extends NodeMaterialBlock {
  53321. /**
  53322. * Gets or sets a boolean indicating if this block will output an alpha value
  53323. */
  53324. alphaBlendingEnabled: boolean;
  53325. /**
  53326. * Create a new FragmentOutputBlock
  53327. * @param name defines the block name
  53328. */
  53329. constructor(name: string);
  53330. /**
  53331. * Gets the current class name
  53332. * @returns the class name
  53333. */
  53334. getClassName(): string;
  53335. /**
  53336. * Gets the color input component
  53337. */
  53338. readonly color: NodeMaterialConnectionPoint;
  53339. protected _buildBlock(state: NodeMaterialBuildState): this;
  53340. }
  53341. }
  53342. declare module "babylonjs/Materials/Node/nodeMaterial" {
  53343. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53344. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53345. import { Scene } from "babylonjs/scene";
  53346. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53347. import { Matrix } from "babylonjs/Maths/math";
  53348. import { Mesh } from "babylonjs/Meshes/mesh";
  53349. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53350. import { Observable } from "babylonjs/Misc/observable";
  53351. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53352. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53353. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  53354. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53355. import { Nullable } from "babylonjs/types";
  53356. /**
  53357. * Interface used to configure the node material editor
  53358. */
  53359. export interface INodeMaterialEditorOptions {
  53360. /** Define the URl to load node editor script */
  53361. editorURL?: string;
  53362. }
  53363. /** @hidden */
  53364. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  53365. /** BONES */
  53366. NUM_BONE_INFLUENCERS: number;
  53367. BonesPerMesh: number;
  53368. BONETEXTURE: boolean;
  53369. /** MORPH TARGETS */
  53370. MORPHTARGETS: boolean;
  53371. MORPHTARGETS_NORMAL: boolean;
  53372. MORPHTARGETS_TANGENT: boolean;
  53373. MORPHTARGETS_UV: boolean;
  53374. NUM_MORPH_INFLUENCERS: number;
  53375. /** IMAGE PROCESSING */
  53376. IMAGEPROCESSING: boolean;
  53377. VIGNETTE: boolean;
  53378. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53379. VIGNETTEBLENDMODEOPAQUE: boolean;
  53380. TONEMAPPING: boolean;
  53381. TONEMAPPING_ACES: boolean;
  53382. CONTRAST: boolean;
  53383. EXPOSURE: boolean;
  53384. COLORCURVES: boolean;
  53385. COLORGRADING: boolean;
  53386. COLORGRADING3D: boolean;
  53387. SAMPLER3DGREENDEPTH: boolean;
  53388. SAMPLER3DBGRMAP: boolean;
  53389. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53390. constructor();
  53391. setValue(name: string, value: boolean): void;
  53392. }
  53393. /**
  53394. * Class used to configure NodeMaterial
  53395. */
  53396. export interface INodeMaterialOptions {
  53397. /**
  53398. * Defines if blocks should emit comments
  53399. */
  53400. emitComments: boolean;
  53401. }
  53402. /**
  53403. * Class used to create a node based material built by assembling shader blocks
  53404. */
  53405. export class NodeMaterial extends PushMaterial {
  53406. private _options;
  53407. private _vertexCompilationState;
  53408. private _fragmentCompilationState;
  53409. private _sharedData;
  53410. private _buildId;
  53411. private _buildWasSuccessful;
  53412. private _cachedWorldViewMatrix;
  53413. private _cachedWorldViewProjectionMatrix;
  53414. private _textureConnectionPoints;
  53415. private _optimizers;
  53416. /** Define the URl to load node editor script */
  53417. static EditorURL: string;
  53418. private BJSNODEMATERIALEDITOR;
  53419. /** Get the inspector from bundle or global */
  53420. private _getGlobalNodeMaterialEditor;
  53421. /**
  53422. * Defines the maximum number of lights that can be used in the material
  53423. */
  53424. maxSimultaneousLights: number;
  53425. /**
  53426. * Observable raised when the material is built
  53427. */
  53428. onBuildObservable: Observable<NodeMaterial>;
  53429. /**
  53430. * Gets or sets the root nodes of the material vertex shader
  53431. */
  53432. _vertexOutputNodes: NodeMaterialBlock[];
  53433. /**
  53434. * Gets or sets the root nodes of the material fragment (pixel) shader
  53435. */
  53436. _fragmentOutputNodes: NodeMaterialBlock[];
  53437. /** Gets or sets options to control the node material overall behavior */
  53438. options: INodeMaterialOptions;
  53439. /**
  53440. * Default configuration related to image processing available in the standard Material.
  53441. */
  53442. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53443. /**
  53444. * Gets the image processing configuration used either in this material.
  53445. */
  53446. /**
  53447. * Sets the Default image processing configuration used either in the this material.
  53448. *
  53449. * If sets to null, the scene one is in use.
  53450. */
  53451. imageProcessingConfiguration: ImageProcessingConfiguration;
  53452. /**
  53453. * Create a new node based material
  53454. * @param name defines the material name
  53455. * @param scene defines the hosting scene
  53456. * @param options defines creation option
  53457. */
  53458. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  53459. /**
  53460. * Gets the current class name of the material e.g. "NodeMaterial"
  53461. * @returns the class name
  53462. */
  53463. getClassName(): string;
  53464. /**
  53465. * Keep track of the image processing observer to allow dispose and replace.
  53466. */
  53467. private _imageProcessingObserver;
  53468. /**
  53469. * Attaches a new image processing configuration to the Standard Material.
  53470. * @param configuration
  53471. */
  53472. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53473. /**
  53474. * Adds a new optimizer to the list of optimizers
  53475. * @param optimizer defines the optimizers to add
  53476. * @returns the current material
  53477. */
  53478. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53479. /**
  53480. * Remove an optimizer from the list of optimizers
  53481. * @param optimizer defines the optimizers to remove
  53482. * @returns the current material
  53483. */
  53484. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53485. /**
  53486. * Add a new block to the list of output nodes
  53487. * @param node defines the node to add
  53488. * @returns the current material
  53489. */
  53490. addOutputNode(node: NodeMaterialBlock): this;
  53491. /**
  53492. * Remove a block from the list of root nodes
  53493. * @param node defines the node to remove
  53494. * @returns the current material
  53495. */
  53496. removeOutputNode(node: NodeMaterialBlock): this;
  53497. private _addVertexOutputNode;
  53498. private _removeVertexOutputNode;
  53499. private _addFragmentOutputNode;
  53500. private _removeFragmentOutputNode;
  53501. /**
  53502. * Specifies if the material will require alpha blending
  53503. * @returns a boolean specifying if alpha blending is needed
  53504. */
  53505. needAlphaBlending(): boolean;
  53506. /**
  53507. * Specifies if this material should be rendered in alpha test mode
  53508. * @returns a boolean specifying if an alpha test is needed.
  53509. */
  53510. needAlphaTesting(): boolean;
  53511. private _initializeBlock;
  53512. private _resetDualBlocks;
  53513. /**
  53514. * Build the material and generates the inner effect
  53515. * @param verbose defines if the build should log activity
  53516. */
  53517. build(verbose?: boolean): void;
  53518. /**
  53519. * Runs an otpimization phase to try to improve the shader code
  53520. */
  53521. optimize(): void;
  53522. private _prepareDefinesForAttributes;
  53523. /**
  53524. * Get if the submesh is ready to be used and all its information available.
  53525. * Child classes can use it to update shaders
  53526. * @param mesh defines the mesh to check
  53527. * @param subMesh defines which submesh to check
  53528. * @param useInstances specifies that instances should be used
  53529. * @returns a boolean indicating that the submesh is ready or not
  53530. */
  53531. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53532. /**
  53533. * Binds the world matrix to the material
  53534. * @param world defines the world transformation matrix
  53535. */
  53536. bindOnlyWorldMatrix(world: Matrix): void;
  53537. /**
  53538. * Binds the submesh to this material by preparing the effect and shader to draw
  53539. * @param world defines the world transformation matrix
  53540. * @param mesh defines the mesh containing the submesh
  53541. * @param subMesh defines the submesh to bind the material to
  53542. */
  53543. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53544. /**
  53545. * Gets the active textures from the material
  53546. * @returns an array of textures
  53547. */
  53548. getActiveTextures(): BaseTexture[];
  53549. /**
  53550. * Specifies if the material uses a texture
  53551. * @param texture defines the texture to check against the material
  53552. * @returns a boolean specifying if the material uses the texture
  53553. */
  53554. hasTexture(texture: BaseTexture): boolean;
  53555. /**
  53556. * Disposes the material
  53557. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  53558. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  53559. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  53560. */
  53561. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53562. /** Creates the node editor window. */
  53563. private _createNodeEditor;
  53564. /**
  53565. * Launch the node material editor
  53566. * @param config Define the configuration of the editor
  53567. * @return a promise fulfilled when the node editor is visible
  53568. */
  53569. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53570. /**
  53571. * Clear the current material
  53572. */
  53573. clear(): void;
  53574. /**
  53575. * Clear the current material and set it to a default state
  53576. */
  53577. setToDefault(): void;
  53578. }
  53579. }
  53580. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  53581. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53582. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53583. import { Nullable } from "babylonjs/types";
  53584. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53585. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53586. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53588. import { Mesh } from "babylonjs/Meshes/mesh";
  53589. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53590. /**
  53591. * Defines a block that can be used inside a node based material
  53592. */
  53593. export class NodeMaterialBlock {
  53594. private _buildId;
  53595. private _target;
  53596. private _isFinalMerger;
  53597. /** @hidden */
  53598. _inputs: NodeMaterialConnectionPoint[];
  53599. /** @hidden */
  53600. _outputs: NodeMaterialConnectionPoint[];
  53601. /**
  53602. * Gets or sets the name of the block
  53603. */
  53604. name: string;
  53605. /**
  53606. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  53607. */
  53608. readonly isFinalMerger: boolean;
  53609. /**
  53610. * Gets or sets the build Id
  53611. */
  53612. buildId: number;
  53613. /**
  53614. * Gets or sets the target of the block
  53615. */
  53616. target: NodeMaterialBlockTargets;
  53617. /**
  53618. * Gets the list of input points
  53619. */
  53620. readonly inputs: NodeMaterialConnectionPoint[];
  53621. /** Gets the list of output points */
  53622. readonly outputs: NodeMaterialConnectionPoint[];
  53623. /**
  53624. * Find an input by its name
  53625. * @param name defines the name of the input to look for
  53626. * @returns the input or null if not found
  53627. */
  53628. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53629. /**
  53630. * Find an output by its name
  53631. * @param name defines the name of the outputto look for
  53632. * @returns the output or null if not found
  53633. */
  53634. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53635. /**
  53636. * Creates a new NodeMaterialBlock
  53637. * @param name defines the block name
  53638. * @param target defines the target of that block (Vertex by default)
  53639. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  53640. */
  53641. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  53642. /**
  53643. * Initialize the block and prepare the context for build
  53644. * @param state defines the state that will be used for the build
  53645. */
  53646. initialize(state: NodeMaterialBuildState): void;
  53647. /**
  53648. * Bind data to effect. Will only be called for blocks with isBindable === true
  53649. * @param effect defines the effect to bind data to
  53650. * @param nodeMaterial defines the hosting NodeMaterial
  53651. * @param mesh defines the mesh that will be rendered
  53652. */
  53653. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53654. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  53655. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  53656. protected _writeFloat(value: number): string;
  53657. /**
  53658. * Gets the current class name e.g. "NodeMaterialBlock"
  53659. * @returns the class name
  53660. */
  53661. getClassName(): string;
  53662. /**
  53663. * Register a new input. Must be called inside a block constructor
  53664. * @param name defines the connection point name
  53665. * @param type defines the connection point type
  53666. * @param isOptional defines a boolean indicating that this input can be omitted
  53667. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  53668. * @returns the current block
  53669. */
  53670. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  53671. /**
  53672. * Register a new output. Must be called inside a block constructor
  53673. * @param name defines the connection point name
  53674. * @param type defines the connection point type
  53675. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  53676. * @returns the current block
  53677. */
  53678. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  53679. /**
  53680. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  53681. * @param forOutput defines an optional connection point to check compatibility with
  53682. * @returns the first available input or null
  53683. */
  53684. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  53685. /**
  53686. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  53687. * @param forBlock defines an optional block to check compatibility with
  53688. * @returns the first available input or null
  53689. */
  53690. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  53691. /**
  53692. * Connect current block with another block
  53693. * @param other defines the block to connect with
  53694. * @param options define the various options to help pick the right connections
  53695. * @returns the current block
  53696. */
  53697. connectTo(other: NodeMaterialBlock, options?: {
  53698. input?: string;
  53699. output?: string;
  53700. outputSwizzle?: string;
  53701. }): this | undefined;
  53702. protected _buildBlock(state: NodeMaterialBuildState): void;
  53703. /**
  53704. * Add uniforms, samplers and uniform buffers at compilation time
  53705. * @param state defines the state to update
  53706. * @param nodeMaterial defines the node material requesting the update
  53707. * @param defines defines the material defines to update
  53708. */
  53709. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53710. /**
  53711. * Add potential fallbacks if shader compilation fails
  53712. * @param mesh defines the mesh to be rendered
  53713. * @param fallbacks defines the current prioritized list of fallbacks
  53714. */
  53715. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53716. /**
  53717. * Update defines for shader compilation
  53718. * @param mesh defines the mesh to be rendered
  53719. * @param nodeMaterial defines the node material requesting the update
  53720. * @param defines defines the material defines to update
  53721. * @param useInstances specifies that instances should be used
  53722. */
  53723. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53724. /**
  53725. * Lets the block try to connect some inputs automatically
  53726. */
  53727. autoConfigure(): void;
  53728. /**
  53729. * Function called when a block is declared as repeatable content generator
  53730. * @param vertexShaderState defines the current compilation state for the vertex shader
  53731. * @param fragmentShaderState defines the current compilation state for the fragment shader
  53732. * @param mesh defines the mesh to be rendered
  53733. * @param defines defines the material defines to update
  53734. */
  53735. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53736. /**
  53737. * Checks if the block is ready
  53738. * @param mesh defines the mesh to be rendered
  53739. * @param nodeMaterial defines the node material requesting the update
  53740. * @param defines defines the material defines to update
  53741. * @param useInstances specifies that instances should be used
  53742. * @returns true if the block is ready
  53743. */
  53744. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53745. /**
  53746. * Compile the current node and generate the shader code
  53747. * @param state defines the current compilation state (uniforms, samplers, current string)
  53748. * @returns the current block
  53749. */
  53750. build(state: NodeMaterialBuildState): this | undefined;
  53751. }
  53752. }
  53753. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  53754. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53755. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53756. import { Nullable } from "babylonjs/types";
  53757. import { Effect } from "babylonjs/Materials/effect";
  53758. import { NodeMaterialWellKnownValues } from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  53759. import { Scene } from "babylonjs/scene";
  53760. import { Matrix } from "babylonjs/Maths/math";
  53761. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53762. /**
  53763. * Defines a connection point for a block
  53764. */
  53765. export class NodeMaterialConnectionPoint {
  53766. /** @hidden */
  53767. _ownerBlock: NodeMaterialBlock;
  53768. /** @hidden */
  53769. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53770. private _associatedVariableName;
  53771. private _endpoints;
  53772. private _storedValue;
  53773. private _valueCallback;
  53774. private _mode;
  53775. /** @hidden */
  53776. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  53777. /** @hidden */
  53778. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53779. /** @hidden */
  53780. _needToEmitVarying: boolean;
  53781. /** @hidden */
  53782. _forceUniformInVertexShaderOnly: boolean;
  53783. private _type;
  53784. /**
  53785. * Gets or sets the connection point type (default is float)
  53786. */
  53787. type: NodeMaterialBlockConnectionPointTypes;
  53788. /**
  53789. * Gets or sets the connection point name
  53790. */
  53791. name: string;
  53792. /**
  53793. * Gets or sets the swizzle to apply to this connection point when reading or writing
  53794. */
  53795. swizzle: string;
  53796. /**
  53797. * Gets or sets a boolean indicating that this connection point can be omitted
  53798. */
  53799. isOptional: boolean;
  53800. /**
  53801. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53802. */
  53803. define: string;
  53804. /** Gets or sets the target of that connection point */
  53805. target: NodeMaterialBlockTargets;
  53806. /**
  53807. * Gets or sets the value of that point.
  53808. * Please note that this value will be ignored if valueCallback is defined
  53809. */
  53810. value: any;
  53811. /**
  53812. * Gets or sets a callback used to get the value of that point.
  53813. * Please note that setting this value will force the connection point to ignore the value property
  53814. */
  53815. valueCallback: () => any;
  53816. /**
  53817. * Gets or sets the associated variable name in the shader
  53818. */
  53819. associatedVariableName: string;
  53820. /**
  53821. * Gets a boolean indicating that this connection point not defined yet
  53822. */
  53823. readonly isUndefined: boolean;
  53824. /**
  53825. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53826. * In this case the connection point name must be the name of the uniform to use.
  53827. * Can only be set on inputs
  53828. */
  53829. isUniform: boolean;
  53830. /**
  53831. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53832. * In this case the connection point name must be the name of the attribute to use
  53833. * Can only be set on inputs
  53834. */
  53835. isAttribute: boolean;
  53836. /**
  53837. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53838. * Can only be set on exit points
  53839. */
  53840. isVarying: boolean;
  53841. /** Get the other side of the connection (if any) */
  53842. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53843. /** Get the block that owns this connection point */
  53844. readonly ownerBlock: NodeMaterialBlock;
  53845. /** Get the block connected on the other side of this connection (if any) */
  53846. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53847. /** Get the block connected on the endpoints of this connection (if any) */
  53848. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53849. /**
  53850. * Creates a new connection point
  53851. * @param name defines the connection point name
  53852. * @param ownerBlock defines the block hosting this connection point
  53853. */
  53854. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53855. /**
  53856. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53857. * @returns the class name
  53858. */
  53859. getClassName(): string;
  53860. /**
  53861. * Set the source of this connection point to a vertex attribute
  53862. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53863. * @returns the current connection point
  53864. */
  53865. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  53866. /**
  53867. * Set the source of this connection point to a well known value
  53868. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  53869. * @returns the current connection point
  53870. */
  53871. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  53872. /**
  53873. * Gets a boolean indicating that the current connection point is a well known value
  53874. */
  53875. readonly isWellKnownValue: boolean;
  53876. /**
  53877. * Gets or sets the current well known value or null if not defined as well know value
  53878. */
  53879. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  53880. private _getTypeLength;
  53881. /**
  53882. * Gets an boolean indicating if the current point can be connected to another point
  53883. * @param connectionPoint defines the other connection point
  53884. * @returns true if the connection is possible
  53885. */
  53886. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  53887. /**
  53888. * Connect this point to another connection point
  53889. * @param connectionPoint defines the other connection point
  53890. * @returns the current connection point
  53891. */
  53892. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53893. /**
  53894. * Disconnect this point from one of his endpoint
  53895. * @param endpoint defines the other connection point
  53896. * @returns the current connection point
  53897. */
  53898. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53899. /**
  53900. * When connection point is an uniform, this function will send its value to the effect
  53901. * @param effect defines the effect to transmit value to
  53902. * @param world defines the world matrix
  53903. * @param worldView defines the worldxview matrix
  53904. * @param worldViewProjection defines the worldxviewxprojection matrix
  53905. */
  53906. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53907. /**
  53908. * When connection point is an uniform, this function will send its value to the effect
  53909. * @param effect defines the effect to transmit value to
  53910. * @param scene defines the hosting scene
  53911. */
  53912. transmit(effect: Effect, scene: Scene): void;
  53913. }
  53914. }
  53915. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  53916. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53917. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53918. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53919. import { Mesh } from "babylonjs/Meshes/mesh";
  53920. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53921. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53922. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53923. /**
  53924. * Block used to add support for vertex skinning (bones)
  53925. */
  53926. export class BonesBlock extends NodeMaterialBlock {
  53927. /**
  53928. * Creates a new BonesBlock
  53929. * @param name defines the block name
  53930. */
  53931. constructor(name: string);
  53932. /**
  53933. * Initialize the block and prepare the context for build
  53934. * @param state defines the state that will be used for the build
  53935. */
  53936. initialize(state: NodeMaterialBuildState): void;
  53937. /**
  53938. * Gets the current class name
  53939. * @returns the class name
  53940. */
  53941. getClassName(): string;
  53942. /**
  53943. * Gets the matrix indices input component
  53944. */
  53945. readonly matricesIndices: NodeMaterialConnectionPoint;
  53946. /**
  53947. * Gets the matrix weights input component
  53948. */
  53949. readonly matricesWeights: NodeMaterialConnectionPoint;
  53950. /**
  53951. * Gets the extra matrix indices input component
  53952. */
  53953. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53954. /**
  53955. * Gets the extra matrix weights input component
  53956. */
  53957. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53958. /**
  53959. * Gets the world input component
  53960. */
  53961. readonly world: NodeMaterialConnectionPoint;
  53962. /**
  53963. * Gets the output component
  53964. */
  53965. readonly output: NodeMaterialConnectionPoint;
  53966. autoConfigure(): void;
  53967. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53968. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53969. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53970. protected _buildBlock(state: NodeMaterialBuildState): this;
  53971. }
  53972. }
  53973. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  53974. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53975. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53976. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53977. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53978. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53979. /**
  53980. * Block used to add support for instances
  53981. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53982. */
  53983. export class InstancesBlock extends NodeMaterialBlock {
  53984. /**
  53985. * Creates a new InstancesBlock
  53986. * @param name defines the block name
  53987. */
  53988. constructor(name: string);
  53989. /**
  53990. * Gets the current class name
  53991. * @returns the class name
  53992. */
  53993. getClassName(): string;
  53994. /**
  53995. * Gets the first world row input component
  53996. */
  53997. readonly world0: NodeMaterialConnectionPoint;
  53998. /**
  53999. * Gets the second world row input component
  54000. */
  54001. readonly world1: NodeMaterialConnectionPoint;
  54002. /**
  54003. * Gets the third world row input component
  54004. */
  54005. readonly world2: NodeMaterialConnectionPoint;
  54006. /**
  54007. * Gets the forth world row input component
  54008. */
  54009. readonly world3: NodeMaterialConnectionPoint;
  54010. /**
  54011. * Gets the world input component
  54012. */
  54013. readonly world: NodeMaterialConnectionPoint;
  54014. /**
  54015. * Gets the output component
  54016. */
  54017. readonly output: NodeMaterialConnectionPoint;
  54018. autoConfigure(): void;
  54019. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54020. protected _buildBlock(state: NodeMaterialBuildState): this;
  54021. }
  54022. }
  54023. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  54024. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54025. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54026. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54027. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54028. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54029. import { Effect } from "babylonjs/Materials/effect";
  54030. import { Mesh } from "babylonjs/Meshes/mesh";
  54031. /**
  54032. * Block used to add morph targets support to vertex shader
  54033. */
  54034. export class MorphTargetsBlock extends NodeMaterialBlock {
  54035. private _repeatableContentAnchor;
  54036. private _repeatebleContentGenerated;
  54037. /**
  54038. * Create a new MorphTargetsBlock
  54039. * @param name defines the block name
  54040. */
  54041. constructor(name: string);
  54042. /**
  54043. * Gets the current class name
  54044. * @returns the class name
  54045. */
  54046. getClassName(): string;
  54047. /**
  54048. * Gets the position input component
  54049. */
  54050. readonly position: NodeMaterialConnectionPoint;
  54051. /**
  54052. * Gets the normal input component
  54053. */
  54054. readonly normal: NodeMaterialConnectionPoint;
  54055. /**
  54056. * Gets the tangent input component
  54057. */
  54058. readonly tangent: NodeMaterialConnectionPoint;
  54059. /**
  54060. * Gets the tangent input component
  54061. */
  54062. readonly uv: NodeMaterialConnectionPoint;
  54063. /**
  54064. * Gets the position output component
  54065. */
  54066. readonly positionOutput: NodeMaterialConnectionPoint;
  54067. /**
  54068. * Gets the normal output component
  54069. */
  54070. readonly normalOutput: NodeMaterialConnectionPoint;
  54071. /**
  54072. * Gets the tangent output component
  54073. */
  54074. readonly tangentOutput: NodeMaterialConnectionPoint;
  54075. /**
  54076. * Gets the tangent output component
  54077. */
  54078. readonly uvOutput: NodeMaterialConnectionPoint;
  54079. initialize(state: NodeMaterialBuildState): void;
  54080. autoConfigure(): void;
  54081. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54082. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54083. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54084. protected _buildBlock(state: NodeMaterialBuildState): this;
  54085. }
  54086. }
  54087. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  54088. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  54089. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  54090. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  54091. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  54092. }
  54093. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  54094. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54095. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54096. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54097. /**
  54098. * Block used to add an alpha test in the fragment shader
  54099. */
  54100. export class AlphaTestBlock extends NodeMaterialBlock {
  54101. /**
  54102. * Gets or sets the alpha value where alpha testing happens
  54103. */
  54104. alphaCutOff: number;
  54105. /**
  54106. * Create a new AlphaTestBlock
  54107. * @param name defines the block name
  54108. */
  54109. constructor(name: string);
  54110. /**
  54111. * Gets the current class name
  54112. * @returns the class name
  54113. */
  54114. getClassName(): string;
  54115. /**
  54116. * Gets the color input component
  54117. */
  54118. readonly color: NodeMaterialConnectionPoint;
  54119. protected _buildBlock(state: NodeMaterialBuildState): this;
  54120. }
  54121. }
  54122. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock" {
  54123. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54124. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54125. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54126. /**
  54127. * Block used to create a Color4 out of 4 inputs (one for each component)
  54128. */
  54129. export class RGBAMergerBlock extends NodeMaterialBlock {
  54130. /**
  54131. * Create a new RGBAMergerBlock
  54132. * @param name defines the block name
  54133. */
  54134. constructor(name: string);
  54135. /**
  54136. * Gets the current class name
  54137. * @returns the class name
  54138. */
  54139. getClassName(): string;
  54140. /**
  54141. * Gets the R input component
  54142. */
  54143. readonly r: NodeMaterialConnectionPoint;
  54144. /**
  54145. * Gets the G input component
  54146. */
  54147. readonly g: NodeMaterialConnectionPoint;
  54148. /**
  54149. * Gets the B input component
  54150. */
  54151. readonly b: NodeMaterialConnectionPoint;
  54152. /**
  54153. * Gets the RGB input component
  54154. */
  54155. readonly rgb: NodeMaterialConnectionPoint;
  54156. /**
  54157. * Gets the R input component
  54158. */
  54159. readonly a: NodeMaterialConnectionPoint;
  54160. /**
  54161. * Gets the output component
  54162. */
  54163. readonly output: NodeMaterialConnectionPoint;
  54164. protected _buildBlock(state: NodeMaterialBuildState): this;
  54165. }
  54166. }
  54167. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock" {
  54168. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54169. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54170. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54171. /**
  54172. * Block used to create a Color3 out of 3 inputs (one for each component)
  54173. */
  54174. export class RGBMergerBlock extends NodeMaterialBlock {
  54175. /**
  54176. * Create a new RGBMergerBlock
  54177. * @param name defines the block name
  54178. */
  54179. constructor(name: string);
  54180. /**
  54181. * Gets the current class name
  54182. * @returns the class name
  54183. */
  54184. getClassName(): string;
  54185. /**
  54186. * Gets the R component input
  54187. */
  54188. readonly r: NodeMaterialConnectionPoint;
  54189. /**
  54190. * Gets the G component input
  54191. */
  54192. readonly g: NodeMaterialConnectionPoint;
  54193. /**
  54194. * Gets the B component input
  54195. */
  54196. readonly b: NodeMaterialConnectionPoint;
  54197. /**
  54198. * Gets the output component
  54199. */
  54200. readonly output: NodeMaterialConnectionPoint;
  54201. protected _buildBlock(state: NodeMaterialBuildState): this;
  54202. }
  54203. }
  54204. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock" {
  54205. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54206. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54207. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54208. /**
  54209. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  54210. */
  54211. export class RGBASplitterBlock extends NodeMaterialBlock {
  54212. /**
  54213. * Create a new RGBASplitterBlock
  54214. * @param name defines the block name
  54215. */
  54216. constructor(name: string);
  54217. /**
  54218. * Gets the current class name
  54219. * @returns the class name
  54220. */
  54221. getClassName(): string;
  54222. /**
  54223. * Gets the input component
  54224. */
  54225. readonly input: NodeMaterialConnectionPoint;
  54226. protected _buildBlock(state: NodeMaterialBuildState): this;
  54227. }
  54228. }
  54229. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock" {
  54230. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54231. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54232. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54233. /**
  54234. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  54235. */
  54236. export class RGBSplitterBlock extends NodeMaterialBlock {
  54237. /**
  54238. * Create a new RGBSplitterBlock
  54239. * @param name defines the block name
  54240. */
  54241. constructor(name: string);
  54242. /**
  54243. * Gets the current class name
  54244. * @returns the class name
  54245. */
  54246. getClassName(): string;
  54247. /**
  54248. * Gets the input component
  54249. */
  54250. readonly input: NodeMaterialConnectionPoint;
  54251. protected _buildBlock(state: NodeMaterialBuildState): this;
  54252. }
  54253. }
  54254. declare module "babylonjs/Materials/Node/Blocks/Fragment/textureBlock" {
  54255. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54256. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54257. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54258. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54259. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54260. /**
  54261. * Block used to read a texture from a sampler
  54262. */
  54263. export class TextureBlock extends NodeMaterialBlock {
  54264. private _defineName;
  54265. /**
  54266. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  54267. */
  54268. autoConnectTextureMatrix: boolean;
  54269. /**
  54270. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  54271. */
  54272. autoSelectUV: boolean;
  54273. /**
  54274. * Create a new TextureBlock
  54275. * @param name defines the block name
  54276. */
  54277. constructor(name: string);
  54278. /**
  54279. * Gets the current class name
  54280. * @returns the class name
  54281. */
  54282. getClassName(): string;
  54283. /**
  54284. * Gets the uv input component
  54285. */
  54286. readonly uv: NodeMaterialConnectionPoint;
  54287. /**
  54288. * Gets the texture information input component
  54289. */
  54290. readonly textureInfo: NodeMaterialConnectionPoint;
  54291. /**
  54292. * Gets the transformed uv input component
  54293. */
  54294. readonly transformedUV: NodeMaterialConnectionPoint;
  54295. /**
  54296. * Gets the texture input component
  54297. */
  54298. readonly texture: NodeMaterialConnectionPoint;
  54299. /**
  54300. * Gets the texture transform input component
  54301. */
  54302. readonly textureTransform: NodeMaterialConnectionPoint;
  54303. /**
  54304. * Gets the output component
  54305. */
  54306. readonly output: NodeMaterialConnectionPoint;
  54307. autoConfigure(): void;
  54308. initialize(state: NodeMaterialBuildState): void;
  54309. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54310. isReady(): boolean;
  54311. private _injectVertexCode;
  54312. protected _buildBlock(state: NodeMaterialBuildState): this;
  54313. }
  54314. }
  54315. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  54316. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54317. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54318. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54319. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54320. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54321. import { Effect } from "babylonjs/Materials/effect";
  54322. import { Mesh } from "babylonjs/Meshes/mesh";
  54323. /**
  54324. * Block used to add image processing support to fragment shader
  54325. */
  54326. export class ImageProcessingBlock extends NodeMaterialBlock {
  54327. /**
  54328. * Create a new ImageProcessingBlock
  54329. * @param name defines the block name
  54330. */
  54331. constructor(name: string);
  54332. /**
  54333. * Gets the current class name
  54334. * @returns the class name
  54335. */
  54336. getClassName(): string;
  54337. /**
  54338. * Gets the color input component
  54339. */
  54340. readonly color: NodeMaterialConnectionPoint;
  54341. /**
  54342. * Gets the output component
  54343. */
  54344. readonly output: NodeMaterialConnectionPoint;
  54345. /**
  54346. * Initialize the block and prepare the context for build
  54347. * @param state defines the state that will be used for the build
  54348. */
  54349. initialize(state: NodeMaterialBuildState): void;
  54350. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  54351. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54352. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54353. protected _buildBlock(state: NodeMaterialBuildState): this;
  54354. }
  54355. }
  54356. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  54357. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  54358. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  54359. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock";
  54360. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock";
  54361. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock";
  54362. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock";
  54363. export * from "babylonjs/Materials/Node/Blocks/Fragment/textureBlock";
  54364. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  54365. }
  54366. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  54367. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54368. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54369. import { Mesh } from "babylonjs/Meshes/mesh";
  54370. import { Effect } from "babylonjs/Materials/effect";
  54371. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54372. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54373. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54374. /**
  54375. * Block used to add support for scene fog
  54376. */
  54377. export class FogBlock extends NodeMaterialBlock {
  54378. /**
  54379. * Create a new FogBlock
  54380. * @param name defines the block name
  54381. */
  54382. constructor(name: string);
  54383. /**
  54384. * Gets the current class name
  54385. * @returns the class name
  54386. */
  54387. getClassName(): string;
  54388. /**
  54389. * Gets the world position input component
  54390. */
  54391. readonly worldPosition: NodeMaterialConnectionPoint;
  54392. /**
  54393. * Gets the view input component
  54394. */
  54395. readonly view: NodeMaterialConnectionPoint;
  54396. /**
  54397. * Gets the color input component
  54398. */
  54399. readonly color: NodeMaterialConnectionPoint;
  54400. /**
  54401. * Gets the fog color input component
  54402. */
  54403. readonly fogColor: NodeMaterialConnectionPoint;
  54404. /**
  54405. * Gets the for parameter input component
  54406. */
  54407. readonly fogParameters: NodeMaterialConnectionPoint;
  54408. /**
  54409. * Gets the output component
  54410. */
  54411. readonly output: NodeMaterialConnectionPoint;
  54412. autoConfigure(): void;
  54413. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54414. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54415. protected _buildBlock(state: NodeMaterialBuildState): this;
  54416. }
  54417. }
  54418. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  54419. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54420. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54421. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54422. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54423. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54424. import { Effect } from "babylonjs/Materials/effect";
  54425. import { Mesh } from "babylonjs/Meshes/mesh";
  54426. /**
  54427. * Block used to add light in the fragment shader
  54428. */
  54429. export class LightBlock extends NodeMaterialBlock {
  54430. private _lightId;
  54431. /**
  54432. * Create a new LightBlock
  54433. * @param name defines the block name
  54434. */
  54435. constructor(name: string);
  54436. /**
  54437. * Gets the current class name
  54438. * @returns the class name
  54439. */
  54440. getClassName(): string;
  54441. /**
  54442. * Gets the world position input component
  54443. */
  54444. readonly worldPosition: NodeMaterialConnectionPoint;
  54445. /**
  54446. * Gets the world normal input component
  54447. */
  54448. readonly worldNormal: NodeMaterialConnectionPoint;
  54449. /**
  54450. * Gets the light input component.
  54451. * If not defined, all lights will be considered
  54452. */
  54453. readonly light: NodeMaterialConnectionPoint;
  54454. /**
  54455. * Gets the camera (or eye) position component
  54456. */
  54457. readonly cameraPosition: NodeMaterialConnectionPoint;
  54458. /**
  54459. * Gets the diffuse output component
  54460. */
  54461. readonly diffuseOutput: NodeMaterialConnectionPoint;
  54462. /**
  54463. * Gets the specular output component
  54464. */
  54465. readonly specularOutput: NodeMaterialConnectionPoint;
  54466. autoConfigure(): void;
  54467. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54468. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54469. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54470. private _injectVertexCode;
  54471. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54472. }
  54473. }
  54474. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  54475. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  54476. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  54477. }
  54478. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  54479. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54480. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54481. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54482. /**
  54483. * Block used to multiply 2 vector4
  54484. */
  54485. export class MultiplyBlock extends NodeMaterialBlock {
  54486. /**
  54487. * Creates a new MultiplyBlock
  54488. * @param name defines the block name
  54489. */
  54490. constructor(name: string);
  54491. /**
  54492. * Gets the current class name
  54493. * @returns the class name
  54494. */
  54495. getClassName(): string;
  54496. /**
  54497. * Gets the left operand input component
  54498. */
  54499. readonly left: NodeMaterialConnectionPoint;
  54500. /**
  54501. * Gets the right operand input component
  54502. */
  54503. readonly right: NodeMaterialConnectionPoint;
  54504. /**
  54505. * Gets the output component
  54506. */
  54507. readonly output: NodeMaterialConnectionPoint;
  54508. protected _buildBlock(state: NodeMaterialBuildState): this;
  54509. }
  54510. }
  54511. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  54512. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54513. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54514. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54515. /**
  54516. * Block used to add 2 vector4
  54517. */
  54518. export class AddBlock extends NodeMaterialBlock {
  54519. /**
  54520. * Creates a new AddBlock
  54521. * @param name defines the block name
  54522. */
  54523. constructor(name: string);
  54524. /**
  54525. * Gets the current class name
  54526. * @returns the class name
  54527. */
  54528. getClassName(): string;
  54529. /**
  54530. * Gets the left operand input component
  54531. */
  54532. readonly left: NodeMaterialConnectionPoint;
  54533. /**
  54534. * Gets the right operand input component
  54535. */
  54536. readonly right: NodeMaterialConnectionPoint;
  54537. /**
  54538. * Gets the output component
  54539. */
  54540. readonly output: NodeMaterialConnectionPoint;
  54541. protected _buildBlock(state: NodeMaterialBuildState): this;
  54542. }
  54543. }
  54544. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  54545. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54546. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54547. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54548. /**
  54549. * Block used to clamp a float
  54550. */
  54551. export class ClampBlock extends NodeMaterialBlock {
  54552. /** Gets or sets the minimum range */
  54553. minimum: number;
  54554. /** Gets or sets the maximum range */
  54555. maximum: number;
  54556. /**
  54557. * Creates a new ClampBlock
  54558. * @param name defines the block name
  54559. */
  54560. constructor(name: string);
  54561. /**
  54562. * Gets the current class name
  54563. * @returns the class name
  54564. */
  54565. getClassName(): string;
  54566. /**
  54567. * Gets the value input component
  54568. */
  54569. readonly value: NodeMaterialConnectionPoint;
  54570. /**
  54571. * Gets the output component
  54572. */
  54573. readonly output: NodeMaterialConnectionPoint;
  54574. protected _buildBlock(state: NodeMaterialBuildState): this;
  54575. }
  54576. }
  54577. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  54578. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54579. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54580. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54581. /**
  54582. * Block used to scale a value
  54583. */
  54584. export class ScaleBlock extends NodeMaterialBlock {
  54585. /**
  54586. * Creates a new ScaleBlock
  54587. * @param name defines the block name
  54588. */
  54589. constructor(name: string);
  54590. /**
  54591. * Gets the current class name
  54592. * @returns the class name
  54593. */
  54594. getClassName(): string;
  54595. /**
  54596. * Gets the value operand input component
  54597. */
  54598. readonly value: NodeMaterialConnectionPoint;
  54599. /**
  54600. * Gets the scale operand input component
  54601. */
  54602. readonly scale: NodeMaterialConnectionPoint;
  54603. /**
  54604. * Gets the output component
  54605. */
  54606. readonly output: NodeMaterialConnectionPoint;
  54607. protected _buildBlock(state: NodeMaterialBuildState): this;
  54608. }
  54609. }
  54610. declare module "babylonjs/Materials/Node/Blocks/vector2TransformBlock" {
  54611. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54612. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54613. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54614. /**
  54615. * Block used to transform a vector2 with a matrix
  54616. */
  54617. export class Vector2TransformBlock extends NodeMaterialBlock {
  54618. /**
  54619. * Defines the value to use to complement Vector2 to transform it to a Vector4
  54620. */
  54621. complementZ: number;
  54622. /**
  54623. * Defines the value to use to complement Vector2 to transform it to a Vector4
  54624. */
  54625. complementW: number;
  54626. /**
  54627. * Creates a new Vector2TransformBlock
  54628. * @param name defines the block name
  54629. */
  54630. constructor(name: string);
  54631. /**
  54632. * Gets the vector input
  54633. */
  54634. readonly vector: NodeMaterialConnectionPoint;
  54635. /**
  54636. * Gets the matrix transform input
  54637. */
  54638. readonly transform: NodeMaterialConnectionPoint;
  54639. /**
  54640. * Gets the output component
  54641. */
  54642. readonly output: NodeMaterialConnectionPoint;
  54643. /**
  54644. * Gets the current class name
  54645. * @returns the class name
  54646. */
  54647. getClassName(): string;
  54648. protected _buildBlock(state: NodeMaterialBuildState): this;
  54649. }
  54650. }
  54651. declare module "babylonjs/Materials/Node/Blocks/vector3TransformBlock" {
  54652. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54653. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54654. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54655. /**
  54656. * Block used to transform a vector3 with a matrix
  54657. */
  54658. export class Vector3TransformBlock extends NodeMaterialBlock {
  54659. /**
  54660. * Defines the value to use to complement Vector3 to transform it to a Vector4
  54661. */
  54662. complement: number;
  54663. /**
  54664. * Creates a new Vector3TransformBlock
  54665. * @param name defines the block name
  54666. */
  54667. constructor(name: string);
  54668. /**
  54669. * Gets the vector input
  54670. */
  54671. readonly vector: NodeMaterialConnectionPoint;
  54672. /**
  54673. * Gets the matrix transform input
  54674. */
  54675. readonly transform: NodeMaterialConnectionPoint;
  54676. /**
  54677. * Gets the output component
  54678. */
  54679. readonly output: NodeMaterialConnectionPoint;
  54680. /**
  54681. * Gets the current class name
  54682. * @returns the class name
  54683. */
  54684. getClassName(): string;
  54685. protected _buildBlock(state: NodeMaterialBuildState): this;
  54686. }
  54687. }
  54688. declare module "babylonjs/Materials/Node/Blocks/matrixMultiplicationBlock" {
  54689. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54690. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54691. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54692. /**
  54693. * Block used to multiply two matrices
  54694. */
  54695. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  54696. /**
  54697. * Creates a new MatrixMultiplicationBlock
  54698. * @param name defines the block name
  54699. */
  54700. constructor(name: string);
  54701. /**
  54702. * Gets the left operand
  54703. */
  54704. readonly left: NodeMaterialConnectionPoint;
  54705. /**
  54706. * Gets the right operand
  54707. */
  54708. readonly right: NodeMaterialConnectionPoint;
  54709. /**
  54710. * Gets the output component
  54711. */
  54712. readonly output: NodeMaterialConnectionPoint;
  54713. /**
  54714. * Gets the current class name
  54715. * @returns the class name
  54716. */
  54717. getClassName(): string;
  54718. protected _buildBlock(state: NodeMaterialBuildState): this;
  54719. }
  54720. }
  54721. declare module "babylonjs/Materials/Node/Blocks/index" {
  54722. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  54723. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  54724. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  54725. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  54726. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  54727. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  54728. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  54729. export * from "babylonjs/Materials/Node/Blocks/vector2TransformBlock";
  54730. export * from "babylonjs/Materials/Node/Blocks/vector3TransformBlock";
  54731. export * from "babylonjs/Materials/Node/Blocks/vector4TransformBlock";
  54732. export * from "babylonjs/Materials/Node/Blocks/matrixMultiplicationBlock";
  54733. }
  54734. declare module "babylonjs/Materials/Node/Optimizers/index" {
  54735. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54736. }
  54737. declare module "babylonjs/Materials/Node/index" {
  54738. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54739. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54740. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54741. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  54742. export * from "babylonjs/Materials/Node/nodeMaterial";
  54743. export * from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  54744. export * from "babylonjs/Materials/Node/Blocks/index";
  54745. export * from "babylonjs/Materials/Node/Optimizers/index";
  54746. }
  54747. declare module "babylonjs/Materials/index" {
  54748. export * from "babylonjs/Materials/Background/index";
  54749. export * from "babylonjs/Materials/colorCurves";
  54750. export * from "babylonjs/Materials/effect";
  54751. export * from "babylonjs/Materials/fresnelParameters";
  54752. export * from "babylonjs/Materials/imageProcessingConfiguration";
  54753. export * from "babylonjs/Materials/material";
  54754. export * from "babylonjs/Materials/materialDefines";
  54755. export * from "babylonjs/Materials/materialHelper";
  54756. export * from "babylonjs/Materials/multiMaterial";
  54757. export * from "babylonjs/Materials/PBR/index";
  54758. export * from "babylonjs/Materials/pushMaterial";
  54759. export * from "babylonjs/Materials/shaderMaterial";
  54760. export * from "babylonjs/Materials/standardMaterial";
  54761. export * from "babylonjs/Materials/Textures/index";
  54762. export * from "babylonjs/Materials/uniformBuffer";
  54763. export * from "babylonjs/Materials/materialFlags";
  54764. export * from "babylonjs/Materials/Node/index";
  54765. }
  54766. declare module "babylonjs/Maths/index" {
  54767. export * from "babylonjs/Maths/math.scalar";
  54768. export * from "babylonjs/Maths/math";
  54769. export * from "babylonjs/Maths/sphericalPolynomial";
  54770. }
  54771. declare module "babylonjs/Misc/workerPool" {
  54772. import { IDisposable } from "babylonjs/scene";
  54773. /**
  54774. * Helper class to push actions to a pool of workers.
  54775. */
  54776. export class WorkerPool implements IDisposable {
  54777. private _workerInfos;
  54778. private _pendingActions;
  54779. /**
  54780. * Constructor
  54781. * @param workers Array of workers to use for actions
  54782. */
  54783. constructor(workers: Array<Worker>);
  54784. /**
  54785. * Terminates all workers and clears any pending actions.
  54786. */
  54787. dispose(): void;
  54788. /**
  54789. * Pushes an action to the worker pool. If all the workers are active, the action will be
  54790. * pended until a worker has completed its action.
  54791. * @param action The action to perform. Call onComplete when the action is complete.
  54792. */
  54793. push(action: (worker: Worker, onComplete: () => void) => void): void;
  54794. private _execute;
  54795. }
  54796. }
  54797. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  54798. import { IDisposable } from "babylonjs/scene";
  54799. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  54800. /**
  54801. * Configuration for Draco compression
  54802. */
  54803. export interface IDracoCompressionConfiguration {
  54804. /**
  54805. * Configuration for the decoder.
  54806. */
  54807. decoder: {
  54808. /**
  54809. * The url to the WebAssembly module.
  54810. */
  54811. wasmUrl?: string;
  54812. /**
  54813. * The url to the WebAssembly binary.
  54814. */
  54815. wasmBinaryUrl?: string;
  54816. /**
  54817. * The url to the fallback JavaScript module.
  54818. */
  54819. fallbackUrl?: string;
  54820. };
  54821. }
  54822. /**
  54823. * Draco compression (https://google.github.io/draco/)
  54824. *
  54825. * This class wraps the Draco module.
  54826. *
  54827. * **Encoder**
  54828. *
  54829. * The encoder is not currently implemented.
  54830. *
  54831. * **Decoder**
  54832. *
  54833. * 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.
  54834. *
  54835. * To update the configuration, use the following code:
  54836. * ```javascript
  54837. * DracoCompression.Configuration = {
  54838. * decoder: {
  54839. * wasmUrl: "<url to the WebAssembly library>",
  54840. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  54841. * fallbackUrl: "<url to the fallback JavaScript library>",
  54842. * }
  54843. * };
  54844. * ```
  54845. *
  54846. * 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.
  54847. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  54848. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  54849. *
  54850. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  54851. * ```javascript
  54852. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  54853. * ```
  54854. *
  54855. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  54856. */
  54857. export class DracoCompression implements IDisposable {
  54858. private _workerPoolPromise?;
  54859. private _decoderModulePromise?;
  54860. /**
  54861. * The configuration. Defaults to the following urls:
  54862. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  54863. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  54864. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  54865. */
  54866. static Configuration: IDracoCompressionConfiguration;
  54867. /**
  54868. * Returns true if the decoder configuration is available.
  54869. */
  54870. static readonly DecoderAvailable: boolean;
  54871. /**
  54872. * Default number of workers to create when creating the draco compression object.
  54873. */
  54874. static DefaultNumWorkers: number;
  54875. private static GetDefaultNumWorkers;
  54876. private static _Default;
  54877. /**
  54878. * Default instance for the draco compression object.
  54879. */
  54880. static readonly Default: DracoCompression;
  54881. /**
  54882. * Constructor
  54883. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  54884. */
  54885. constructor(numWorkers?: number);
  54886. /**
  54887. * Stop all async operations and release resources.
  54888. */
  54889. dispose(): void;
  54890. /**
  54891. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  54892. * @returns a promise that resolves when ready
  54893. */
  54894. whenReadyAsync(): Promise<void>;
  54895. /**
  54896. * Decode Draco compressed mesh data to vertex data.
  54897. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  54898. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  54899. * @returns A promise that resolves with the decoded vertex data
  54900. */
  54901. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  54902. [kind: string]: number;
  54903. }): Promise<VertexData>;
  54904. }
  54905. }
  54906. declare module "babylonjs/Meshes/Compression/index" {
  54907. export * from "babylonjs/Meshes/Compression/dracoCompression";
  54908. }
  54909. declare module "babylonjs/Meshes/csg" {
  54910. import { Nullable } from "babylonjs/types";
  54911. import { Scene } from "babylonjs/scene";
  54912. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  54913. import { Mesh } from "babylonjs/Meshes/mesh";
  54914. import { Material } from "babylonjs/Materials/material";
  54915. /**
  54916. * Class for building Constructive Solid Geometry
  54917. */
  54918. export class CSG {
  54919. private polygons;
  54920. /**
  54921. * The world matrix
  54922. */
  54923. matrix: Matrix;
  54924. /**
  54925. * Stores the position
  54926. */
  54927. position: Vector3;
  54928. /**
  54929. * Stores the rotation
  54930. */
  54931. rotation: Vector3;
  54932. /**
  54933. * Stores the rotation quaternion
  54934. */
  54935. rotationQuaternion: Nullable<Quaternion>;
  54936. /**
  54937. * Stores the scaling vector
  54938. */
  54939. scaling: Vector3;
  54940. /**
  54941. * Convert the Mesh to CSG
  54942. * @param mesh The Mesh to convert to CSG
  54943. * @returns A new CSG from the Mesh
  54944. */
  54945. static FromMesh(mesh: Mesh): CSG;
  54946. /**
  54947. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  54948. * @param polygons Polygons used to construct a CSG solid
  54949. */
  54950. private static FromPolygons;
  54951. /**
  54952. * Clones, or makes a deep copy, of the CSG
  54953. * @returns A new CSG
  54954. */
  54955. clone(): CSG;
  54956. /**
  54957. * Unions this CSG with another CSG
  54958. * @param csg The CSG to union against this CSG
  54959. * @returns The unioned CSG
  54960. */
  54961. union(csg: CSG): CSG;
  54962. /**
  54963. * Unions this CSG with another CSG in place
  54964. * @param csg The CSG to union against this CSG
  54965. */
  54966. unionInPlace(csg: CSG): void;
  54967. /**
  54968. * Subtracts this CSG with another CSG
  54969. * @param csg The CSG to subtract against this CSG
  54970. * @returns A new CSG
  54971. */
  54972. subtract(csg: CSG): CSG;
  54973. /**
  54974. * Subtracts this CSG with another CSG in place
  54975. * @param csg The CSG to subtact against this CSG
  54976. */
  54977. subtractInPlace(csg: CSG): void;
  54978. /**
  54979. * Intersect this CSG with another CSG
  54980. * @param csg The CSG to intersect against this CSG
  54981. * @returns A new CSG
  54982. */
  54983. intersect(csg: CSG): CSG;
  54984. /**
  54985. * Intersects this CSG with another CSG in place
  54986. * @param csg The CSG to intersect against this CSG
  54987. */
  54988. intersectInPlace(csg: CSG): void;
  54989. /**
  54990. * Return a new CSG solid with solid and empty space switched. This solid is
  54991. * not modified.
  54992. * @returns A new CSG solid with solid and empty space switched
  54993. */
  54994. inverse(): CSG;
  54995. /**
  54996. * Inverses the CSG in place
  54997. */
  54998. inverseInPlace(): void;
  54999. /**
  55000. * This is used to keep meshes transformations so they can be restored
  55001. * when we build back a Babylon Mesh
  55002. * NB : All CSG operations are performed in world coordinates
  55003. * @param csg The CSG to copy the transform attributes from
  55004. * @returns This CSG
  55005. */
  55006. copyTransformAttributes(csg: CSG): CSG;
  55007. /**
  55008. * Build Raw mesh from CSG
  55009. * Coordinates here are in world space
  55010. * @param name The name of the mesh geometry
  55011. * @param scene The Scene
  55012. * @param keepSubMeshes Specifies if the submeshes should be kept
  55013. * @returns A new Mesh
  55014. */
  55015. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  55016. /**
  55017. * Build Mesh from CSG taking material and transforms into account
  55018. * @param name The name of the Mesh
  55019. * @param material The material of the Mesh
  55020. * @param scene The Scene
  55021. * @param keepSubMeshes Specifies if submeshes should be kept
  55022. * @returns The new Mesh
  55023. */
  55024. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  55025. }
  55026. }
  55027. declare module "babylonjs/Meshes/trailMesh" {
  55028. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55029. import { Mesh } from "babylonjs/Meshes/mesh";
  55030. import { Scene } from "babylonjs/scene";
  55031. /**
  55032. * Class used to create a trail following a mesh
  55033. */
  55034. export class TrailMesh extends Mesh {
  55035. private _generator;
  55036. private _autoStart;
  55037. private _running;
  55038. private _diameter;
  55039. private _length;
  55040. private _sectionPolygonPointsCount;
  55041. private _sectionVectors;
  55042. private _sectionNormalVectors;
  55043. private _beforeRenderObserver;
  55044. /**
  55045. * @constructor
  55046. * @param name The value used by scene.getMeshByName() to do a lookup.
  55047. * @param generator The mesh to generate a trail.
  55048. * @param scene The scene to add this mesh to.
  55049. * @param diameter Diameter of trailing mesh. Default is 1.
  55050. * @param length Length of trailing mesh. Default is 60.
  55051. * @param autoStart Automatically start trailing mesh. Default true.
  55052. */
  55053. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  55054. /**
  55055. * "TrailMesh"
  55056. * @returns "TrailMesh"
  55057. */
  55058. getClassName(): string;
  55059. private _createMesh;
  55060. /**
  55061. * Start trailing mesh.
  55062. */
  55063. start(): void;
  55064. /**
  55065. * Stop trailing mesh.
  55066. */
  55067. stop(): void;
  55068. /**
  55069. * Update trailing mesh geometry.
  55070. */
  55071. update(): void;
  55072. /**
  55073. * Returns a new TrailMesh object.
  55074. * @param name is a string, the name given to the new mesh
  55075. * @param newGenerator use new generator object for cloned trail mesh
  55076. * @returns a new mesh
  55077. */
  55078. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  55079. /**
  55080. * Serializes this trail mesh
  55081. * @param serializationObject object to write serialization to
  55082. */
  55083. serialize(serializationObject: any): void;
  55084. /**
  55085. * Parses a serialized trail mesh
  55086. * @param parsedMesh the serialized mesh
  55087. * @param scene the scene to create the trail mesh in
  55088. * @returns the created trail mesh
  55089. */
  55090. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  55091. }
  55092. }
  55093. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  55094. import { Nullable } from "babylonjs/types";
  55095. import { Scene } from "babylonjs/scene";
  55096. import { Vector4, Color4 } from "babylonjs/Maths/math";
  55097. import { Mesh } from "babylonjs/Meshes/mesh";
  55098. /**
  55099. * Class containing static functions to help procedurally build meshes
  55100. */
  55101. export class TiledBoxBuilder {
  55102. /**
  55103. * Creates a box mesh
  55104. * 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)
  55105. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55106. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55107. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55108. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55109. * @param name defines the name of the mesh
  55110. * @param options defines the options used to create the mesh
  55111. * @param scene defines the hosting scene
  55112. * @returns the box mesh
  55113. */
  55114. static CreateTiledBox(name: string, options: {
  55115. pattern?: number;
  55116. width?: number;
  55117. height?: number;
  55118. depth?: number;
  55119. tileSize?: number;
  55120. tileWidth?: number;
  55121. tileHeight?: number;
  55122. alignHorizontal?: number;
  55123. alignVertical?: number;
  55124. faceUV?: Vector4[];
  55125. faceColors?: Color4[];
  55126. sideOrientation?: number;
  55127. updatable?: boolean;
  55128. }, scene?: Nullable<Scene>): Mesh;
  55129. }
  55130. }
  55131. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  55132. import { Vector4 } from "babylonjs/Maths/math";
  55133. import { Mesh } from "babylonjs/Meshes/mesh";
  55134. /**
  55135. * Class containing static functions to help procedurally build meshes
  55136. */
  55137. export class TorusKnotBuilder {
  55138. /**
  55139. * Creates a torus knot mesh
  55140. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55141. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55142. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55143. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55144. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55145. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55146. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55147. * @param name defines the name of the mesh
  55148. * @param options defines the options used to create the mesh
  55149. * @param scene defines the hosting scene
  55150. * @returns the torus knot mesh
  55151. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55152. */
  55153. static CreateTorusKnot(name: string, options: {
  55154. radius?: number;
  55155. tube?: number;
  55156. radialSegments?: number;
  55157. tubularSegments?: number;
  55158. p?: number;
  55159. q?: number;
  55160. updatable?: boolean;
  55161. sideOrientation?: number;
  55162. frontUVs?: Vector4;
  55163. backUVs?: Vector4;
  55164. }, scene: any): Mesh;
  55165. }
  55166. }
  55167. declare module "babylonjs/Meshes/polygonMesh" {
  55168. import { Scene } from "babylonjs/scene";
  55169. import { Vector2, Path2 } from "babylonjs/Maths/math";
  55170. import { Mesh } from "babylonjs/Meshes/mesh";
  55171. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  55172. /**
  55173. * Polygon
  55174. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  55175. */
  55176. export class Polygon {
  55177. /**
  55178. * Creates a rectangle
  55179. * @param xmin bottom X coord
  55180. * @param ymin bottom Y coord
  55181. * @param xmax top X coord
  55182. * @param ymax top Y coord
  55183. * @returns points that make the resulting rectation
  55184. */
  55185. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  55186. /**
  55187. * Creates a circle
  55188. * @param radius radius of circle
  55189. * @param cx scale in x
  55190. * @param cy scale in y
  55191. * @param numberOfSides number of sides that make up the circle
  55192. * @returns points that make the resulting circle
  55193. */
  55194. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  55195. /**
  55196. * Creates a polygon from input string
  55197. * @param input Input polygon data
  55198. * @returns the parsed points
  55199. */
  55200. static Parse(input: string): Vector2[];
  55201. /**
  55202. * Starts building a polygon from x and y coordinates
  55203. * @param x x coordinate
  55204. * @param y y coordinate
  55205. * @returns the started path2
  55206. */
  55207. static StartingAt(x: number, y: number): Path2;
  55208. }
  55209. /**
  55210. * Builds a polygon
  55211. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  55212. */
  55213. export class PolygonMeshBuilder {
  55214. private _points;
  55215. private _outlinepoints;
  55216. private _holes;
  55217. private _name;
  55218. private _scene;
  55219. private _epoints;
  55220. private _eholes;
  55221. private _addToepoint;
  55222. /**
  55223. * Babylon reference to the earcut plugin.
  55224. */
  55225. bjsEarcut: any;
  55226. /**
  55227. * Creates a PolygonMeshBuilder
  55228. * @param name name of the builder
  55229. * @param contours Path of the polygon
  55230. * @param scene scene to add to when creating the mesh
  55231. * @param earcutInjection can be used to inject your own earcut reference
  55232. */
  55233. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  55234. /**
  55235. * Adds a whole within the polygon
  55236. * @param hole Array of points defining the hole
  55237. * @returns this
  55238. */
  55239. addHole(hole: Vector2[]): PolygonMeshBuilder;
  55240. /**
  55241. * Creates the polygon
  55242. * @param updatable If the mesh should be updatable
  55243. * @param depth The depth of the mesh created
  55244. * @returns the created mesh
  55245. */
  55246. build(updatable?: boolean, depth?: number): Mesh;
  55247. /**
  55248. * Creates the polygon
  55249. * @param depth The depth of the mesh created
  55250. * @returns the created VertexData
  55251. */
  55252. buildVertexData(depth?: number): VertexData;
  55253. /**
  55254. * Adds a side to the polygon
  55255. * @param positions points that make the polygon
  55256. * @param normals normals of the polygon
  55257. * @param uvs uvs of the polygon
  55258. * @param indices indices of the polygon
  55259. * @param bounds bounds of the polygon
  55260. * @param points points of the polygon
  55261. * @param depth depth of the polygon
  55262. * @param flip flip of the polygon
  55263. */
  55264. private addSide;
  55265. }
  55266. }
  55267. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  55268. import { Scene } from "babylonjs/scene";
  55269. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  55270. import { Mesh } from "babylonjs/Meshes/mesh";
  55271. import { Nullable } from "babylonjs/types";
  55272. /**
  55273. * Class containing static functions to help procedurally build meshes
  55274. */
  55275. export class PolygonBuilder {
  55276. /**
  55277. * Creates a polygon mesh
  55278. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55279. * * 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
  55280. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55282. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  55283. * * Remember you can only change the shape positions, not their number when updating a polygon
  55284. * @param name defines the name of the mesh
  55285. * @param options defines the options used to create the mesh
  55286. * @param scene defines the hosting scene
  55287. * @param earcutInjection can be used to inject your own earcut reference
  55288. * @returns the polygon mesh
  55289. */
  55290. static CreatePolygon(name: string, options: {
  55291. shape: Vector3[];
  55292. holes?: Vector3[][];
  55293. depth?: number;
  55294. faceUV?: Vector4[];
  55295. faceColors?: Color4[];
  55296. updatable?: boolean;
  55297. sideOrientation?: number;
  55298. frontUVs?: Vector4;
  55299. backUVs?: Vector4;
  55300. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55301. /**
  55302. * Creates an extruded polygon mesh, with depth in the Y direction.
  55303. * * 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)
  55304. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55305. * @param name defines the name of the mesh
  55306. * @param options defines the options used to create the mesh
  55307. * @param scene defines the hosting scene
  55308. * @param earcutInjection can be used to inject your own earcut reference
  55309. * @returns the polygon mesh
  55310. */
  55311. static ExtrudePolygon(name: string, options: {
  55312. shape: Vector3[];
  55313. holes?: Vector3[][];
  55314. depth?: number;
  55315. faceUV?: Vector4[];
  55316. faceColors?: Color4[];
  55317. updatable?: boolean;
  55318. sideOrientation?: number;
  55319. frontUVs?: Vector4;
  55320. backUVs?: Vector4;
  55321. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55322. }
  55323. }
  55324. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  55325. import { Scene } from "babylonjs/scene";
  55326. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  55327. import { Mesh } from "babylonjs/Meshes/mesh";
  55328. import { Nullable } from "babylonjs/types";
  55329. /**
  55330. * Class containing static functions to help procedurally build meshes
  55331. */
  55332. export class LatheBuilder {
  55333. /**
  55334. * Creates lathe mesh.
  55335. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55336. * * 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
  55337. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55338. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55339. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55340. * * 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
  55341. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55342. * * 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
  55343. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55344. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55345. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55347. * @param name defines the name of the mesh
  55348. * @param options defines the options used to create the mesh
  55349. * @param scene defines the hosting scene
  55350. * @returns the lathe mesh
  55351. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55352. */
  55353. static CreateLathe(name: string, options: {
  55354. shape: Vector3[];
  55355. radius?: number;
  55356. tessellation?: number;
  55357. clip?: number;
  55358. arc?: number;
  55359. closed?: boolean;
  55360. updatable?: boolean;
  55361. sideOrientation?: number;
  55362. frontUVs?: Vector4;
  55363. backUVs?: Vector4;
  55364. cap?: number;
  55365. invertUV?: boolean;
  55366. }, scene?: Nullable<Scene>): Mesh;
  55367. }
  55368. }
  55369. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  55370. import { Nullable } from "babylonjs/types";
  55371. import { Scene } from "babylonjs/scene";
  55372. import { Vector4 } from "babylonjs/Maths/math";
  55373. import { Mesh } from "babylonjs/Meshes/mesh";
  55374. /**
  55375. * Class containing static functions to help procedurally build meshes
  55376. */
  55377. export class TiledPlaneBuilder {
  55378. /**
  55379. * Creates a tiled plane mesh
  55380. * * The parameter `pattern` will, depending on value, do nothing or
  55381. * * * flip (reflect about central vertical) alternate tiles across and up
  55382. * * * flip every tile on alternate rows
  55383. * * * rotate (180 degs) alternate tiles across and up
  55384. * * * rotate every tile on alternate rows
  55385. * * * flip and rotate alternate tiles across and up
  55386. * * * flip and rotate every tile on alternate rows
  55387. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  55388. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  55389. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55390. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55391. * * 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)
  55392. * * 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)
  55393. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55394. * @param name defines the name of the mesh
  55395. * @param options defines the options used to create the mesh
  55396. * @param scene defines the hosting scene
  55397. * @returns the box mesh
  55398. */
  55399. static CreateTiledPlane(name: string, options: {
  55400. pattern?: number;
  55401. tileSize?: number;
  55402. tileWidth?: number;
  55403. tileHeight?: number;
  55404. size?: number;
  55405. width?: number;
  55406. height?: number;
  55407. alignHorizontal?: number;
  55408. alignVertical?: number;
  55409. sideOrientation?: number;
  55410. frontUVs?: Vector4;
  55411. backUVs?: Vector4;
  55412. updatable?: boolean;
  55413. }, scene?: Nullable<Scene>): Mesh;
  55414. }
  55415. }
  55416. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  55417. import { Nullable } from "babylonjs/types";
  55418. import { Scene } from "babylonjs/scene";
  55419. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  55420. import { Mesh } from "babylonjs/Meshes/mesh";
  55421. /**
  55422. * Class containing static functions to help procedurally build meshes
  55423. */
  55424. export class TubeBuilder {
  55425. /**
  55426. * Creates a tube mesh.
  55427. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55428. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55429. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55430. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55431. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55432. * * 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)
  55433. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55434. * * 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
  55435. * * 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
  55436. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55437. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55438. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55440. * @param name defines the name of the mesh
  55441. * @param options defines the options used to create the mesh
  55442. * @param scene defines the hosting scene
  55443. * @returns the tube mesh
  55444. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55445. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55446. */
  55447. static CreateTube(name: string, options: {
  55448. path: Vector3[];
  55449. radius?: number;
  55450. tessellation?: number;
  55451. radiusFunction?: {
  55452. (i: number, distance: number): number;
  55453. };
  55454. cap?: number;
  55455. arc?: number;
  55456. updatable?: boolean;
  55457. sideOrientation?: number;
  55458. frontUVs?: Vector4;
  55459. backUVs?: Vector4;
  55460. instance?: Mesh;
  55461. invertUV?: boolean;
  55462. }, scene?: Nullable<Scene>): Mesh;
  55463. }
  55464. }
  55465. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  55466. import { Scene } from "babylonjs/scene";
  55467. import { Vector4 } from "babylonjs/Maths/math";
  55468. import { Mesh } from "babylonjs/Meshes/mesh";
  55469. import { Nullable } from "babylonjs/types";
  55470. /**
  55471. * Class containing static functions to help procedurally build meshes
  55472. */
  55473. export class IcoSphereBuilder {
  55474. /**
  55475. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55476. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55477. * * 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`)
  55478. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55479. * * 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
  55480. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55481. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55483. * @param name defines the name of the mesh
  55484. * @param options defines the options used to create the mesh
  55485. * @param scene defines the hosting scene
  55486. * @returns the icosahedron mesh
  55487. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55488. */
  55489. static CreateIcoSphere(name: string, options: {
  55490. radius?: number;
  55491. radiusX?: number;
  55492. radiusY?: number;
  55493. radiusZ?: number;
  55494. flat?: boolean;
  55495. subdivisions?: number;
  55496. sideOrientation?: number;
  55497. frontUVs?: Vector4;
  55498. backUVs?: Vector4;
  55499. updatable?: boolean;
  55500. }, scene?: Nullable<Scene>): Mesh;
  55501. }
  55502. }
  55503. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  55504. import { Vector3 } from "babylonjs/Maths/math";
  55505. import { Mesh } from "babylonjs/Meshes/mesh";
  55506. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55507. /**
  55508. * Class containing static functions to help procedurally build meshes
  55509. */
  55510. export class DecalBuilder {
  55511. /**
  55512. * Creates a decal mesh.
  55513. * 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
  55514. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55515. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55516. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55517. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55518. * @param name defines the name of the mesh
  55519. * @param sourceMesh defines the mesh where the decal must be applied
  55520. * @param options defines the options used to create the mesh
  55521. * @param scene defines the hosting scene
  55522. * @returns the decal mesh
  55523. * @see https://doc.babylonjs.com/how_to/decals
  55524. */
  55525. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55526. position?: Vector3;
  55527. normal?: Vector3;
  55528. size?: Vector3;
  55529. angle?: number;
  55530. }): Mesh;
  55531. }
  55532. }
  55533. declare module "babylonjs/Meshes/meshBuilder" {
  55534. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  55535. import { Nullable } from "babylonjs/types";
  55536. import { Scene } from "babylonjs/scene";
  55537. import { Mesh } from "babylonjs/Meshes/mesh";
  55538. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  55539. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  55540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55541. /**
  55542. * Class containing static functions to help procedurally build meshes
  55543. */
  55544. export class MeshBuilder {
  55545. /**
  55546. * Creates a box mesh
  55547. * * The parameter `size` sets the size (float) of each box side (default 1)
  55548. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  55549. * * 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)
  55550. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55551. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55552. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55554. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55555. * @param name defines the name of the mesh
  55556. * @param options defines the options used to create the mesh
  55557. * @param scene defines the hosting scene
  55558. * @returns the box mesh
  55559. */
  55560. static CreateBox(name: string, options: {
  55561. size?: number;
  55562. width?: number;
  55563. height?: number;
  55564. depth?: number;
  55565. faceUV?: Vector4[];
  55566. faceColors?: Color4[];
  55567. sideOrientation?: number;
  55568. frontUVs?: Vector4;
  55569. backUVs?: Vector4;
  55570. updatable?: boolean;
  55571. }, scene?: Nullable<Scene>): Mesh;
  55572. /**
  55573. * Creates a tiled box mesh
  55574. * * faceTiles sets the pattern, tile size and number of tiles for a face
  55575. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55576. * @param name defines the name of the mesh
  55577. * @param options defines the options used to create the mesh
  55578. * @param scene defines the hosting scene
  55579. * @returns the tiled box mesh
  55580. */
  55581. static CreateTiledBox(name: string, options: {
  55582. pattern?: number;
  55583. size?: number;
  55584. width?: number;
  55585. height?: number;
  55586. depth: number;
  55587. tileSize?: number;
  55588. tileWidth?: number;
  55589. tileHeight?: number;
  55590. faceUV?: Vector4[];
  55591. faceColors?: Color4[];
  55592. alignHorizontal?: number;
  55593. alignVertical?: number;
  55594. sideOrientation?: number;
  55595. updatable?: boolean;
  55596. }, scene?: Nullable<Scene>): Mesh;
  55597. /**
  55598. * Creates a sphere mesh
  55599. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55600. * * 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`)
  55601. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55602. * * 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
  55603. * * 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)
  55604. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55605. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55606. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55607. * @param name defines the name of the mesh
  55608. * @param options defines the options used to create the mesh
  55609. * @param scene defines the hosting scene
  55610. * @returns the sphere mesh
  55611. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55612. */
  55613. static CreateSphere(name: string, options: {
  55614. segments?: number;
  55615. diameter?: number;
  55616. diameterX?: number;
  55617. diameterY?: number;
  55618. diameterZ?: number;
  55619. arc?: number;
  55620. slice?: number;
  55621. sideOrientation?: number;
  55622. frontUVs?: Vector4;
  55623. backUVs?: Vector4;
  55624. updatable?: boolean;
  55625. }, scene?: Nullable<Scene>): Mesh;
  55626. /**
  55627. * Creates a plane polygonal mesh. By default, this is a disc
  55628. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  55629. * * 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
  55630. * * 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
  55631. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55632. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55633. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55634. * @param name defines the name of the mesh
  55635. * @param options defines the options used to create the mesh
  55636. * @param scene defines the hosting scene
  55637. * @returns the plane polygonal mesh
  55638. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  55639. */
  55640. static CreateDisc(name: string, options: {
  55641. radius?: number;
  55642. tessellation?: number;
  55643. arc?: number;
  55644. updatable?: boolean;
  55645. sideOrientation?: number;
  55646. frontUVs?: Vector4;
  55647. backUVs?: Vector4;
  55648. }, scene?: Nullable<Scene>): Mesh;
  55649. /**
  55650. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55651. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55652. * * 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`)
  55653. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55654. * * 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
  55655. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55656. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55658. * @param name defines the name of the mesh
  55659. * @param options defines the options used to create the mesh
  55660. * @param scene defines the hosting scene
  55661. * @returns the icosahedron mesh
  55662. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55663. */
  55664. static CreateIcoSphere(name: string, options: {
  55665. radius?: number;
  55666. radiusX?: number;
  55667. radiusY?: number;
  55668. radiusZ?: number;
  55669. flat?: boolean;
  55670. subdivisions?: number;
  55671. sideOrientation?: number;
  55672. frontUVs?: Vector4;
  55673. backUVs?: Vector4;
  55674. updatable?: boolean;
  55675. }, scene?: Nullable<Scene>): Mesh;
  55676. /**
  55677. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55678. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55679. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55680. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55681. * * 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
  55682. * * 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
  55683. * * 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
  55684. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55685. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55686. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55687. * * 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
  55688. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55689. * * 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
  55690. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55692. * @param name defines the name of the mesh
  55693. * @param options defines the options used to create the mesh
  55694. * @param scene defines the hosting scene
  55695. * @returns the ribbon mesh
  55696. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55697. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55698. */
  55699. static CreateRibbon(name: string, options: {
  55700. pathArray: Vector3[][];
  55701. closeArray?: boolean;
  55702. closePath?: boolean;
  55703. offset?: number;
  55704. updatable?: boolean;
  55705. sideOrientation?: number;
  55706. frontUVs?: Vector4;
  55707. backUVs?: Vector4;
  55708. instance?: Mesh;
  55709. invertUV?: boolean;
  55710. uvs?: Vector2[];
  55711. colors?: Color4[];
  55712. }, scene?: Nullable<Scene>): Mesh;
  55713. /**
  55714. * Creates a cylinder or a cone mesh
  55715. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  55716. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  55717. * * 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.
  55718. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  55719. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  55720. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  55721. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  55722. * * 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).
  55723. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  55724. * * 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).
  55725. * * 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
  55726. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  55727. * * 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
  55728. * * 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.
  55729. * * If `enclose` is false, a ring surface is one element.
  55730. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  55731. * * 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
  55732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55733. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55735. * @param name defines the name of the mesh
  55736. * @param options defines the options used to create the mesh
  55737. * @param scene defines the hosting scene
  55738. * @returns the cylinder mesh
  55739. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  55740. */
  55741. static CreateCylinder(name: string, options: {
  55742. height?: number;
  55743. diameterTop?: number;
  55744. diameterBottom?: number;
  55745. diameter?: number;
  55746. tessellation?: number;
  55747. subdivisions?: number;
  55748. arc?: number;
  55749. faceColors?: Color4[];
  55750. faceUV?: Vector4[];
  55751. updatable?: boolean;
  55752. hasRings?: boolean;
  55753. enclose?: boolean;
  55754. cap?: number;
  55755. sideOrientation?: number;
  55756. frontUVs?: Vector4;
  55757. backUVs?: Vector4;
  55758. }, scene?: Nullable<Scene>): Mesh;
  55759. /**
  55760. * Creates a torus mesh
  55761. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  55762. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  55763. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  55764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55765. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55767. * @param name defines the name of the mesh
  55768. * @param options defines the options used to create the mesh
  55769. * @param scene defines the hosting scene
  55770. * @returns the torus mesh
  55771. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  55772. */
  55773. static CreateTorus(name: string, options: {
  55774. diameter?: number;
  55775. thickness?: number;
  55776. tessellation?: number;
  55777. updatable?: boolean;
  55778. sideOrientation?: number;
  55779. frontUVs?: Vector4;
  55780. backUVs?: Vector4;
  55781. }, scene?: Nullable<Scene>): Mesh;
  55782. /**
  55783. * Creates a torus knot mesh
  55784. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55785. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55786. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55787. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55788. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55789. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55791. * @param name defines the name of the mesh
  55792. * @param options defines the options used to create the mesh
  55793. * @param scene defines the hosting scene
  55794. * @returns the torus knot mesh
  55795. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55796. */
  55797. static CreateTorusKnot(name: string, options: {
  55798. radius?: number;
  55799. tube?: number;
  55800. radialSegments?: number;
  55801. tubularSegments?: number;
  55802. p?: number;
  55803. q?: number;
  55804. updatable?: boolean;
  55805. sideOrientation?: number;
  55806. frontUVs?: Vector4;
  55807. backUVs?: Vector4;
  55808. }, scene?: Nullable<Scene>): Mesh;
  55809. /**
  55810. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55811. * * 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
  55812. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55813. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55814. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55815. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55816. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55817. * * 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
  55818. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55820. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55821. * @param name defines the name of the new line system
  55822. * @param options defines the options used to create the line system
  55823. * @param scene defines the hosting scene
  55824. * @returns a new line system mesh
  55825. */
  55826. static CreateLineSystem(name: string, options: {
  55827. lines: Vector3[][];
  55828. updatable?: boolean;
  55829. instance?: Nullable<LinesMesh>;
  55830. colors?: Nullable<Color4[][]>;
  55831. useVertexAlpha?: boolean;
  55832. }, scene: Nullable<Scene>): LinesMesh;
  55833. /**
  55834. * Creates a line mesh
  55835. * 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
  55836. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55837. * * The parameter `points` is an array successive Vector3
  55838. * * 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
  55839. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55840. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55841. * * When updating an instance, remember that only point positions can change, not the number of points
  55842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55843. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55844. * @param name defines the name of the new line system
  55845. * @param options defines the options used to create the line system
  55846. * @param scene defines the hosting scene
  55847. * @returns a new line mesh
  55848. */
  55849. static CreateLines(name: string, options: {
  55850. points: Vector3[];
  55851. updatable?: boolean;
  55852. instance?: Nullable<LinesMesh>;
  55853. colors?: Color4[];
  55854. useVertexAlpha?: boolean;
  55855. }, scene?: Nullable<Scene>): LinesMesh;
  55856. /**
  55857. * Creates a dashed line mesh
  55858. * * 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
  55859. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55860. * * The parameter `points` is an array successive Vector3
  55861. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55862. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55863. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55864. * * 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
  55865. * * When updating an instance, remember that only point positions can change, not the number of points
  55866. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55867. * @param name defines the name of the mesh
  55868. * @param options defines the options used to create the mesh
  55869. * @param scene defines the hosting scene
  55870. * @returns the dashed line mesh
  55871. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55872. */
  55873. static CreateDashedLines(name: string, options: {
  55874. points: Vector3[];
  55875. dashSize?: number;
  55876. gapSize?: number;
  55877. dashNb?: number;
  55878. updatable?: boolean;
  55879. instance?: LinesMesh;
  55880. }, scene?: Nullable<Scene>): LinesMesh;
  55881. /**
  55882. * 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.
  55883. * * 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.
  55884. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55885. * * 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.
  55886. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55887. * * 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
  55888. * * 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
  55889. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55890. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55891. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55892. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55893. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55894. * @param name defines the name of the mesh
  55895. * @param options defines the options used to create the mesh
  55896. * @param scene defines the hosting scene
  55897. * @returns the extruded shape mesh
  55898. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55899. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55900. */
  55901. static ExtrudeShape(name: string, options: {
  55902. shape: Vector3[];
  55903. path: Vector3[];
  55904. scale?: number;
  55905. rotation?: number;
  55906. cap?: number;
  55907. updatable?: boolean;
  55908. sideOrientation?: number;
  55909. frontUVs?: Vector4;
  55910. backUVs?: Vector4;
  55911. instance?: Mesh;
  55912. invertUV?: boolean;
  55913. }, scene?: Nullable<Scene>): Mesh;
  55914. /**
  55915. * Creates an custom extruded shape mesh.
  55916. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55917. * * 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.
  55918. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55919. * * 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
  55920. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55921. * * 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
  55922. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55923. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55924. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55925. * * 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
  55926. * * 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
  55927. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55928. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55929. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55930. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55932. * @param name defines the name of the mesh
  55933. * @param options defines the options used to create the mesh
  55934. * @param scene defines the hosting scene
  55935. * @returns the custom extruded shape mesh
  55936. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55937. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55938. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55939. */
  55940. static ExtrudeShapeCustom(name: string, options: {
  55941. shape: Vector3[];
  55942. path: Vector3[];
  55943. scaleFunction?: any;
  55944. rotationFunction?: any;
  55945. ribbonCloseArray?: boolean;
  55946. ribbonClosePath?: boolean;
  55947. cap?: number;
  55948. updatable?: boolean;
  55949. sideOrientation?: number;
  55950. frontUVs?: Vector4;
  55951. backUVs?: Vector4;
  55952. instance?: Mesh;
  55953. invertUV?: boolean;
  55954. }, scene?: Nullable<Scene>): Mesh;
  55955. /**
  55956. * Creates lathe mesh.
  55957. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55958. * * 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
  55959. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55960. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55961. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55962. * * 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
  55963. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55964. * * 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
  55965. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55966. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55967. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55969. * @param name defines the name of the mesh
  55970. * @param options defines the options used to create the mesh
  55971. * @param scene defines the hosting scene
  55972. * @returns the lathe mesh
  55973. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55974. */
  55975. static CreateLathe(name: string, options: {
  55976. shape: Vector3[];
  55977. radius?: number;
  55978. tessellation?: number;
  55979. clip?: number;
  55980. arc?: number;
  55981. closed?: boolean;
  55982. updatable?: boolean;
  55983. sideOrientation?: number;
  55984. frontUVs?: Vector4;
  55985. backUVs?: Vector4;
  55986. cap?: number;
  55987. invertUV?: boolean;
  55988. }, scene?: Nullable<Scene>): Mesh;
  55989. /**
  55990. * Creates a tiled plane mesh
  55991. * * You can set a limited pattern arrangement with the tiles
  55992. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55993. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55995. * @param name defines the name of the mesh
  55996. * @param options defines the options used to create the mesh
  55997. * @param scene defines the hosting scene
  55998. * @returns the plane mesh
  55999. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56000. */
  56001. static CreateTiledPlane(name: string, options: {
  56002. pattern?: number;
  56003. tileSize?: number;
  56004. tileWidth?: number;
  56005. tileHeight?: number;
  56006. size?: number;
  56007. width?: number;
  56008. height?: number;
  56009. alignHorizontal?: number;
  56010. alignVertical?: number;
  56011. sideOrientation?: number;
  56012. frontUVs?: Vector4;
  56013. backUVs?: Vector4;
  56014. updatable?: boolean;
  56015. }, scene?: Nullable<Scene>): Mesh;
  56016. /**
  56017. * Creates a plane mesh
  56018. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  56019. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  56020. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  56021. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56022. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56023. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56024. * @param name defines the name of the mesh
  56025. * @param options defines the options used to create the mesh
  56026. * @param scene defines the hosting scene
  56027. * @returns the plane mesh
  56028. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56029. */
  56030. static CreatePlane(name: string, options: {
  56031. size?: number;
  56032. width?: number;
  56033. height?: number;
  56034. sideOrientation?: number;
  56035. frontUVs?: Vector4;
  56036. backUVs?: Vector4;
  56037. updatable?: boolean;
  56038. sourcePlane?: Plane;
  56039. }, scene?: Nullable<Scene>): Mesh;
  56040. /**
  56041. * Creates a ground mesh
  56042. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  56043. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  56044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56045. * @param name defines the name of the mesh
  56046. * @param options defines the options used to create the mesh
  56047. * @param scene defines the hosting scene
  56048. * @returns the ground mesh
  56049. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  56050. */
  56051. static CreateGround(name: string, options: {
  56052. width?: number;
  56053. height?: number;
  56054. subdivisions?: number;
  56055. subdivisionsX?: number;
  56056. subdivisionsY?: number;
  56057. updatable?: boolean;
  56058. }, scene?: Nullable<Scene>): Mesh;
  56059. /**
  56060. * Creates a tiled ground mesh
  56061. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  56062. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  56063. * * 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
  56064. * * 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
  56065. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56066. * @param name defines the name of the mesh
  56067. * @param options defines the options used to create the mesh
  56068. * @param scene defines the hosting scene
  56069. * @returns the tiled ground mesh
  56070. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  56071. */
  56072. static CreateTiledGround(name: string, options: {
  56073. xmin: number;
  56074. zmin: number;
  56075. xmax: number;
  56076. zmax: number;
  56077. subdivisions?: {
  56078. w: number;
  56079. h: number;
  56080. };
  56081. precision?: {
  56082. w: number;
  56083. h: number;
  56084. };
  56085. updatable?: boolean;
  56086. }, scene?: Nullable<Scene>): Mesh;
  56087. /**
  56088. * Creates a ground mesh from a height map
  56089. * * The parameter `url` sets the URL of the height map image resource.
  56090. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  56091. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  56092. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  56093. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  56094. * * 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.
  56095. * * 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).
  56096. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  56097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56098. * @param name defines the name of the mesh
  56099. * @param url defines the url to the height map
  56100. * @param options defines the options used to create the mesh
  56101. * @param scene defines the hosting scene
  56102. * @returns the ground mesh
  56103. * @see https://doc.babylonjs.com/babylon101/height_map
  56104. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  56105. */
  56106. static CreateGroundFromHeightMap(name: string, url: string, options: {
  56107. width?: number;
  56108. height?: number;
  56109. subdivisions?: number;
  56110. minHeight?: number;
  56111. maxHeight?: number;
  56112. colorFilter?: Color3;
  56113. alphaFilter?: number;
  56114. updatable?: boolean;
  56115. onReady?: (mesh: GroundMesh) => void;
  56116. }, scene?: Nullable<Scene>): GroundMesh;
  56117. /**
  56118. * Creates a polygon mesh
  56119. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56120. * * 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
  56121. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56123. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  56124. * * Remember you can only change the shape positions, not their number when updating a polygon
  56125. * @param name defines the name of the mesh
  56126. * @param options defines the options used to create the mesh
  56127. * @param scene defines the hosting scene
  56128. * @param earcutInjection can be used to inject your own earcut reference
  56129. * @returns the polygon mesh
  56130. */
  56131. static CreatePolygon(name: string, options: {
  56132. shape: Vector3[];
  56133. holes?: Vector3[][];
  56134. depth?: number;
  56135. faceUV?: Vector4[];
  56136. faceColors?: Color4[];
  56137. updatable?: boolean;
  56138. sideOrientation?: number;
  56139. frontUVs?: Vector4;
  56140. backUVs?: Vector4;
  56141. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56142. /**
  56143. * Creates an extruded polygon mesh, with depth in the Y direction.
  56144. * * 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)
  56145. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56146. * @param name defines the name of the mesh
  56147. * @param options defines the options used to create the mesh
  56148. * @param scene defines the hosting scene
  56149. * @param earcutInjection can be used to inject your own earcut reference
  56150. * @returns the polygon mesh
  56151. */
  56152. static ExtrudePolygon(name: string, options: {
  56153. shape: Vector3[];
  56154. holes?: Vector3[][];
  56155. depth?: number;
  56156. faceUV?: Vector4[];
  56157. faceColors?: Color4[];
  56158. updatable?: boolean;
  56159. sideOrientation?: number;
  56160. frontUVs?: Vector4;
  56161. backUVs?: Vector4;
  56162. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56163. /**
  56164. * Creates a tube mesh.
  56165. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56166. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56167. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56168. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56169. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56170. * * 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)
  56171. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56172. * * 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
  56173. * * 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
  56174. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56175. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56176. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56177. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56178. * @param name defines the name of the mesh
  56179. * @param options defines the options used to create the mesh
  56180. * @param scene defines the hosting scene
  56181. * @returns the tube mesh
  56182. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56183. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56184. */
  56185. static CreateTube(name: string, options: {
  56186. path: Vector3[];
  56187. radius?: number;
  56188. tessellation?: number;
  56189. radiusFunction?: {
  56190. (i: number, distance: number): number;
  56191. };
  56192. cap?: number;
  56193. arc?: number;
  56194. updatable?: boolean;
  56195. sideOrientation?: number;
  56196. frontUVs?: Vector4;
  56197. backUVs?: Vector4;
  56198. instance?: Mesh;
  56199. invertUV?: boolean;
  56200. }, scene?: Nullable<Scene>): Mesh;
  56201. /**
  56202. * Creates a polyhedron mesh
  56203. * * 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
  56204. * * The parameter `size` (positive float, default 1) sets the polygon size
  56205. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56206. * * 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`
  56207. * * 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
  56208. * * 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)`)
  56209. * * 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
  56210. * * 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
  56211. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56212. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56213. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56214. * @param name defines the name of the mesh
  56215. * @param options defines the options used to create the mesh
  56216. * @param scene defines the hosting scene
  56217. * @returns the polyhedron mesh
  56218. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56219. */
  56220. static CreatePolyhedron(name: string, options: {
  56221. type?: number;
  56222. size?: number;
  56223. sizeX?: number;
  56224. sizeY?: number;
  56225. sizeZ?: number;
  56226. custom?: any;
  56227. faceUV?: Vector4[];
  56228. faceColors?: Color4[];
  56229. flat?: boolean;
  56230. updatable?: boolean;
  56231. sideOrientation?: number;
  56232. frontUVs?: Vector4;
  56233. backUVs?: Vector4;
  56234. }, scene?: Nullable<Scene>): Mesh;
  56235. /**
  56236. * Creates a decal mesh.
  56237. * 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
  56238. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56239. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56240. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56241. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56242. * @param name defines the name of the mesh
  56243. * @param sourceMesh defines the mesh where the decal must be applied
  56244. * @param options defines the options used to create the mesh
  56245. * @param scene defines the hosting scene
  56246. * @returns the decal mesh
  56247. * @see https://doc.babylonjs.com/how_to/decals
  56248. */
  56249. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56250. position?: Vector3;
  56251. normal?: Vector3;
  56252. size?: Vector3;
  56253. angle?: number;
  56254. }): Mesh;
  56255. }
  56256. }
  56257. declare module "babylonjs/Meshes/meshSimplification" {
  56258. import { Mesh } from "babylonjs/Meshes/mesh";
  56259. /**
  56260. * A simplifier interface for future simplification implementations
  56261. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56262. */
  56263. export interface ISimplifier {
  56264. /**
  56265. * Simplification of a given mesh according to the given settings.
  56266. * Since this requires computation, it is assumed that the function runs async.
  56267. * @param settings The settings of the simplification, including quality and distance
  56268. * @param successCallback A callback that will be called after the mesh was simplified.
  56269. * @param errorCallback in case of an error, this callback will be called. optional.
  56270. */
  56271. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  56272. }
  56273. /**
  56274. * Expected simplification settings.
  56275. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  56276. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56277. */
  56278. export interface ISimplificationSettings {
  56279. /**
  56280. * Gets or sets the expected quality
  56281. */
  56282. quality: number;
  56283. /**
  56284. * Gets or sets the distance when this optimized version should be used
  56285. */
  56286. distance: number;
  56287. /**
  56288. * Gets an already optimized mesh
  56289. */
  56290. optimizeMesh?: boolean;
  56291. }
  56292. /**
  56293. * Class used to specify simplification options
  56294. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56295. */
  56296. export class SimplificationSettings implements ISimplificationSettings {
  56297. /** expected quality */
  56298. quality: number;
  56299. /** distance when this optimized version should be used */
  56300. distance: number;
  56301. /** already optimized mesh */
  56302. optimizeMesh?: boolean | undefined;
  56303. /**
  56304. * Creates a SimplificationSettings
  56305. * @param quality expected quality
  56306. * @param distance distance when this optimized version should be used
  56307. * @param optimizeMesh already optimized mesh
  56308. */
  56309. constructor(
  56310. /** expected quality */
  56311. quality: number,
  56312. /** distance when this optimized version should be used */
  56313. distance: number,
  56314. /** already optimized mesh */
  56315. optimizeMesh?: boolean | undefined);
  56316. }
  56317. /**
  56318. * Interface used to define a simplification task
  56319. */
  56320. export interface ISimplificationTask {
  56321. /**
  56322. * Array of settings
  56323. */
  56324. settings: Array<ISimplificationSettings>;
  56325. /**
  56326. * Simplification type
  56327. */
  56328. simplificationType: SimplificationType;
  56329. /**
  56330. * Mesh to simplify
  56331. */
  56332. mesh: Mesh;
  56333. /**
  56334. * Callback called on success
  56335. */
  56336. successCallback?: () => void;
  56337. /**
  56338. * Defines if parallel processing can be used
  56339. */
  56340. parallelProcessing: boolean;
  56341. }
  56342. /**
  56343. * Queue used to order the simplification tasks
  56344. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56345. */
  56346. export class SimplificationQueue {
  56347. private _simplificationArray;
  56348. /**
  56349. * Gets a boolean indicating that the process is still running
  56350. */
  56351. running: boolean;
  56352. /**
  56353. * Creates a new queue
  56354. */
  56355. constructor();
  56356. /**
  56357. * Adds a new simplification task
  56358. * @param task defines a task to add
  56359. */
  56360. addTask(task: ISimplificationTask): void;
  56361. /**
  56362. * Execute next task
  56363. */
  56364. executeNext(): void;
  56365. /**
  56366. * Execute a simplification task
  56367. * @param task defines the task to run
  56368. */
  56369. runSimplification(task: ISimplificationTask): void;
  56370. private getSimplifier;
  56371. }
  56372. /**
  56373. * The implemented types of simplification
  56374. * At the moment only Quadratic Error Decimation is implemented
  56375. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56376. */
  56377. export enum SimplificationType {
  56378. /** Quadratic error decimation */
  56379. QUADRATIC = 0
  56380. }
  56381. }
  56382. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  56383. import { Scene } from "babylonjs/scene";
  56384. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  56385. import { ISceneComponent } from "babylonjs/sceneComponent";
  56386. module "babylonjs/scene" {
  56387. interface Scene {
  56388. /** @hidden (Backing field) */
  56389. _simplificationQueue: SimplificationQueue;
  56390. /**
  56391. * Gets or sets the simplification queue attached to the scene
  56392. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56393. */
  56394. simplificationQueue: SimplificationQueue;
  56395. }
  56396. }
  56397. module "babylonjs/Meshes/mesh" {
  56398. interface Mesh {
  56399. /**
  56400. * Simplify the mesh according to the given array of settings.
  56401. * Function will return immediately and will simplify async
  56402. * @param settings a collection of simplification settings
  56403. * @param parallelProcessing should all levels calculate parallel or one after the other
  56404. * @param simplificationType the type of simplification to run
  56405. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  56406. * @returns the current mesh
  56407. */
  56408. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  56409. }
  56410. }
  56411. /**
  56412. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  56413. * created in a scene
  56414. */
  56415. export class SimplicationQueueSceneComponent implements ISceneComponent {
  56416. /**
  56417. * The component name helpfull to identify the component in the list of scene components.
  56418. */
  56419. readonly name: string;
  56420. /**
  56421. * The scene the component belongs to.
  56422. */
  56423. scene: Scene;
  56424. /**
  56425. * Creates a new instance of the component for the given scene
  56426. * @param scene Defines the scene to register the component in
  56427. */
  56428. constructor(scene: Scene);
  56429. /**
  56430. * Registers the component in a given scene
  56431. */
  56432. register(): void;
  56433. /**
  56434. * Rebuilds the elements related to this component in case of
  56435. * context lost for instance.
  56436. */
  56437. rebuild(): void;
  56438. /**
  56439. * Disposes the component and the associated ressources
  56440. */
  56441. dispose(): void;
  56442. private _beforeCameraUpdate;
  56443. }
  56444. }
  56445. declare module "babylonjs/Meshes/Builders/index" {
  56446. export * from "babylonjs/Meshes/Builders/boxBuilder";
  56447. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  56448. export * from "babylonjs/Meshes/Builders/discBuilder";
  56449. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  56450. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  56451. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  56452. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  56453. export * from "babylonjs/Meshes/Builders/torusBuilder";
  56454. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  56455. export * from "babylonjs/Meshes/Builders/linesBuilder";
  56456. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  56457. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  56458. export * from "babylonjs/Meshes/Builders/latheBuilder";
  56459. export * from "babylonjs/Meshes/Builders/planeBuilder";
  56460. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  56461. export * from "babylonjs/Meshes/Builders/groundBuilder";
  56462. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  56463. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  56464. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  56465. export * from "babylonjs/Meshes/Builders/decalBuilder";
  56466. }
  56467. declare module "babylonjs/Meshes/index" {
  56468. export * from "babylonjs/Meshes/abstractMesh";
  56469. export * from "babylonjs/Meshes/buffer";
  56470. export * from "babylonjs/Meshes/Compression/index";
  56471. export * from "babylonjs/Meshes/csg";
  56472. export * from "babylonjs/Meshes/geometry";
  56473. export * from "babylonjs/Meshes/groundMesh";
  56474. export * from "babylonjs/Meshes/trailMesh";
  56475. export * from "babylonjs/Meshes/instancedMesh";
  56476. export * from "babylonjs/Meshes/linesMesh";
  56477. export * from "babylonjs/Meshes/mesh";
  56478. export * from "babylonjs/Meshes/mesh.vertexData";
  56479. export * from "babylonjs/Meshes/meshBuilder";
  56480. export * from "babylonjs/Meshes/meshSimplification";
  56481. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  56482. export * from "babylonjs/Meshes/polygonMesh";
  56483. export * from "babylonjs/Meshes/subMesh";
  56484. export * from "babylonjs/Meshes/meshLODLevel";
  56485. export * from "babylonjs/Meshes/transformNode";
  56486. export * from "babylonjs/Meshes/Builders/index";
  56487. export * from "babylonjs/Meshes/dataBuffer";
  56488. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  56489. }
  56490. declare module "babylonjs/Morph/index" {
  56491. export * from "babylonjs/Morph/morphTarget";
  56492. export * from "babylonjs/Morph/morphTargetManager";
  56493. }
  56494. declare module "babylonjs/Offline/database" {
  56495. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  56496. /**
  56497. * Class used to enable access to IndexedDB
  56498. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  56499. */
  56500. export class Database implements IOfflineProvider {
  56501. private _callbackManifestChecked;
  56502. private _currentSceneUrl;
  56503. private _db;
  56504. private _enableSceneOffline;
  56505. private _enableTexturesOffline;
  56506. private _manifestVersionFound;
  56507. private _mustUpdateRessources;
  56508. private _hasReachedQuota;
  56509. private _isSupported;
  56510. private _idbFactory;
  56511. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  56512. private static IsUASupportingBlobStorage;
  56513. /**
  56514. * Gets a boolean indicating if Database storate is enabled (off by default)
  56515. */
  56516. static IDBStorageEnabled: boolean;
  56517. /**
  56518. * Gets a boolean indicating if scene must be saved in the database
  56519. */
  56520. readonly enableSceneOffline: boolean;
  56521. /**
  56522. * Gets a boolean indicating if textures must be saved in the database
  56523. */
  56524. readonly enableTexturesOffline: boolean;
  56525. /**
  56526. * Creates a new Database
  56527. * @param urlToScene defines the url to load the scene
  56528. * @param callbackManifestChecked defines the callback to use when manifest is checked
  56529. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  56530. */
  56531. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  56532. private static _ParseURL;
  56533. private static _ReturnFullUrlLocation;
  56534. private _checkManifestFile;
  56535. /**
  56536. * Open the database and make it available
  56537. * @param successCallback defines the callback to call on success
  56538. * @param errorCallback defines the callback to call on error
  56539. */
  56540. open(successCallback: () => void, errorCallback: () => void): void;
  56541. /**
  56542. * Loads an image from the database
  56543. * @param url defines the url to load from
  56544. * @param image defines the target DOM image
  56545. */
  56546. loadImage(url: string, image: HTMLImageElement): void;
  56547. private _loadImageFromDBAsync;
  56548. private _saveImageIntoDBAsync;
  56549. private _checkVersionFromDB;
  56550. private _loadVersionFromDBAsync;
  56551. private _saveVersionIntoDBAsync;
  56552. /**
  56553. * Loads a file from database
  56554. * @param url defines the URL to load from
  56555. * @param sceneLoaded defines a callback to call on success
  56556. * @param progressCallBack defines a callback to call when progress changed
  56557. * @param errorCallback defines a callback to call on error
  56558. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  56559. */
  56560. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  56561. private _loadFileAsync;
  56562. private _saveFileAsync;
  56563. /**
  56564. * Validates if xhr data is correct
  56565. * @param xhr defines the request to validate
  56566. * @param dataType defines the expected data type
  56567. * @returns true if data is correct
  56568. */
  56569. private static _ValidateXHRData;
  56570. }
  56571. }
  56572. declare module "babylonjs/Offline/index" {
  56573. export * from "babylonjs/Offline/database";
  56574. export * from "babylonjs/Offline/IOfflineProvider";
  56575. }
  56576. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  56577. /** @hidden */
  56578. export var gpuUpdateParticlesPixelShader: {
  56579. name: string;
  56580. shader: string;
  56581. };
  56582. }
  56583. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  56584. /** @hidden */
  56585. export var gpuUpdateParticlesVertexShader: {
  56586. name: string;
  56587. shader: string;
  56588. };
  56589. }
  56590. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  56591. /** @hidden */
  56592. export var clipPlaneFragmentDeclaration2: {
  56593. name: string;
  56594. shader: string;
  56595. };
  56596. }
  56597. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  56598. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  56599. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56600. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56601. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56602. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56603. /** @hidden */
  56604. export var gpuRenderParticlesPixelShader: {
  56605. name: string;
  56606. shader: string;
  56607. };
  56608. }
  56609. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  56610. /** @hidden */
  56611. export var clipPlaneVertexDeclaration2: {
  56612. name: string;
  56613. shader: string;
  56614. };
  56615. }
  56616. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  56617. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  56618. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56619. /** @hidden */
  56620. export var gpuRenderParticlesVertexShader: {
  56621. name: string;
  56622. shader: string;
  56623. };
  56624. }
  56625. declare module "babylonjs/Particles/gpuParticleSystem" {
  56626. import { Nullable } from "babylonjs/types";
  56627. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  56628. import { Observable } from "babylonjs/Misc/observable";
  56629. import { Color4, Color3 } from "babylonjs/Maths/math";
  56630. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56631. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  56632. import { Scene, IDisposable } from "babylonjs/scene";
  56633. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  56634. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  56635. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  56636. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  56637. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  56638. /**
  56639. * This represents a GPU particle system in Babylon
  56640. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  56641. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  56642. */
  56643. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  56644. /**
  56645. * The layer mask we are rendering the particles through.
  56646. */
  56647. layerMask: number;
  56648. private _capacity;
  56649. private _activeCount;
  56650. private _currentActiveCount;
  56651. private _accumulatedCount;
  56652. private _renderEffect;
  56653. private _updateEffect;
  56654. private _buffer0;
  56655. private _buffer1;
  56656. private _spriteBuffer;
  56657. private _updateVAO;
  56658. private _renderVAO;
  56659. private _targetIndex;
  56660. private _sourceBuffer;
  56661. private _targetBuffer;
  56662. private _engine;
  56663. private _currentRenderId;
  56664. private _started;
  56665. private _stopped;
  56666. private _timeDelta;
  56667. private _randomTexture;
  56668. private _randomTexture2;
  56669. private _attributesStrideSize;
  56670. private _updateEffectOptions;
  56671. private _randomTextureSize;
  56672. private _actualFrame;
  56673. private readonly _rawTextureWidth;
  56674. /**
  56675. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  56676. */
  56677. static readonly IsSupported: boolean;
  56678. /**
  56679. * An event triggered when the system is disposed.
  56680. */
  56681. onDisposeObservable: Observable<GPUParticleSystem>;
  56682. /**
  56683. * Gets the maximum number of particles active at the same time.
  56684. * @returns The max number of active particles.
  56685. */
  56686. getCapacity(): number;
  56687. /**
  56688. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  56689. * to override the particles.
  56690. */
  56691. forceDepthWrite: boolean;
  56692. /**
  56693. * Gets or set the number of active particles
  56694. */
  56695. activeParticleCount: number;
  56696. private _preWarmDone;
  56697. /**
  56698. * Is this system ready to be used/rendered
  56699. * @return true if the system is ready
  56700. */
  56701. isReady(): boolean;
  56702. /**
  56703. * Gets if the system has been started. (Note: this will still be true after stop is called)
  56704. * @returns True if it has been started, otherwise false.
  56705. */
  56706. isStarted(): boolean;
  56707. /**
  56708. * Starts the particle system and begins to emit
  56709. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  56710. */
  56711. start(delay?: number): void;
  56712. /**
  56713. * Stops the particle system.
  56714. */
  56715. stop(): void;
  56716. /**
  56717. * Remove all active particles
  56718. */
  56719. reset(): void;
  56720. /**
  56721. * Returns the string "GPUParticleSystem"
  56722. * @returns a string containing the class name
  56723. */
  56724. getClassName(): string;
  56725. private _colorGradientsTexture;
  56726. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  56727. /**
  56728. * Adds a new color gradient
  56729. * @param gradient defines the gradient to use (between 0 and 1)
  56730. * @param color1 defines the color to affect to the specified gradient
  56731. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  56732. * @returns the current particle system
  56733. */
  56734. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  56735. /**
  56736. * Remove a specific color gradient
  56737. * @param gradient defines the gradient to remove
  56738. * @returns the current particle system
  56739. */
  56740. removeColorGradient(gradient: number): GPUParticleSystem;
  56741. private _angularSpeedGradientsTexture;
  56742. private _sizeGradientsTexture;
  56743. private _velocityGradientsTexture;
  56744. private _limitVelocityGradientsTexture;
  56745. private _dragGradientsTexture;
  56746. private _addFactorGradient;
  56747. /**
  56748. * Adds a new size gradient
  56749. * @param gradient defines the gradient to use (between 0 and 1)
  56750. * @param factor defines the size factor to affect to the specified gradient
  56751. * @returns the current particle system
  56752. */
  56753. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  56754. /**
  56755. * Remove a specific size gradient
  56756. * @param gradient defines the gradient to remove
  56757. * @returns the current particle system
  56758. */
  56759. removeSizeGradient(gradient: number): GPUParticleSystem;
  56760. /**
  56761. * Adds a new angular speed gradient
  56762. * @param gradient defines the gradient to use (between 0 and 1)
  56763. * @param factor defines the angular speed to affect to the specified gradient
  56764. * @returns the current particle system
  56765. */
  56766. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  56767. /**
  56768. * Remove a specific angular speed gradient
  56769. * @param gradient defines the gradient to remove
  56770. * @returns the current particle system
  56771. */
  56772. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  56773. /**
  56774. * Adds a new velocity gradient
  56775. * @param gradient defines the gradient to use (between 0 and 1)
  56776. * @param factor defines the velocity to affect to the specified gradient
  56777. * @returns the current particle system
  56778. */
  56779. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56780. /**
  56781. * Remove a specific velocity gradient
  56782. * @param gradient defines the gradient to remove
  56783. * @returns the current particle system
  56784. */
  56785. removeVelocityGradient(gradient: number): GPUParticleSystem;
  56786. /**
  56787. * Adds a new limit velocity gradient
  56788. * @param gradient defines the gradient to use (between 0 and 1)
  56789. * @param factor defines the limit velocity value to affect to the specified gradient
  56790. * @returns the current particle system
  56791. */
  56792. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56793. /**
  56794. * Remove a specific limit velocity gradient
  56795. * @param gradient defines the gradient to remove
  56796. * @returns the current particle system
  56797. */
  56798. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  56799. /**
  56800. * Adds a new drag gradient
  56801. * @param gradient defines the gradient to use (between 0 and 1)
  56802. * @param factor defines the drag value to affect to the specified gradient
  56803. * @returns the current particle system
  56804. */
  56805. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  56806. /**
  56807. * Remove a specific drag gradient
  56808. * @param gradient defines the gradient to remove
  56809. * @returns the current particle system
  56810. */
  56811. removeDragGradient(gradient: number): GPUParticleSystem;
  56812. /**
  56813. * Not supported by GPUParticleSystem
  56814. * @param gradient defines the gradient to use (between 0 and 1)
  56815. * @param factor defines the emit rate value to affect to the specified gradient
  56816. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56817. * @returns the current particle system
  56818. */
  56819. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56820. /**
  56821. * Not supported by GPUParticleSystem
  56822. * @param gradient defines the gradient to remove
  56823. * @returns the current particle system
  56824. */
  56825. removeEmitRateGradient(gradient: number): IParticleSystem;
  56826. /**
  56827. * Not supported by GPUParticleSystem
  56828. * @param gradient defines the gradient to use (between 0 and 1)
  56829. * @param factor defines the start size value to affect to the specified gradient
  56830. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56831. * @returns the current particle system
  56832. */
  56833. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56834. /**
  56835. * Not supported by GPUParticleSystem
  56836. * @param gradient defines the gradient to remove
  56837. * @returns the current particle system
  56838. */
  56839. removeStartSizeGradient(gradient: number): IParticleSystem;
  56840. /**
  56841. * Not supported by GPUParticleSystem
  56842. * @param gradient defines the gradient to use (between 0 and 1)
  56843. * @param min defines the color remap minimal range
  56844. * @param max defines the color remap maximal range
  56845. * @returns the current particle system
  56846. */
  56847. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56848. /**
  56849. * Not supported by GPUParticleSystem
  56850. * @param gradient defines the gradient to remove
  56851. * @returns the current particle system
  56852. */
  56853. removeColorRemapGradient(): IParticleSystem;
  56854. /**
  56855. * Not supported by GPUParticleSystem
  56856. * @param gradient defines the gradient to use (between 0 and 1)
  56857. * @param min defines the alpha remap minimal range
  56858. * @param max defines the alpha remap maximal range
  56859. * @returns the current particle system
  56860. */
  56861. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56862. /**
  56863. * Not supported by GPUParticleSystem
  56864. * @param gradient defines the gradient to remove
  56865. * @returns the current particle system
  56866. */
  56867. removeAlphaRemapGradient(): IParticleSystem;
  56868. /**
  56869. * Not supported by GPUParticleSystem
  56870. * @param gradient defines the gradient to use (between 0 and 1)
  56871. * @param color defines the color to affect to the specified gradient
  56872. * @returns the current particle system
  56873. */
  56874. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  56875. /**
  56876. * Not supported by GPUParticleSystem
  56877. * @param gradient defines the gradient to remove
  56878. * @returns the current particle system
  56879. */
  56880. removeRampGradient(): IParticleSystem;
  56881. /**
  56882. * Not supported by GPUParticleSystem
  56883. * @returns the list of ramp gradients
  56884. */
  56885. getRampGradients(): Nullable<Array<Color3Gradient>>;
  56886. /**
  56887. * Not supported by GPUParticleSystem
  56888. * Gets or sets a boolean indicating that ramp gradients must be used
  56889. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  56890. */
  56891. useRampGradients: boolean;
  56892. /**
  56893. * Not supported by GPUParticleSystem
  56894. * @param gradient defines the gradient to use (between 0 and 1)
  56895. * @param factor defines the life time factor to affect to the specified gradient
  56896. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56897. * @returns the current particle system
  56898. */
  56899. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56900. /**
  56901. * Not supported by GPUParticleSystem
  56902. * @param gradient defines the gradient to remove
  56903. * @returns the current particle system
  56904. */
  56905. removeLifeTimeGradient(gradient: number): IParticleSystem;
  56906. /**
  56907. * Instantiates a GPU particle system.
  56908. * 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.
  56909. * @param name The name of the particle system
  56910. * @param options The options used to create the system
  56911. * @param scene The scene the particle system belongs to
  56912. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  56913. */
  56914. constructor(name: string, options: Partial<{
  56915. capacity: number;
  56916. randomTextureSize: number;
  56917. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  56918. protected _reset(): void;
  56919. private _createUpdateVAO;
  56920. private _createRenderVAO;
  56921. private _initialize;
  56922. /** @hidden */
  56923. _recreateUpdateEffect(): void;
  56924. /** @hidden */
  56925. _recreateRenderEffect(): void;
  56926. /**
  56927. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  56928. * @param preWarm defines if we are in the pre-warmimg phase
  56929. */
  56930. animate(preWarm?: boolean): void;
  56931. private _createFactorGradientTexture;
  56932. private _createSizeGradientTexture;
  56933. private _createAngularSpeedGradientTexture;
  56934. private _createVelocityGradientTexture;
  56935. private _createLimitVelocityGradientTexture;
  56936. private _createDragGradientTexture;
  56937. private _createColorGradientTexture;
  56938. /**
  56939. * Renders the particle system in its current state
  56940. * @param preWarm defines if the system should only update the particles but not render them
  56941. * @returns the current number of particles
  56942. */
  56943. render(preWarm?: boolean): number;
  56944. /**
  56945. * Rebuilds the particle system
  56946. */
  56947. rebuild(): void;
  56948. private _releaseBuffers;
  56949. private _releaseVAOs;
  56950. /**
  56951. * Disposes the particle system and free the associated resources
  56952. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  56953. */
  56954. dispose(disposeTexture?: boolean): void;
  56955. /**
  56956. * Clones the particle system.
  56957. * @param name The name of the cloned object
  56958. * @param newEmitter The new emitter to use
  56959. * @returns the cloned particle system
  56960. */
  56961. clone(name: string, newEmitter: any): GPUParticleSystem;
  56962. /**
  56963. * Serializes the particle system to a JSON object.
  56964. * @returns the JSON object
  56965. */
  56966. serialize(): any;
  56967. /**
  56968. * Parses a JSON object to create a GPU particle system.
  56969. * @param parsedParticleSystem The JSON object to parse
  56970. * @param scene The scene to create the particle system in
  56971. * @param rootUrl The root url to use to load external dependencies like texture
  56972. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  56973. * @returns the parsed GPU particle system
  56974. */
  56975. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  56976. }
  56977. }
  56978. declare module "babylonjs/Particles/particleSystemSet" {
  56979. import { Nullable } from "babylonjs/types";
  56980. import { Color3 } from "babylonjs/Maths/math";
  56981. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56983. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56984. import { Scene, IDisposable } from "babylonjs/scene";
  56985. /**
  56986. * Represents a set of particle systems working together to create a specific effect
  56987. */
  56988. export class ParticleSystemSet implements IDisposable {
  56989. private _emitterCreationOptions;
  56990. private _emitterNode;
  56991. /**
  56992. * Gets the particle system list
  56993. */
  56994. systems: IParticleSystem[];
  56995. /**
  56996. * Gets the emitter node used with this set
  56997. */
  56998. readonly emitterNode: Nullable<TransformNode>;
  56999. /**
  57000. * Creates a new emitter mesh as a sphere
  57001. * @param options defines the options used to create the sphere
  57002. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  57003. * @param scene defines the hosting scene
  57004. */
  57005. setEmitterAsSphere(options: {
  57006. diameter: number;
  57007. segments: number;
  57008. color: Color3;
  57009. }, renderingGroupId: number, scene: Scene): void;
  57010. /**
  57011. * Starts all particle systems of the set
  57012. * @param emitter defines an optional mesh to use as emitter for the particle systems
  57013. */
  57014. start(emitter?: AbstractMesh): void;
  57015. /**
  57016. * Release all associated resources
  57017. */
  57018. dispose(): void;
  57019. /**
  57020. * Serialize the set into a JSON compatible object
  57021. * @returns a JSON compatible representation of the set
  57022. */
  57023. serialize(): any;
  57024. /**
  57025. * Parse a new ParticleSystemSet from a serialized source
  57026. * @param data defines a JSON compatible representation of the set
  57027. * @param scene defines the hosting scene
  57028. * @param gpu defines if we want GPU particles or CPU particles
  57029. * @returns a new ParticleSystemSet
  57030. */
  57031. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  57032. }
  57033. }
  57034. declare module "babylonjs/Particles/particleHelper" {
  57035. import { Nullable } from "babylonjs/types";
  57036. import { Scene } from "babylonjs/scene";
  57037. import { Vector3 } from "babylonjs/Maths/math";
  57038. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57039. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57040. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  57041. /**
  57042. * This class is made for on one-liner static method to help creating particle system set.
  57043. */
  57044. export class ParticleHelper {
  57045. /**
  57046. * Gets or sets base Assets URL
  57047. */
  57048. static BaseAssetsUrl: string;
  57049. /**
  57050. * Create a default particle system that you can tweak
  57051. * @param emitter defines the emitter to use
  57052. * @param capacity defines the system capacity (default is 500 particles)
  57053. * @param scene defines the hosting scene
  57054. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  57055. * @returns the new Particle system
  57056. */
  57057. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  57058. /**
  57059. * This is the main static method (one-liner) of this helper to create different particle systems
  57060. * @param type This string represents the type to the particle system to create
  57061. * @param scene The scene where the particle system should live
  57062. * @param gpu If the system will use gpu
  57063. * @returns the ParticleSystemSet created
  57064. */
  57065. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  57066. /**
  57067. * Static function used to export a particle system to a ParticleSystemSet variable.
  57068. * Please note that the emitter shape is not exported
  57069. * @param systems defines the particle systems to export
  57070. * @returns the created particle system set
  57071. */
  57072. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  57073. }
  57074. }
  57075. declare module "babylonjs/Particles/particleSystemComponent" {
  57076. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57077. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  57078. import "babylonjs/Shaders/particles.vertex";
  57079. module "babylonjs/Engines/engine" {
  57080. interface Engine {
  57081. /**
  57082. * Create an effect to use with particle systems.
  57083. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  57084. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  57085. * @param uniformsNames defines a list of attribute names
  57086. * @param samplers defines an array of string used to represent textures
  57087. * @param defines defines the string containing the defines to use to compile the shaders
  57088. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  57089. * @param onCompiled defines a function to call when the effect creation is successful
  57090. * @param onError defines a function to call when the effect creation has failed
  57091. * @returns the new Effect
  57092. */
  57093. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  57094. }
  57095. }
  57096. module "babylonjs/Meshes/mesh" {
  57097. interface Mesh {
  57098. /**
  57099. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  57100. * @returns an array of IParticleSystem
  57101. */
  57102. getEmittedParticleSystems(): IParticleSystem[];
  57103. /**
  57104. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  57105. * @returns an array of IParticleSystem
  57106. */
  57107. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  57108. }
  57109. }
  57110. /**
  57111. * @hidden
  57112. */
  57113. export var _IDoNeedToBeInTheBuild: number;
  57114. }
  57115. declare module "babylonjs/Particles/index" {
  57116. export * from "babylonjs/Particles/baseParticleSystem";
  57117. export * from "babylonjs/Particles/EmitterTypes/index";
  57118. export * from "babylonjs/Particles/gpuParticleSystem";
  57119. export * from "babylonjs/Particles/IParticleSystem";
  57120. export * from "babylonjs/Particles/particle";
  57121. export * from "babylonjs/Particles/particleHelper";
  57122. export * from "babylonjs/Particles/particleSystem";
  57123. export * from "babylonjs/Particles/particleSystemComponent";
  57124. export * from "babylonjs/Particles/particleSystemSet";
  57125. export * from "babylonjs/Particles/solidParticle";
  57126. export * from "babylonjs/Particles/solidParticleSystem";
  57127. export * from "babylonjs/Particles/subEmitter";
  57128. }
  57129. declare module "babylonjs/Physics/physicsEngineComponent" {
  57130. import { Nullable } from "babylonjs/types";
  57131. import { Observable, Observer } from "babylonjs/Misc/observable";
  57132. import { Vector3 } from "babylonjs/Maths/math";
  57133. import { Mesh } from "babylonjs/Meshes/mesh";
  57134. import { ISceneComponent } from "babylonjs/sceneComponent";
  57135. import { Scene } from "babylonjs/scene";
  57136. import { Node } from "babylonjs/node";
  57137. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57138. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57139. module "babylonjs/scene" {
  57140. interface Scene {
  57141. /** @hidden (Backing field) */
  57142. _physicsEngine: Nullable<IPhysicsEngine>;
  57143. /**
  57144. * Gets the current physics engine
  57145. * @returns a IPhysicsEngine or null if none attached
  57146. */
  57147. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  57148. /**
  57149. * Enables physics to the current scene
  57150. * @param gravity defines the scene's gravity for the physics engine
  57151. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  57152. * @return a boolean indicating if the physics engine was initialized
  57153. */
  57154. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  57155. /**
  57156. * Disables and disposes the physics engine associated with the scene
  57157. */
  57158. disablePhysicsEngine(): void;
  57159. /**
  57160. * Gets a boolean indicating if there is an active physics engine
  57161. * @returns a boolean indicating if there is an active physics engine
  57162. */
  57163. isPhysicsEnabled(): boolean;
  57164. /**
  57165. * Deletes a physics compound impostor
  57166. * @param compound defines the compound to delete
  57167. */
  57168. deleteCompoundImpostor(compound: any): void;
  57169. /**
  57170. * An event triggered when physic simulation is about to be run
  57171. */
  57172. onBeforePhysicsObservable: Observable<Scene>;
  57173. /**
  57174. * An event triggered when physic simulation has been done
  57175. */
  57176. onAfterPhysicsObservable: Observable<Scene>;
  57177. }
  57178. }
  57179. module "babylonjs/Meshes/abstractMesh" {
  57180. interface AbstractMesh {
  57181. /** @hidden */
  57182. _physicsImpostor: Nullable<PhysicsImpostor>;
  57183. /**
  57184. * Gets or sets impostor used for physic simulation
  57185. * @see http://doc.babylonjs.com/features/physics_engine
  57186. */
  57187. physicsImpostor: Nullable<PhysicsImpostor>;
  57188. /**
  57189. * Gets the current physics impostor
  57190. * @see http://doc.babylonjs.com/features/physics_engine
  57191. * @returns a physics impostor or null
  57192. */
  57193. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  57194. /** Apply a physic impulse to the mesh
  57195. * @param force defines the force to apply
  57196. * @param contactPoint defines where to apply the force
  57197. * @returns the current mesh
  57198. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57199. */
  57200. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  57201. /**
  57202. * Creates a physic joint between two meshes
  57203. * @param otherMesh defines the other mesh to use
  57204. * @param pivot1 defines the pivot to use on this mesh
  57205. * @param pivot2 defines the pivot to use on the other mesh
  57206. * @param options defines additional options (can be plugin dependent)
  57207. * @returns the current mesh
  57208. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  57209. */
  57210. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  57211. /** @hidden */
  57212. _disposePhysicsObserver: Nullable<Observer<Node>>;
  57213. }
  57214. }
  57215. /**
  57216. * Defines the physics engine scene component responsible to manage a physics engine
  57217. */
  57218. export class PhysicsEngineSceneComponent implements ISceneComponent {
  57219. /**
  57220. * The component name helpful to identify the component in the list of scene components.
  57221. */
  57222. readonly name: string;
  57223. /**
  57224. * The scene the component belongs to.
  57225. */
  57226. scene: Scene;
  57227. /**
  57228. * Creates a new instance of the component for the given scene
  57229. * @param scene Defines the scene to register the component in
  57230. */
  57231. constructor(scene: Scene);
  57232. /**
  57233. * Registers the component in a given scene
  57234. */
  57235. register(): void;
  57236. /**
  57237. * Rebuilds the elements related to this component in case of
  57238. * context lost for instance.
  57239. */
  57240. rebuild(): void;
  57241. /**
  57242. * Disposes the component and the associated ressources
  57243. */
  57244. dispose(): void;
  57245. }
  57246. }
  57247. declare module "babylonjs/Physics/physicsHelper" {
  57248. import { Nullable } from "babylonjs/types";
  57249. import { Vector3 } from "babylonjs/Maths/math";
  57250. import { Mesh } from "babylonjs/Meshes/mesh";
  57251. import { Scene } from "babylonjs/scene";
  57252. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57253. /**
  57254. * A helper for physics simulations
  57255. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57256. */
  57257. export class PhysicsHelper {
  57258. private _scene;
  57259. private _physicsEngine;
  57260. /**
  57261. * Initializes the Physics helper
  57262. * @param scene Babylon.js scene
  57263. */
  57264. constructor(scene: Scene);
  57265. /**
  57266. * Applies a radial explosion impulse
  57267. * @param origin the origin of the explosion
  57268. * @param radiusOrEventOptions the radius or the options of radial explosion
  57269. * @param strength the explosion strength
  57270. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57271. * @returns A physics radial explosion event, or null
  57272. */
  57273. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57274. /**
  57275. * Applies a radial explosion force
  57276. * @param origin the origin of the explosion
  57277. * @param radiusOrEventOptions the radius or the options of radial explosion
  57278. * @param strength the explosion strength
  57279. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57280. * @returns A physics radial explosion event, or null
  57281. */
  57282. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57283. /**
  57284. * Creates a gravitational field
  57285. * @param origin the origin of the explosion
  57286. * @param radiusOrEventOptions the radius or the options of radial explosion
  57287. * @param strength the explosion strength
  57288. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57289. * @returns A physics gravitational field event, or null
  57290. */
  57291. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  57292. /**
  57293. * Creates a physics updraft event
  57294. * @param origin the origin of the updraft
  57295. * @param radiusOrEventOptions the radius or the options of the updraft
  57296. * @param strength the strength of the updraft
  57297. * @param height the height of the updraft
  57298. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  57299. * @returns A physics updraft event, or null
  57300. */
  57301. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  57302. /**
  57303. * Creates a physics vortex event
  57304. * @param origin the of the vortex
  57305. * @param radiusOrEventOptions the radius or the options of the vortex
  57306. * @param strength the strength of the vortex
  57307. * @param height the height of the vortex
  57308. * @returns a Physics vortex event, or null
  57309. * A physics vortex event or null
  57310. */
  57311. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  57312. }
  57313. /**
  57314. * Represents a physics radial explosion event
  57315. */
  57316. class PhysicsRadialExplosionEvent {
  57317. private _scene;
  57318. private _options;
  57319. private _sphere;
  57320. private _dataFetched;
  57321. /**
  57322. * Initializes a radial explosioin event
  57323. * @param _scene BabylonJS scene
  57324. * @param _options The options for the vortex event
  57325. */
  57326. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  57327. /**
  57328. * Returns the data related to the radial explosion event (sphere).
  57329. * @returns The radial explosion event data
  57330. */
  57331. getData(): PhysicsRadialExplosionEventData;
  57332. /**
  57333. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  57334. * @param impostor A physics imposter
  57335. * @param origin the origin of the explosion
  57336. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  57337. */
  57338. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  57339. /**
  57340. * Triggers affecterd impostors callbacks
  57341. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  57342. */
  57343. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  57344. /**
  57345. * Disposes the sphere.
  57346. * @param force Specifies if the sphere should be disposed by force
  57347. */
  57348. dispose(force?: boolean): void;
  57349. /*** Helpers ***/
  57350. private _prepareSphere;
  57351. private _intersectsWithSphere;
  57352. }
  57353. /**
  57354. * Represents a gravitational field event
  57355. */
  57356. class PhysicsGravitationalFieldEvent {
  57357. private _physicsHelper;
  57358. private _scene;
  57359. private _origin;
  57360. private _options;
  57361. private _tickCallback;
  57362. private _sphere;
  57363. private _dataFetched;
  57364. /**
  57365. * Initializes the physics gravitational field event
  57366. * @param _physicsHelper A physics helper
  57367. * @param _scene BabylonJS scene
  57368. * @param _origin The origin position of the gravitational field event
  57369. * @param _options The options for the vortex event
  57370. */
  57371. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  57372. /**
  57373. * Returns the data related to the gravitational field event (sphere).
  57374. * @returns A gravitational field event
  57375. */
  57376. getData(): PhysicsGravitationalFieldEventData;
  57377. /**
  57378. * Enables the gravitational field.
  57379. */
  57380. enable(): void;
  57381. /**
  57382. * Disables the gravitational field.
  57383. */
  57384. disable(): void;
  57385. /**
  57386. * Disposes the sphere.
  57387. * @param force The force to dispose from the gravitational field event
  57388. */
  57389. dispose(force?: boolean): void;
  57390. private _tick;
  57391. }
  57392. /**
  57393. * Represents a physics updraft event
  57394. */
  57395. class PhysicsUpdraftEvent {
  57396. private _scene;
  57397. private _origin;
  57398. private _options;
  57399. private _physicsEngine;
  57400. private _originTop;
  57401. private _originDirection;
  57402. private _tickCallback;
  57403. private _cylinder;
  57404. private _cylinderPosition;
  57405. private _dataFetched;
  57406. /**
  57407. * Initializes the physics updraft event
  57408. * @param _scene BabylonJS scene
  57409. * @param _origin The origin position of the updraft
  57410. * @param _options The options for the updraft event
  57411. */
  57412. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  57413. /**
  57414. * Returns the data related to the updraft event (cylinder).
  57415. * @returns A physics updraft event
  57416. */
  57417. getData(): PhysicsUpdraftEventData;
  57418. /**
  57419. * Enables the updraft.
  57420. */
  57421. enable(): void;
  57422. /**
  57423. * Disables the updraft.
  57424. */
  57425. disable(): void;
  57426. /**
  57427. * Disposes the cylinder.
  57428. * @param force Specifies if the updraft should be disposed by force
  57429. */
  57430. dispose(force?: boolean): void;
  57431. private getImpostorHitData;
  57432. private _tick;
  57433. /*** Helpers ***/
  57434. private _prepareCylinder;
  57435. private _intersectsWithCylinder;
  57436. }
  57437. /**
  57438. * Represents a physics vortex event
  57439. */
  57440. class PhysicsVortexEvent {
  57441. private _scene;
  57442. private _origin;
  57443. private _options;
  57444. private _physicsEngine;
  57445. private _originTop;
  57446. private _tickCallback;
  57447. private _cylinder;
  57448. private _cylinderPosition;
  57449. private _dataFetched;
  57450. /**
  57451. * Initializes the physics vortex event
  57452. * @param _scene The BabylonJS scene
  57453. * @param _origin The origin position of the vortex
  57454. * @param _options The options for the vortex event
  57455. */
  57456. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  57457. /**
  57458. * Returns the data related to the vortex event (cylinder).
  57459. * @returns The physics vortex event data
  57460. */
  57461. getData(): PhysicsVortexEventData;
  57462. /**
  57463. * Enables the vortex.
  57464. */
  57465. enable(): void;
  57466. /**
  57467. * Disables the cortex.
  57468. */
  57469. disable(): void;
  57470. /**
  57471. * Disposes the sphere.
  57472. * @param force
  57473. */
  57474. dispose(force?: boolean): void;
  57475. private getImpostorHitData;
  57476. private _tick;
  57477. /*** Helpers ***/
  57478. private _prepareCylinder;
  57479. private _intersectsWithCylinder;
  57480. }
  57481. /**
  57482. * Options fot the radial explosion event
  57483. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57484. */
  57485. export class PhysicsRadialExplosionEventOptions {
  57486. /**
  57487. * The radius of the sphere for the radial explosion.
  57488. */
  57489. radius: number;
  57490. /**
  57491. * The strenth of the explosion.
  57492. */
  57493. strength: number;
  57494. /**
  57495. * The strenght of the force in correspondence to the distance of the affected object
  57496. */
  57497. falloff: PhysicsRadialImpulseFalloff;
  57498. /**
  57499. * Sphere options for the radial explosion.
  57500. */
  57501. sphere: {
  57502. segments: number;
  57503. diameter: number;
  57504. };
  57505. /**
  57506. * Sphere options for the radial explosion.
  57507. */
  57508. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  57509. }
  57510. /**
  57511. * Options fot the updraft event
  57512. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57513. */
  57514. export class PhysicsUpdraftEventOptions {
  57515. /**
  57516. * The radius of the cylinder for the vortex
  57517. */
  57518. radius: number;
  57519. /**
  57520. * The strenth of the updraft.
  57521. */
  57522. strength: number;
  57523. /**
  57524. * The height of the cylinder for the updraft.
  57525. */
  57526. height: number;
  57527. /**
  57528. * The mode for the the updraft.
  57529. */
  57530. updraftMode: PhysicsUpdraftMode;
  57531. }
  57532. /**
  57533. * Options fot the vortex event
  57534. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57535. */
  57536. export class PhysicsVortexEventOptions {
  57537. /**
  57538. * The radius of the cylinder for the vortex
  57539. */
  57540. radius: number;
  57541. /**
  57542. * The strenth of the vortex.
  57543. */
  57544. strength: number;
  57545. /**
  57546. * The height of the cylinder for the vortex.
  57547. */
  57548. height: number;
  57549. /**
  57550. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  57551. */
  57552. centripetalForceThreshold: number;
  57553. /**
  57554. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  57555. */
  57556. centripetalForceMultiplier: number;
  57557. /**
  57558. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  57559. */
  57560. centrifugalForceMultiplier: number;
  57561. /**
  57562. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  57563. */
  57564. updraftForceMultiplier: number;
  57565. }
  57566. /**
  57567. * The strenght of the force in correspondence to the distance of the affected object
  57568. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57569. */
  57570. export enum PhysicsRadialImpulseFalloff {
  57571. /** Defines that impulse is constant in strength across it's whole radius */
  57572. Constant = 0,
  57573. /** Defines that impulse gets weaker if it's further from the origin */
  57574. Linear = 1
  57575. }
  57576. /**
  57577. * The strength of the force in correspondence to the distance of the affected object
  57578. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57579. */
  57580. export enum PhysicsUpdraftMode {
  57581. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  57582. Center = 0,
  57583. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  57584. Perpendicular = 1
  57585. }
  57586. /**
  57587. * Interface for a physics hit data
  57588. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57589. */
  57590. export interface PhysicsHitData {
  57591. /**
  57592. * The force applied at the contact point
  57593. */
  57594. force: Vector3;
  57595. /**
  57596. * The contact point
  57597. */
  57598. contactPoint: Vector3;
  57599. /**
  57600. * The distance from the origin to the contact point
  57601. */
  57602. distanceFromOrigin: number;
  57603. }
  57604. /**
  57605. * Interface for radial explosion event data
  57606. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57607. */
  57608. export interface PhysicsRadialExplosionEventData {
  57609. /**
  57610. * A sphere used for the radial explosion event
  57611. */
  57612. sphere: Mesh;
  57613. }
  57614. /**
  57615. * Interface for gravitational field event data
  57616. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57617. */
  57618. export interface PhysicsGravitationalFieldEventData {
  57619. /**
  57620. * A sphere mesh used for the gravitational field event
  57621. */
  57622. sphere: Mesh;
  57623. }
  57624. /**
  57625. * Interface for updraft event data
  57626. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57627. */
  57628. export interface PhysicsUpdraftEventData {
  57629. /**
  57630. * A cylinder used for the updraft event
  57631. */
  57632. cylinder: Mesh;
  57633. }
  57634. /**
  57635. * Interface for vortex event data
  57636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57637. */
  57638. export interface PhysicsVortexEventData {
  57639. /**
  57640. * A cylinder used for the vortex event
  57641. */
  57642. cylinder: Mesh;
  57643. }
  57644. /**
  57645. * Interface for an affected physics impostor
  57646. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57647. */
  57648. export interface PhysicsAffectedImpostorWithData {
  57649. /**
  57650. * The impostor affected by the effect
  57651. */
  57652. impostor: PhysicsImpostor;
  57653. /**
  57654. * The data about the hit/horce from the explosion
  57655. */
  57656. hitData: PhysicsHitData;
  57657. }
  57658. }
  57659. declare module "babylonjs/Physics/Plugins/index" {
  57660. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  57661. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  57662. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  57663. }
  57664. declare module "babylonjs/Physics/index" {
  57665. export * from "babylonjs/Physics/IPhysicsEngine";
  57666. export * from "babylonjs/Physics/physicsEngine";
  57667. export * from "babylonjs/Physics/physicsEngineComponent";
  57668. export * from "babylonjs/Physics/physicsHelper";
  57669. export * from "babylonjs/Physics/physicsImpostor";
  57670. export * from "babylonjs/Physics/physicsJoint";
  57671. export * from "babylonjs/Physics/Plugins/index";
  57672. }
  57673. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  57674. /** @hidden */
  57675. export var blackAndWhitePixelShader: {
  57676. name: string;
  57677. shader: string;
  57678. };
  57679. }
  57680. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  57681. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57682. import { Camera } from "babylonjs/Cameras/camera";
  57683. import { Engine } from "babylonjs/Engines/engine";
  57684. import "babylonjs/Shaders/blackAndWhite.fragment";
  57685. /**
  57686. * Post process used to render in black and white
  57687. */
  57688. export class BlackAndWhitePostProcess extends PostProcess {
  57689. /**
  57690. * Linear about to convert he result to black and white (default: 1)
  57691. */
  57692. degree: number;
  57693. /**
  57694. * Creates a black and white post process
  57695. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  57696. * @param name The name of the effect.
  57697. * @param options The required width/height ratio to downsize to before computing the render pass.
  57698. * @param camera The camera to apply the render pass to.
  57699. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57700. * @param engine The engine which the post process will be applied. (default: current engine)
  57701. * @param reusable If the post process can be reused on the same frame. (default: false)
  57702. */
  57703. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57704. }
  57705. }
  57706. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  57707. import { Nullable } from "babylonjs/types";
  57708. import { Camera } from "babylonjs/Cameras/camera";
  57709. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57710. import { Engine } from "babylonjs/Engines/engine";
  57711. /**
  57712. * This represents a set of one or more post processes in Babylon.
  57713. * A post process can be used to apply a shader to a texture after it is rendered.
  57714. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57715. */
  57716. export class PostProcessRenderEffect {
  57717. private _postProcesses;
  57718. private _getPostProcesses;
  57719. private _singleInstance;
  57720. private _cameras;
  57721. private _indicesForCamera;
  57722. /**
  57723. * Name of the effect
  57724. * @hidden
  57725. */
  57726. _name: string;
  57727. /**
  57728. * Instantiates a post process render effect.
  57729. * A post process can be used to apply a shader to a texture after it is rendered.
  57730. * @param engine The engine the effect is tied to
  57731. * @param name The name of the effect
  57732. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  57733. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  57734. */
  57735. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  57736. /**
  57737. * Checks if all the post processes in the effect are supported.
  57738. */
  57739. readonly isSupported: boolean;
  57740. /**
  57741. * Updates the current state of the effect
  57742. * @hidden
  57743. */
  57744. _update(): void;
  57745. /**
  57746. * Attaches the effect on cameras
  57747. * @param cameras The camera to attach to.
  57748. * @hidden
  57749. */
  57750. _attachCameras(cameras: Camera): void;
  57751. /**
  57752. * Attaches the effect on cameras
  57753. * @param cameras The camera to attach to.
  57754. * @hidden
  57755. */
  57756. _attachCameras(cameras: Camera[]): void;
  57757. /**
  57758. * Detaches the effect on cameras
  57759. * @param cameras The camera to detatch from.
  57760. * @hidden
  57761. */
  57762. _detachCameras(cameras: Camera): void;
  57763. /**
  57764. * Detatches the effect on cameras
  57765. * @param cameras The camera to detatch from.
  57766. * @hidden
  57767. */
  57768. _detachCameras(cameras: Camera[]): void;
  57769. /**
  57770. * Enables the effect on given cameras
  57771. * @param cameras The camera to enable.
  57772. * @hidden
  57773. */
  57774. _enable(cameras: Camera): void;
  57775. /**
  57776. * Enables the effect on given cameras
  57777. * @param cameras The camera to enable.
  57778. * @hidden
  57779. */
  57780. _enable(cameras: Nullable<Camera[]>): void;
  57781. /**
  57782. * Disables the effect on the given cameras
  57783. * @param cameras The camera to disable.
  57784. * @hidden
  57785. */
  57786. _disable(cameras: Camera): void;
  57787. /**
  57788. * Disables the effect on the given cameras
  57789. * @param cameras The camera to disable.
  57790. * @hidden
  57791. */
  57792. _disable(cameras: Nullable<Camera[]>): void;
  57793. /**
  57794. * Gets a list of the post processes contained in the effect.
  57795. * @param camera The camera to get the post processes on.
  57796. * @returns The list of the post processes in the effect.
  57797. */
  57798. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  57799. }
  57800. }
  57801. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  57802. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57803. /** @hidden */
  57804. export var extractHighlightsPixelShader: {
  57805. name: string;
  57806. shader: string;
  57807. };
  57808. }
  57809. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  57810. import { Nullable } from "babylonjs/types";
  57811. import { Camera } from "babylonjs/Cameras/camera";
  57812. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57813. import { Engine } from "babylonjs/Engines/engine";
  57814. import "babylonjs/Shaders/extractHighlights.fragment";
  57815. /**
  57816. * 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.
  57817. */
  57818. export class ExtractHighlightsPostProcess extends PostProcess {
  57819. /**
  57820. * The luminance threshold, pixels below this value will be set to black.
  57821. */
  57822. threshold: number;
  57823. /** @hidden */
  57824. _exposure: number;
  57825. /**
  57826. * Post process which has the input texture to be used when performing highlight extraction
  57827. * @hidden
  57828. */
  57829. _inputPostProcess: Nullable<PostProcess>;
  57830. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57831. }
  57832. }
  57833. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  57834. /** @hidden */
  57835. export var bloomMergePixelShader: {
  57836. name: string;
  57837. shader: string;
  57838. };
  57839. }
  57840. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  57841. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57842. import { Nullable } from "babylonjs/types";
  57843. import { Engine } from "babylonjs/Engines/engine";
  57844. import { Camera } from "babylonjs/Cameras/camera";
  57845. import "babylonjs/Shaders/bloomMerge.fragment";
  57846. /**
  57847. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57848. */
  57849. export class BloomMergePostProcess extends PostProcess {
  57850. /** Weight of the bloom to be added to the original input. */
  57851. weight: number;
  57852. /**
  57853. * Creates a new instance of @see BloomMergePostProcess
  57854. * @param name The name of the effect.
  57855. * @param originalFromInput Post process which's input will be used for the merge.
  57856. * @param blurred Blurred highlights post process which's output will be used.
  57857. * @param weight Weight of the bloom to be added to the original input.
  57858. * @param options The required width/height ratio to downsize to before computing the render pass.
  57859. * @param camera The camera to apply the render pass to.
  57860. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57861. * @param engine The engine which the post process will be applied. (default: current engine)
  57862. * @param reusable If the post process can be reused on the same frame. (default: false)
  57863. * @param textureType Type of textures used when performing the post process. (default: 0)
  57864. * @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)
  57865. */
  57866. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  57867. /** Weight of the bloom to be added to the original input. */
  57868. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57869. }
  57870. }
  57871. declare module "babylonjs/PostProcesses/bloomEffect" {
  57872. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57873. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57874. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  57875. import { Camera } from "babylonjs/Cameras/camera";
  57876. import { Scene } from "babylonjs/scene";
  57877. /**
  57878. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  57879. */
  57880. export class BloomEffect extends PostProcessRenderEffect {
  57881. private bloomScale;
  57882. /**
  57883. * @hidden Internal
  57884. */
  57885. _effects: Array<PostProcess>;
  57886. /**
  57887. * @hidden Internal
  57888. */
  57889. _downscale: ExtractHighlightsPostProcess;
  57890. private _blurX;
  57891. private _blurY;
  57892. private _merge;
  57893. /**
  57894. * The luminance threshold to find bright areas of the image to bloom.
  57895. */
  57896. threshold: number;
  57897. /**
  57898. * The strength of the bloom.
  57899. */
  57900. weight: number;
  57901. /**
  57902. * Specifies the size of the bloom blur kernel, relative to the final output size
  57903. */
  57904. kernel: number;
  57905. /**
  57906. * Creates a new instance of @see BloomEffect
  57907. * @param scene The scene the effect belongs to.
  57908. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  57909. * @param bloomKernel The size of the kernel to be used when applying the blur.
  57910. * @param bloomWeight The the strength of bloom.
  57911. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57912. * @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)
  57913. */
  57914. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  57915. /**
  57916. * Disposes each of the internal effects for a given camera.
  57917. * @param camera The camera to dispose the effect on.
  57918. */
  57919. disposeEffects(camera: Camera): void;
  57920. /**
  57921. * @hidden Internal
  57922. */
  57923. _updateEffects(): void;
  57924. /**
  57925. * Internal
  57926. * @returns if all the contained post processes are ready.
  57927. * @hidden
  57928. */
  57929. _isReady(): boolean;
  57930. }
  57931. }
  57932. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  57933. /** @hidden */
  57934. export var chromaticAberrationPixelShader: {
  57935. name: string;
  57936. shader: string;
  57937. };
  57938. }
  57939. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  57940. import { Vector2 } from "babylonjs/Maths/math";
  57941. import { Nullable } from "babylonjs/types";
  57942. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57943. import { Camera } from "babylonjs/Cameras/camera";
  57944. import { Engine } from "babylonjs/Engines/engine";
  57945. import "babylonjs/Shaders/chromaticAberration.fragment";
  57946. /**
  57947. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  57948. */
  57949. export class ChromaticAberrationPostProcess extends PostProcess {
  57950. /**
  57951. * The amount of seperation of rgb channels (default: 30)
  57952. */
  57953. aberrationAmount: number;
  57954. /**
  57955. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  57956. */
  57957. radialIntensity: number;
  57958. /**
  57959. * 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))
  57960. */
  57961. direction: Vector2;
  57962. /**
  57963. * 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))
  57964. */
  57965. centerPosition: Vector2;
  57966. /**
  57967. * Creates a new instance ChromaticAberrationPostProcess
  57968. * @param name The name of the effect.
  57969. * @param screenWidth The width of the screen to apply the effect on.
  57970. * @param screenHeight The height of the screen to apply the effect on.
  57971. * @param options The required width/height ratio to downsize to before computing the render pass.
  57972. * @param camera The camera to apply the render pass to.
  57973. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57974. * @param engine The engine which the post process will be applied. (default: current engine)
  57975. * @param reusable If the post process can be reused on the same frame. (default: false)
  57976. * @param textureType Type of textures used when performing the post process. (default: 0)
  57977. * @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)
  57978. */
  57979. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57980. }
  57981. }
  57982. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  57983. /** @hidden */
  57984. export var circleOfConfusionPixelShader: {
  57985. name: string;
  57986. shader: string;
  57987. };
  57988. }
  57989. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  57990. import { Nullable } from "babylonjs/types";
  57991. import { Engine } from "babylonjs/Engines/engine";
  57992. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57993. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57994. import { Camera } from "babylonjs/Cameras/camera";
  57995. import "babylonjs/Shaders/circleOfConfusion.fragment";
  57996. /**
  57997. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  57998. */
  57999. export class CircleOfConfusionPostProcess extends PostProcess {
  58000. /**
  58001. * 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.
  58002. */
  58003. lensSize: number;
  58004. /**
  58005. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58006. */
  58007. fStop: number;
  58008. /**
  58009. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58010. */
  58011. focusDistance: number;
  58012. /**
  58013. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  58014. */
  58015. focalLength: number;
  58016. private _depthTexture;
  58017. /**
  58018. * Creates a new instance CircleOfConfusionPostProcess
  58019. * @param name The name of the effect.
  58020. * @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.
  58021. * @param options The required width/height ratio to downsize to before computing the render pass.
  58022. * @param camera The camera to apply the render pass to.
  58023. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58024. * @param engine The engine which the post process will be applied. (default: current engine)
  58025. * @param reusable If the post process can be reused on the same frame. (default: false)
  58026. * @param textureType Type of textures used when performing the post process. (default: 0)
  58027. * @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)
  58028. */
  58029. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58030. /**
  58031. * 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.
  58032. */
  58033. depthTexture: RenderTargetTexture;
  58034. }
  58035. }
  58036. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  58037. /** @hidden */
  58038. export var colorCorrectionPixelShader: {
  58039. name: string;
  58040. shader: string;
  58041. };
  58042. }
  58043. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  58044. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58045. import { Engine } from "babylonjs/Engines/engine";
  58046. import { Camera } from "babylonjs/Cameras/camera";
  58047. import "babylonjs/Shaders/colorCorrection.fragment";
  58048. /**
  58049. *
  58050. * This post-process allows the modification of rendered colors by using
  58051. * a 'look-up table' (LUT). This effect is also called Color Grading.
  58052. *
  58053. * The object needs to be provided an url to a texture containing the color
  58054. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  58055. * Use an image editing software to tweak the LUT to match your needs.
  58056. *
  58057. * For an example of a color LUT, see here:
  58058. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  58059. * For explanations on color grading, see here:
  58060. * @see http://udn.epicgames.com/Three/ColorGrading.html
  58061. *
  58062. */
  58063. export class ColorCorrectionPostProcess extends PostProcess {
  58064. private _colorTableTexture;
  58065. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58066. }
  58067. }
  58068. declare module "babylonjs/Shaders/convolution.fragment" {
  58069. /** @hidden */
  58070. export var convolutionPixelShader: {
  58071. name: string;
  58072. shader: string;
  58073. };
  58074. }
  58075. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  58076. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58077. import { Nullable } from "babylonjs/types";
  58078. import { Camera } from "babylonjs/Cameras/camera";
  58079. import { Engine } from "babylonjs/Engines/engine";
  58080. import "babylonjs/Shaders/convolution.fragment";
  58081. /**
  58082. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  58083. * input texture to perform effects such as edge detection or sharpening
  58084. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58085. */
  58086. export class ConvolutionPostProcess extends PostProcess {
  58087. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58088. kernel: number[];
  58089. /**
  58090. * Creates a new instance ConvolutionPostProcess
  58091. * @param name The name of the effect.
  58092. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  58093. * @param options The required width/height ratio to downsize to before computing the render pass.
  58094. * @param camera The camera to apply the render pass to.
  58095. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58096. * @param engine The engine which the post process will be applied. (default: current engine)
  58097. * @param reusable If the post process can be reused on the same frame. (default: false)
  58098. * @param textureType Type of textures used when performing the post process. (default: 0)
  58099. */
  58100. constructor(name: string,
  58101. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58102. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58103. /**
  58104. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58105. */
  58106. static EdgeDetect0Kernel: number[];
  58107. /**
  58108. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58109. */
  58110. static EdgeDetect1Kernel: number[];
  58111. /**
  58112. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58113. */
  58114. static EdgeDetect2Kernel: number[];
  58115. /**
  58116. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58117. */
  58118. static SharpenKernel: number[];
  58119. /**
  58120. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58121. */
  58122. static EmbossKernel: number[];
  58123. /**
  58124. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58125. */
  58126. static GaussianKernel: number[];
  58127. }
  58128. }
  58129. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  58130. import { Nullable } from "babylonjs/types";
  58131. import { Vector2 } from "babylonjs/Maths/math";
  58132. import { Camera } from "babylonjs/Cameras/camera";
  58133. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58134. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  58135. import { Engine } from "babylonjs/Engines/engine";
  58136. import { Scene } from "babylonjs/scene";
  58137. /**
  58138. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  58139. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  58140. * based on samples that have a large difference in distance than the center pixel.
  58141. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  58142. */
  58143. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  58144. direction: Vector2;
  58145. /**
  58146. * Creates a new instance CircleOfConfusionPostProcess
  58147. * @param name The name of the effect.
  58148. * @param scene The scene the effect belongs to.
  58149. * @param direction The direction the blur should be applied.
  58150. * @param kernel The size of the kernel used to blur.
  58151. * @param options The required width/height ratio to downsize to before computing the render pass.
  58152. * @param camera The camera to apply the render pass to.
  58153. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  58154. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  58155. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58156. * @param engine The engine which the post process will be applied. (default: current engine)
  58157. * @param reusable If the post process can be reused on the same frame. (default: false)
  58158. * @param textureType Type of textures used when performing the post process. (default: 0)
  58159. * @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)
  58160. */
  58161. 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);
  58162. }
  58163. }
  58164. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  58165. /** @hidden */
  58166. export var depthOfFieldMergePixelShader: {
  58167. name: string;
  58168. shader: string;
  58169. };
  58170. }
  58171. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  58172. import { Nullable } from "babylonjs/types";
  58173. import { Camera } from "babylonjs/Cameras/camera";
  58174. import { Effect } from "babylonjs/Materials/effect";
  58175. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58176. import { Engine } from "babylonjs/Engines/engine";
  58177. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  58178. /**
  58179. * Options to be set when merging outputs from the default pipeline.
  58180. */
  58181. export class DepthOfFieldMergePostProcessOptions {
  58182. /**
  58183. * The original image to merge on top of
  58184. */
  58185. originalFromInput: PostProcess;
  58186. /**
  58187. * Parameters to perform the merge of the depth of field effect
  58188. */
  58189. depthOfField?: {
  58190. circleOfConfusion: PostProcess;
  58191. blurSteps: Array<PostProcess>;
  58192. };
  58193. /**
  58194. * Parameters to perform the merge of bloom effect
  58195. */
  58196. bloom?: {
  58197. blurred: PostProcess;
  58198. weight: number;
  58199. };
  58200. }
  58201. /**
  58202. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58203. */
  58204. export class DepthOfFieldMergePostProcess extends PostProcess {
  58205. private blurSteps;
  58206. /**
  58207. * Creates a new instance of DepthOfFieldMergePostProcess
  58208. * @param name The name of the effect.
  58209. * @param originalFromInput Post process which's input will be used for the merge.
  58210. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  58211. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  58212. * @param options The required width/height ratio to downsize to before computing the render pass.
  58213. * @param camera The camera to apply the render pass to.
  58214. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58215. * @param engine The engine which the post process will be applied. (default: current engine)
  58216. * @param reusable If the post process can be reused on the same frame. (default: false)
  58217. * @param textureType Type of textures used when performing the post process. (default: 0)
  58218. * @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)
  58219. */
  58220. 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);
  58221. /**
  58222. * Updates the effect with the current post process compile time values and recompiles the shader.
  58223. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  58224. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  58225. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  58226. * @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
  58227. * @param onCompiled Called when the shader has been compiled.
  58228. * @param onError Called if there is an error when compiling a shader.
  58229. */
  58230. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  58231. }
  58232. }
  58233. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  58234. import { Nullable } from "babylonjs/types";
  58235. import { Camera } from "babylonjs/Cameras/camera";
  58236. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58237. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  58238. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  58239. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  58240. import { Scene } from "babylonjs/scene";
  58241. /**
  58242. * Specifies the level of max blur that should be applied when using the depth of field effect
  58243. */
  58244. export enum DepthOfFieldEffectBlurLevel {
  58245. /**
  58246. * Subtle blur
  58247. */
  58248. Low = 0,
  58249. /**
  58250. * Medium blur
  58251. */
  58252. Medium = 1,
  58253. /**
  58254. * Large blur
  58255. */
  58256. High = 2
  58257. }
  58258. /**
  58259. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  58260. */
  58261. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  58262. private _circleOfConfusion;
  58263. /**
  58264. * @hidden Internal, blurs from high to low
  58265. */
  58266. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  58267. private _depthOfFieldBlurY;
  58268. private _dofMerge;
  58269. /**
  58270. * @hidden Internal post processes in depth of field effect
  58271. */
  58272. _effects: Array<PostProcess>;
  58273. /**
  58274. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  58275. */
  58276. focalLength: number;
  58277. /**
  58278. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58279. */
  58280. fStop: number;
  58281. /**
  58282. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58283. */
  58284. focusDistance: number;
  58285. /**
  58286. * 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.
  58287. */
  58288. lensSize: number;
  58289. /**
  58290. * Creates a new instance DepthOfFieldEffect
  58291. * @param scene The scene the effect belongs to.
  58292. * @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.
  58293. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58294. * @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)
  58295. */
  58296. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  58297. /**
  58298. * Get the current class name of the current effet
  58299. * @returns "DepthOfFieldEffect"
  58300. */
  58301. getClassName(): string;
  58302. /**
  58303. * 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.
  58304. */
  58305. depthTexture: RenderTargetTexture;
  58306. /**
  58307. * Disposes each of the internal effects for a given camera.
  58308. * @param camera The camera to dispose the effect on.
  58309. */
  58310. disposeEffects(camera: Camera): void;
  58311. /**
  58312. * @hidden Internal
  58313. */
  58314. _updateEffects(): void;
  58315. /**
  58316. * Internal
  58317. * @returns if all the contained post processes are ready.
  58318. * @hidden
  58319. */
  58320. _isReady(): boolean;
  58321. }
  58322. }
  58323. declare module "babylonjs/Shaders/displayPass.fragment" {
  58324. /** @hidden */
  58325. export var displayPassPixelShader: {
  58326. name: string;
  58327. shader: string;
  58328. };
  58329. }
  58330. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  58331. import { Nullable } from "babylonjs/types";
  58332. import { Camera } from "babylonjs/Cameras/camera";
  58333. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58334. import { Engine } from "babylonjs/Engines/engine";
  58335. import "babylonjs/Shaders/displayPass.fragment";
  58336. /**
  58337. * DisplayPassPostProcess which produces an output the same as it's input
  58338. */
  58339. export class DisplayPassPostProcess extends PostProcess {
  58340. /**
  58341. * Creates the DisplayPassPostProcess
  58342. * @param name The name of the effect.
  58343. * @param options The required width/height ratio to downsize to before computing the render pass.
  58344. * @param camera The camera to apply the render pass to.
  58345. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58346. * @param engine The engine which the post process will be applied. (default: current engine)
  58347. * @param reusable If the post process can be reused on the same frame. (default: false)
  58348. */
  58349. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58350. }
  58351. }
  58352. declare module "babylonjs/Shaders/filter.fragment" {
  58353. /** @hidden */
  58354. export var filterPixelShader: {
  58355. name: string;
  58356. shader: string;
  58357. };
  58358. }
  58359. declare module "babylonjs/PostProcesses/filterPostProcess" {
  58360. import { Nullable } from "babylonjs/types";
  58361. import { Matrix } from "babylonjs/Maths/math";
  58362. import { Camera } from "babylonjs/Cameras/camera";
  58363. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58364. import { Engine } from "babylonjs/Engines/engine";
  58365. import "babylonjs/Shaders/filter.fragment";
  58366. /**
  58367. * Applies a kernel filter to the image
  58368. */
  58369. export class FilterPostProcess extends PostProcess {
  58370. /** The matrix to be applied to the image */
  58371. kernelMatrix: Matrix;
  58372. /**
  58373. *
  58374. * @param name The name of the effect.
  58375. * @param kernelMatrix The matrix to be applied to the image
  58376. * @param options The required width/height ratio to downsize to before computing the render pass.
  58377. * @param camera The camera to apply the render pass to.
  58378. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58379. * @param engine The engine which the post process will be applied. (default: current engine)
  58380. * @param reusable If the post process can be reused on the same frame. (default: false)
  58381. */
  58382. constructor(name: string,
  58383. /** The matrix to be applied to the image */
  58384. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58385. }
  58386. }
  58387. declare module "babylonjs/Shaders/fxaa.fragment" {
  58388. /** @hidden */
  58389. export var fxaaPixelShader: {
  58390. name: string;
  58391. shader: string;
  58392. };
  58393. }
  58394. declare module "babylonjs/Shaders/fxaa.vertex" {
  58395. /** @hidden */
  58396. export var fxaaVertexShader: {
  58397. name: string;
  58398. shader: string;
  58399. };
  58400. }
  58401. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  58402. import { Nullable } from "babylonjs/types";
  58403. import { Camera } from "babylonjs/Cameras/camera";
  58404. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58405. import { Engine } from "babylonjs/Engines/engine";
  58406. import "babylonjs/Shaders/fxaa.fragment";
  58407. import "babylonjs/Shaders/fxaa.vertex";
  58408. /**
  58409. * Fxaa post process
  58410. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  58411. */
  58412. export class FxaaPostProcess extends PostProcess {
  58413. /** @hidden */
  58414. texelWidth: number;
  58415. /** @hidden */
  58416. texelHeight: number;
  58417. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58418. private _getDefines;
  58419. }
  58420. }
  58421. declare module "babylonjs/Shaders/grain.fragment" {
  58422. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58423. /** @hidden */
  58424. export var grainPixelShader: {
  58425. name: string;
  58426. shader: string;
  58427. };
  58428. }
  58429. declare module "babylonjs/PostProcesses/grainPostProcess" {
  58430. import { Nullable } from "babylonjs/types";
  58431. import { Camera } from "babylonjs/Cameras/camera";
  58432. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58433. import { Engine } from "babylonjs/Engines/engine";
  58434. import "babylonjs/Shaders/grain.fragment";
  58435. /**
  58436. * The GrainPostProcess adds noise to the image at mid luminance levels
  58437. */
  58438. export class GrainPostProcess extends PostProcess {
  58439. /**
  58440. * The intensity of the grain added (default: 30)
  58441. */
  58442. intensity: number;
  58443. /**
  58444. * If the grain should be randomized on every frame
  58445. */
  58446. animated: boolean;
  58447. /**
  58448. * Creates a new instance of @see GrainPostProcess
  58449. * @param name The name of the effect.
  58450. * @param options The required width/height ratio to downsize to before computing the render pass.
  58451. * @param camera The camera to apply the render pass to.
  58452. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58453. * @param engine The engine which the post process will be applied. (default: current engine)
  58454. * @param reusable If the post process can be reused on the same frame. (default: false)
  58455. * @param textureType Type of textures used when performing the post process. (default: 0)
  58456. * @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)
  58457. */
  58458. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58459. }
  58460. }
  58461. declare module "babylonjs/Shaders/highlights.fragment" {
  58462. /** @hidden */
  58463. export var highlightsPixelShader: {
  58464. name: string;
  58465. shader: string;
  58466. };
  58467. }
  58468. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  58469. import { Nullable } from "babylonjs/types";
  58470. import { Camera } from "babylonjs/Cameras/camera";
  58471. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58472. import { Engine } from "babylonjs/Engines/engine";
  58473. import "babylonjs/Shaders/highlights.fragment";
  58474. /**
  58475. * Extracts highlights from the image
  58476. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58477. */
  58478. export class HighlightsPostProcess extends PostProcess {
  58479. /**
  58480. * Extracts highlights from the image
  58481. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58482. * @param name The name of the effect.
  58483. * @param options The required width/height ratio to downsize to before computing the render pass.
  58484. * @param camera The camera to apply the render pass to.
  58485. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58486. * @param engine The engine which the post process will be applied. (default: current engine)
  58487. * @param reusable If the post process can be reused on the same frame. (default: false)
  58488. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  58489. */
  58490. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58491. }
  58492. }
  58493. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  58494. /** @hidden */
  58495. export var mrtFragmentDeclaration: {
  58496. name: string;
  58497. shader: string;
  58498. };
  58499. }
  58500. declare module "babylonjs/Shaders/geometry.fragment" {
  58501. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  58502. /** @hidden */
  58503. export var geometryPixelShader: {
  58504. name: string;
  58505. shader: string;
  58506. };
  58507. }
  58508. declare module "babylonjs/Shaders/geometry.vertex" {
  58509. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58510. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58511. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58512. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58513. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  58514. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  58515. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58516. /** @hidden */
  58517. export var geometryVertexShader: {
  58518. name: string;
  58519. shader: string;
  58520. };
  58521. }
  58522. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  58523. import { Matrix } from "babylonjs/Maths/math";
  58524. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58525. import { Mesh } from "babylonjs/Meshes/mesh";
  58526. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  58527. import { Effect } from "babylonjs/Materials/effect";
  58528. import { Scene } from "babylonjs/scene";
  58529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58530. import "babylonjs/Shaders/geometry.fragment";
  58531. import "babylonjs/Shaders/geometry.vertex";
  58532. /** @hidden */
  58533. interface ISavedTransformationMatrix {
  58534. world: Matrix;
  58535. viewProjection: Matrix;
  58536. }
  58537. /**
  58538. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  58539. */
  58540. export class GeometryBufferRenderer {
  58541. /**
  58542. * Constant used to retrieve the position texture index in the G-Buffer textures array
  58543. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  58544. */
  58545. static readonly POSITION_TEXTURE_TYPE: number;
  58546. /**
  58547. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  58548. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  58549. */
  58550. static readonly VELOCITY_TEXTURE_TYPE: number;
  58551. /**
  58552. * Dictionary used to store the previous transformation matrices of each rendered mesh
  58553. * in order to compute objects velocities when enableVelocity is set to "true"
  58554. * @hidden
  58555. */
  58556. _previousTransformationMatrices: {
  58557. [index: number]: ISavedTransformationMatrix;
  58558. };
  58559. /**
  58560. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  58561. * in order to compute objects velocities when enableVelocity is set to "true"
  58562. * @hidden
  58563. */
  58564. _previousBonesTransformationMatrices: {
  58565. [index: number]: Float32Array;
  58566. };
  58567. /**
  58568. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  58569. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  58570. */
  58571. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  58572. private _scene;
  58573. private _multiRenderTarget;
  58574. private _ratio;
  58575. private _enablePosition;
  58576. private _enableVelocity;
  58577. private _positionIndex;
  58578. private _velocityIndex;
  58579. protected _effect: Effect;
  58580. protected _cachedDefines: string;
  58581. /**
  58582. * Set the render list (meshes to be rendered) used in the G buffer.
  58583. */
  58584. renderList: Mesh[];
  58585. /**
  58586. * Gets wether or not G buffer are supported by the running hardware.
  58587. * This requires draw buffer supports
  58588. */
  58589. readonly isSupported: boolean;
  58590. /**
  58591. * Returns the index of the given texture type in the G-Buffer textures array
  58592. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  58593. * @returns the index of the given texture type in the G-Buffer textures array
  58594. */
  58595. getTextureIndex(textureType: number): number;
  58596. /**
  58597. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  58598. */
  58599. /**
  58600. * Sets whether or not objects positions are enabled for the G buffer.
  58601. */
  58602. enablePosition: boolean;
  58603. /**
  58604. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  58605. */
  58606. /**
  58607. * Sets wether or not objects velocities are enabled for the G buffer.
  58608. */
  58609. enableVelocity: boolean;
  58610. /**
  58611. * Gets the scene associated with the buffer.
  58612. */
  58613. readonly scene: Scene;
  58614. /**
  58615. * Gets the ratio used by the buffer during its creation.
  58616. * How big is the buffer related to the main canvas.
  58617. */
  58618. readonly ratio: number;
  58619. /** @hidden */
  58620. static _SceneComponentInitialization: (scene: Scene) => void;
  58621. /**
  58622. * Creates a new G Buffer for the scene
  58623. * @param scene The scene the buffer belongs to
  58624. * @param ratio How big is the buffer related to the main canvas.
  58625. */
  58626. constructor(scene: Scene, ratio?: number);
  58627. /**
  58628. * Checks wether everything is ready to render a submesh to the G buffer.
  58629. * @param subMesh the submesh to check readiness for
  58630. * @param useInstances is the mesh drawn using instance or not
  58631. * @returns true if ready otherwise false
  58632. */
  58633. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58634. /**
  58635. * Gets the current underlying G Buffer.
  58636. * @returns the buffer
  58637. */
  58638. getGBuffer(): MultiRenderTarget;
  58639. /**
  58640. * Gets the number of samples used to render the buffer (anti aliasing).
  58641. */
  58642. /**
  58643. * Sets the number of samples used to render the buffer (anti aliasing).
  58644. */
  58645. samples: number;
  58646. /**
  58647. * Disposes the renderer and frees up associated resources.
  58648. */
  58649. dispose(): void;
  58650. protected _createRenderTargets(): void;
  58651. private _copyBonesTransformationMatrices;
  58652. }
  58653. }
  58654. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  58655. import { Nullable } from "babylonjs/types";
  58656. import { Scene } from "babylonjs/scene";
  58657. import { ISceneComponent } from "babylonjs/sceneComponent";
  58658. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  58659. module "babylonjs/scene" {
  58660. interface Scene {
  58661. /** @hidden (Backing field) */
  58662. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58663. /**
  58664. * Gets or Sets the current geometry buffer associated to the scene.
  58665. */
  58666. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58667. /**
  58668. * Enables a GeometryBufferRender and associates it with the scene
  58669. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  58670. * @returns the GeometryBufferRenderer
  58671. */
  58672. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  58673. /**
  58674. * Disables the GeometryBufferRender associated with the scene
  58675. */
  58676. disableGeometryBufferRenderer(): void;
  58677. }
  58678. }
  58679. /**
  58680. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  58681. * in several rendering techniques.
  58682. */
  58683. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  58684. /**
  58685. * The component name helpful to identify the component in the list of scene components.
  58686. */
  58687. readonly name: string;
  58688. /**
  58689. * The scene the component belongs to.
  58690. */
  58691. scene: Scene;
  58692. /**
  58693. * Creates a new instance of the component for the given scene
  58694. * @param scene Defines the scene to register the component in
  58695. */
  58696. constructor(scene: Scene);
  58697. /**
  58698. * Registers the component in a given scene
  58699. */
  58700. register(): void;
  58701. /**
  58702. * Rebuilds the elements related to this component in case of
  58703. * context lost for instance.
  58704. */
  58705. rebuild(): void;
  58706. /**
  58707. * Disposes the component and the associated ressources
  58708. */
  58709. dispose(): void;
  58710. private _gatherRenderTargets;
  58711. }
  58712. }
  58713. declare module "babylonjs/Shaders/motionBlur.fragment" {
  58714. /** @hidden */
  58715. export var motionBlurPixelShader: {
  58716. name: string;
  58717. shader: string;
  58718. };
  58719. }
  58720. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  58721. import { Nullable } from "babylonjs/types";
  58722. import { Camera } from "babylonjs/Cameras/camera";
  58723. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58724. import { Scene } from "babylonjs/scene";
  58725. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58726. import "babylonjs/Animations/animatable";
  58727. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  58728. import "babylonjs/Shaders/motionBlur.fragment";
  58729. import { Engine } from "babylonjs/Engines/engine";
  58730. /**
  58731. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  58732. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  58733. * As an example, all you have to do is to create the post-process:
  58734. * var mb = new BABYLON.MotionBlurPostProcess(
  58735. * 'mb', // The name of the effect.
  58736. * scene, // The scene containing the objects to blur according to their velocity.
  58737. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  58738. * camera // The camera to apply the render pass to.
  58739. * );
  58740. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  58741. */
  58742. export class MotionBlurPostProcess extends PostProcess {
  58743. /**
  58744. * Defines how much the image is blurred by the movement. Default value is equal to 1
  58745. */
  58746. motionStrength: number;
  58747. /**
  58748. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  58749. */
  58750. /**
  58751. * Sets the number of iterations to be used for motion blur quality
  58752. */
  58753. motionBlurSamples: number;
  58754. private _motionBlurSamples;
  58755. private _geometryBufferRenderer;
  58756. /**
  58757. * Creates a new instance MotionBlurPostProcess
  58758. * @param name The name of the effect.
  58759. * @param scene The scene containing the objects to blur according to their velocity.
  58760. * @param options The required width/height ratio to downsize to before computing the render pass.
  58761. * @param camera The camera to apply the render pass to.
  58762. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58763. * @param engine The engine which the post process will be applied. (default: current engine)
  58764. * @param reusable If the post process can be reused on the same frame. (default: false)
  58765. * @param textureType Type of textures used when performing the post process. (default: 0)
  58766. * @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)
  58767. */
  58768. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58769. /**
  58770. * Excludes the given skinned mesh from computing bones velocities.
  58771. * 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.
  58772. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  58773. */
  58774. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58775. /**
  58776. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  58777. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  58778. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  58779. */
  58780. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58781. /**
  58782. * Disposes the post process.
  58783. * @param camera The camera to dispose the post process on.
  58784. */
  58785. dispose(camera?: Camera): void;
  58786. }
  58787. }
  58788. declare module "babylonjs/Shaders/refraction.fragment" {
  58789. /** @hidden */
  58790. export var refractionPixelShader: {
  58791. name: string;
  58792. shader: string;
  58793. };
  58794. }
  58795. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  58796. import { Color3 } from "babylonjs/Maths/math";
  58797. import { Camera } from "babylonjs/Cameras/camera";
  58798. import { Texture } from "babylonjs/Materials/Textures/texture";
  58799. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58800. import { Engine } from "babylonjs/Engines/engine";
  58801. import "babylonjs/Shaders/refraction.fragment";
  58802. /**
  58803. * Post process which applies a refractin texture
  58804. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58805. */
  58806. export class RefractionPostProcess extends PostProcess {
  58807. /** the base color of the refraction (used to taint the rendering) */
  58808. color: Color3;
  58809. /** simulated refraction depth */
  58810. depth: number;
  58811. /** the coefficient of the base color (0 to remove base color tainting) */
  58812. colorLevel: number;
  58813. private _refTexture;
  58814. private _ownRefractionTexture;
  58815. /**
  58816. * Gets or sets the refraction texture
  58817. * Please note that you are responsible for disposing the texture if you set it manually
  58818. */
  58819. refractionTexture: Texture;
  58820. /**
  58821. * Initializes the RefractionPostProcess
  58822. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58823. * @param name The name of the effect.
  58824. * @param refractionTextureUrl Url of the refraction texture to use
  58825. * @param color the base color of the refraction (used to taint the rendering)
  58826. * @param depth simulated refraction depth
  58827. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  58828. * @param camera The camera to apply the render pass to.
  58829. * @param options The required width/height ratio to downsize to before computing the render pass.
  58830. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58831. * @param engine The engine which the post process will be applied. (default: current engine)
  58832. * @param reusable If the post process can be reused on the same frame. (default: false)
  58833. */
  58834. constructor(name: string, refractionTextureUrl: string,
  58835. /** the base color of the refraction (used to taint the rendering) */
  58836. color: Color3,
  58837. /** simulated refraction depth */
  58838. depth: number,
  58839. /** the coefficient of the base color (0 to remove base color tainting) */
  58840. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58841. /**
  58842. * Disposes of the post process
  58843. * @param camera Camera to dispose post process on
  58844. */
  58845. dispose(camera: Camera): void;
  58846. }
  58847. }
  58848. declare module "babylonjs/Shaders/sharpen.fragment" {
  58849. /** @hidden */
  58850. export var sharpenPixelShader: {
  58851. name: string;
  58852. shader: string;
  58853. };
  58854. }
  58855. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  58856. import { Nullable } from "babylonjs/types";
  58857. import { Camera } from "babylonjs/Cameras/camera";
  58858. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58859. import "babylonjs/Shaders/sharpen.fragment";
  58860. import { Engine } from "babylonjs/Engines/engine";
  58861. /**
  58862. * The SharpenPostProcess applies a sharpen kernel to every pixel
  58863. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58864. */
  58865. export class SharpenPostProcess extends PostProcess {
  58866. /**
  58867. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  58868. */
  58869. colorAmount: number;
  58870. /**
  58871. * How much sharpness should be applied (default: 0.3)
  58872. */
  58873. edgeAmount: number;
  58874. /**
  58875. * Creates a new instance ConvolutionPostProcess
  58876. * @param name The name of the effect.
  58877. * @param options The required width/height ratio to downsize to before computing the render pass.
  58878. * @param camera The camera to apply the render pass to.
  58879. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58880. * @param engine The engine which the post process will be applied. (default: current engine)
  58881. * @param reusable If the post process can be reused on the same frame. (default: false)
  58882. * @param textureType Type of textures used when performing the post process. (default: 0)
  58883. * @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)
  58884. */
  58885. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58886. }
  58887. }
  58888. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  58889. import { Nullable } from "babylonjs/types";
  58890. import { Camera } from "babylonjs/Cameras/camera";
  58891. import { Engine } from "babylonjs/Engines/engine";
  58892. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  58893. import { IInspectable } from "babylonjs/Misc/iInspectable";
  58894. /**
  58895. * PostProcessRenderPipeline
  58896. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58897. */
  58898. export class PostProcessRenderPipeline {
  58899. private engine;
  58900. private _renderEffects;
  58901. private _renderEffectsForIsolatedPass;
  58902. /**
  58903. * List of inspectable custom properties (used by the Inspector)
  58904. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  58905. */
  58906. inspectableCustomProperties: IInspectable[];
  58907. /**
  58908. * @hidden
  58909. */
  58910. protected _cameras: Camera[];
  58911. /** @hidden */
  58912. _name: string;
  58913. /**
  58914. * Gets pipeline name
  58915. */
  58916. readonly name: string;
  58917. /**
  58918. * Initializes a PostProcessRenderPipeline
  58919. * @param engine engine to add the pipeline to
  58920. * @param name name of the pipeline
  58921. */
  58922. constructor(engine: Engine, name: string);
  58923. /**
  58924. * Gets the class name
  58925. * @returns "PostProcessRenderPipeline"
  58926. */
  58927. getClassName(): string;
  58928. /**
  58929. * If all the render effects in the pipeline are supported
  58930. */
  58931. readonly isSupported: boolean;
  58932. /**
  58933. * Adds an effect to the pipeline
  58934. * @param renderEffect the effect to add
  58935. */
  58936. addEffect(renderEffect: PostProcessRenderEffect): void;
  58937. /** @hidden */
  58938. _rebuild(): void;
  58939. /** @hidden */
  58940. _enableEffect(renderEffectName: string, cameras: Camera): void;
  58941. /** @hidden */
  58942. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  58943. /** @hidden */
  58944. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58945. /** @hidden */
  58946. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58947. /** @hidden */
  58948. _attachCameras(cameras: Camera, unique: boolean): void;
  58949. /** @hidden */
  58950. _attachCameras(cameras: Camera[], unique: boolean): void;
  58951. /** @hidden */
  58952. _detachCameras(cameras: Camera): void;
  58953. /** @hidden */
  58954. _detachCameras(cameras: Nullable<Camera[]>): void;
  58955. /** @hidden */
  58956. _update(): void;
  58957. /** @hidden */
  58958. _reset(): void;
  58959. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  58960. /**
  58961. * Disposes of the pipeline
  58962. */
  58963. dispose(): void;
  58964. }
  58965. }
  58966. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  58967. import { Camera } from "babylonjs/Cameras/camera";
  58968. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58969. /**
  58970. * PostProcessRenderPipelineManager class
  58971. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58972. */
  58973. export class PostProcessRenderPipelineManager {
  58974. private _renderPipelines;
  58975. /**
  58976. * Initializes a PostProcessRenderPipelineManager
  58977. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58978. */
  58979. constructor();
  58980. /**
  58981. * Gets the list of supported render pipelines
  58982. */
  58983. readonly supportedPipelines: PostProcessRenderPipeline[];
  58984. /**
  58985. * Adds a pipeline to the manager
  58986. * @param renderPipeline The pipeline to add
  58987. */
  58988. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  58989. /**
  58990. * Attaches a camera to the pipeline
  58991. * @param renderPipelineName The name of the pipeline to attach to
  58992. * @param cameras the camera to attach
  58993. * @param unique if the camera can be attached multiple times to the pipeline
  58994. */
  58995. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  58996. /**
  58997. * Detaches a camera from the pipeline
  58998. * @param renderPipelineName The name of the pipeline to detach from
  58999. * @param cameras the camera to detach
  59000. */
  59001. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  59002. /**
  59003. * Enables an effect by name on a pipeline
  59004. * @param renderPipelineName the name of the pipeline to enable the effect in
  59005. * @param renderEffectName the name of the effect to enable
  59006. * @param cameras the cameras that the effect should be enabled on
  59007. */
  59008. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59009. /**
  59010. * Disables an effect by name on a pipeline
  59011. * @param renderPipelineName the name of the pipeline to disable the effect in
  59012. * @param renderEffectName the name of the effect to disable
  59013. * @param cameras the cameras that the effect should be disabled on
  59014. */
  59015. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59016. /**
  59017. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  59018. */
  59019. update(): void;
  59020. /** @hidden */
  59021. _rebuild(): void;
  59022. /**
  59023. * Disposes of the manager and pipelines
  59024. */
  59025. dispose(): void;
  59026. }
  59027. }
  59028. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  59029. import { ISceneComponent } from "babylonjs/sceneComponent";
  59030. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  59031. import { Scene } from "babylonjs/scene";
  59032. module "babylonjs/scene" {
  59033. interface Scene {
  59034. /** @hidden (Backing field) */
  59035. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59036. /**
  59037. * Gets the postprocess render pipeline manager
  59038. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59039. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59040. */
  59041. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59042. }
  59043. }
  59044. /**
  59045. * Defines the Render Pipeline scene component responsible to rendering pipelines
  59046. */
  59047. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  59048. /**
  59049. * The component name helpfull to identify the component in the list of scene components.
  59050. */
  59051. readonly name: string;
  59052. /**
  59053. * The scene the component belongs to.
  59054. */
  59055. scene: Scene;
  59056. /**
  59057. * Creates a new instance of the component for the given scene
  59058. * @param scene Defines the scene to register the component in
  59059. */
  59060. constructor(scene: Scene);
  59061. /**
  59062. * Registers the component in a given scene
  59063. */
  59064. register(): void;
  59065. /**
  59066. * Rebuilds the elements related to this component in case of
  59067. * context lost for instance.
  59068. */
  59069. rebuild(): void;
  59070. /**
  59071. * Disposes the component and the associated ressources
  59072. */
  59073. dispose(): void;
  59074. private _gatherRenderTargets;
  59075. }
  59076. }
  59077. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  59078. import { Nullable } from "babylonjs/types";
  59079. import { IAnimatable } from "babylonjs/Misc/tools";
  59080. import { Camera } from "babylonjs/Cameras/camera";
  59081. import { IDisposable } from "babylonjs/scene";
  59082. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  59083. import { Scene } from "babylonjs/scene";
  59084. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  59085. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  59086. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  59087. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  59088. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  59089. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59090. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  59091. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  59092. import { Animation } from "babylonjs/Animations/animation";
  59093. /**
  59094. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  59095. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59096. */
  59097. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59098. private _scene;
  59099. private _camerasToBeAttached;
  59100. /**
  59101. * ID of the sharpen post process,
  59102. */
  59103. private readonly SharpenPostProcessId;
  59104. /**
  59105. * @ignore
  59106. * ID of the image processing post process;
  59107. */
  59108. readonly ImageProcessingPostProcessId: string;
  59109. /**
  59110. * @ignore
  59111. * ID of the Fast Approximate Anti-Aliasing post process;
  59112. */
  59113. readonly FxaaPostProcessId: string;
  59114. /**
  59115. * ID of the chromatic aberration post process,
  59116. */
  59117. private readonly ChromaticAberrationPostProcessId;
  59118. /**
  59119. * ID of the grain post process
  59120. */
  59121. private readonly GrainPostProcessId;
  59122. /**
  59123. * Sharpen post process which will apply a sharpen convolution to enhance edges
  59124. */
  59125. sharpen: SharpenPostProcess;
  59126. private _sharpenEffect;
  59127. private bloom;
  59128. /**
  59129. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  59130. */
  59131. depthOfField: DepthOfFieldEffect;
  59132. /**
  59133. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59134. */
  59135. fxaa: FxaaPostProcess;
  59136. /**
  59137. * Image post processing pass used to perform operations such as tone mapping or color grading.
  59138. */
  59139. imageProcessing: ImageProcessingPostProcess;
  59140. /**
  59141. * Chromatic aberration post process which will shift rgb colors in the image
  59142. */
  59143. chromaticAberration: ChromaticAberrationPostProcess;
  59144. private _chromaticAberrationEffect;
  59145. /**
  59146. * Grain post process which add noise to the image
  59147. */
  59148. grain: GrainPostProcess;
  59149. private _grainEffect;
  59150. /**
  59151. * Glow post process which adds a glow to emissive areas of the image
  59152. */
  59153. private _glowLayer;
  59154. /**
  59155. * Animations which can be used to tweak settings over a period of time
  59156. */
  59157. animations: Animation[];
  59158. private _imageProcessingConfigurationObserver;
  59159. private _sharpenEnabled;
  59160. private _bloomEnabled;
  59161. private _depthOfFieldEnabled;
  59162. private _depthOfFieldBlurLevel;
  59163. private _fxaaEnabled;
  59164. private _imageProcessingEnabled;
  59165. private _defaultPipelineTextureType;
  59166. private _bloomScale;
  59167. private _chromaticAberrationEnabled;
  59168. private _grainEnabled;
  59169. private _buildAllowed;
  59170. /**
  59171. * Gets active scene
  59172. */
  59173. readonly scene: Scene;
  59174. /**
  59175. * Enable or disable the sharpen process from the pipeline
  59176. */
  59177. sharpenEnabled: boolean;
  59178. private _resizeObserver;
  59179. private _hardwareScaleLevel;
  59180. private _bloomKernel;
  59181. /**
  59182. * Specifies the size of the bloom blur kernel, relative to the final output size
  59183. */
  59184. bloomKernel: number;
  59185. /**
  59186. * Specifies the weight of the bloom in the final rendering
  59187. */
  59188. private _bloomWeight;
  59189. /**
  59190. * Specifies the luma threshold for the area that will be blurred by the bloom
  59191. */
  59192. private _bloomThreshold;
  59193. private _hdr;
  59194. /**
  59195. * The strength of the bloom.
  59196. */
  59197. bloomWeight: number;
  59198. /**
  59199. * The strength of the bloom.
  59200. */
  59201. bloomThreshold: number;
  59202. /**
  59203. * The scale of the bloom, lower value will provide better performance.
  59204. */
  59205. bloomScale: number;
  59206. /**
  59207. * Enable or disable the bloom from the pipeline
  59208. */
  59209. bloomEnabled: boolean;
  59210. private _rebuildBloom;
  59211. /**
  59212. * If the depth of field is enabled.
  59213. */
  59214. depthOfFieldEnabled: boolean;
  59215. /**
  59216. * Blur level of the depth of field effect. (Higher blur will effect performance)
  59217. */
  59218. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  59219. /**
  59220. * If the anti aliasing is enabled.
  59221. */
  59222. fxaaEnabled: boolean;
  59223. private _samples;
  59224. /**
  59225. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59226. */
  59227. samples: number;
  59228. /**
  59229. * If image processing is enabled.
  59230. */
  59231. imageProcessingEnabled: boolean;
  59232. /**
  59233. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  59234. */
  59235. glowLayerEnabled: boolean;
  59236. /**
  59237. * Gets the glow layer (or null if not defined)
  59238. */
  59239. readonly glowLayer: Nullable<GlowLayer>;
  59240. /**
  59241. * Enable or disable the chromaticAberration process from the pipeline
  59242. */
  59243. chromaticAberrationEnabled: boolean;
  59244. /**
  59245. * Enable or disable the grain process from the pipeline
  59246. */
  59247. grainEnabled: boolean;
  59248. /**
  59249. * @constructor
  59250. * @param name - The rendering pipeline name (default: "")
  59251. * @param hdr - If high dynamic range textures should be used (default: true)
  59252. * @param scene - The scene linked to this pipeline (default: the last created scene)
  59253. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  59254. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  59255. */
  59256. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  59257. /**
  59258. * Get the class name
  59259. * @returns "DefaultRenderingPipeline"
  59260. */
  59261. getClassName(): string;
  59262. /**
  59263. * Force the compilation of the entire pipeline.
  59264. */
  59265. prepare(): void;
  59266. private _hasCleared;
  59267. private _prevPostProcess;
  59268. private _prevPrevPostProcess;
  59269. private _setAutoClearAndTextureSharing;
  59270. private _depthOfFieldSceneObserver;
  59271. private _buildPipeline;
  59272. private _disposePostProcesses;
  59273. /**
  59274. * Adds a camera to the pipeline
  59275. * @param camera the camera to be added
  59276. */
  59277. addCamera(camera: Camera): void;
  59278. /**
  59279. * Removes a camera from the pipeline
  59280. * @param camera the camera to remove
  59281. */
  59282. removeCamera(camera: Camera): void;
  59283. /**
  59284. * Dispose of the pipeline and stop all post processes
  59285. */
  59286. dispose(): void;
  59287. /**
  59288. * Serialize the rendering pipeline (Used when exporting)
  59289. * @returns the serialized object
  59290. */
  59291. serialize(): any;
  59292. /**
  59293. * Parse the serialized pipeline
  59294. * @param source Source pipeline.
  59295. * @param scene The scene to load the pipeline to.
  59296. * @param rootUrl The URL of the serialized pipeline.
  59297. * @returns An instantiated pipeline from the serialized object.
  59298. */
  59299. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  59300. }
  59301. }
  59302. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  59303. /** @hidden */
  59304. export var lensHighlightsPixelShader: {
  59305. name: string;
  59306. shader: string;
  59307. };
  59308. }
  59309. declare module "babylonjs/Shaders/depthOfField.fragment" {
  59310. /** @hidden */
  59311. export var depthOfFieldPixelShader: {
  59312. name: string;
  59313. shader: string;
  59314. };
  59315. }
  59316. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  59317. import { Camera } from "babylonjs/Cameras/camera";
  59318. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59319. import { Scene } from "babylonjs/scene";
  59320. import "babylonjs/Shaders/chromaticAberration.fragment";
  59321. import "babylonjs/Shaders/lensHighlights.fragment";
  59322. import "babylonjs/Shaders/depthOfField.fragment";
  59323. /**
  59324. * BABYLON.JS Chromatic Aberration GLSL Shader
  59325. * Author: Olivier Guyot
  59326. * Separates very slightly R, G and B colors on the edges of the screen
  59327. * Inspired by Francois Tarlier & Martins Upitis
  59328. */
  59329. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  59330. /**
  59331. * @ignore
  59332. * The chromatic aberration PostProcess id in the pipeline
  59333. */
  59334. LensChromaticAberrationEffect: string;
  59335. /**
  59336. * @ignore
  59337. * The highlights enhancing PostProcess id in the pipeline
  59338. */
  59339. HighlightsEnhancingEffect: string;
  59340. /**
  59341. * @ignore
  59342. * The depth-of-field PostProcess id in the pipeline
  59343. */
  59344. LensDepthOfFieldEffect: string;
  59345. private _scene;
  59346. private _depthTexture;
  59347. private _grainTexture;
  59348. private _chromaticAberrationPostProcess;
  59349. private _highlightsPostProcess;
  59350. private _depthOfFieldPostProcess;
  59351. private _edgeBlur;
  59352. private _grainAmount;
  59353. private _chromaticAberration;
  59354. private _distortion;
  59355. private _highlightsGain;
  59356. private _highlightsThreshold;
  59357. private _dofDistance;
  59358. private _dofAperture;
  59359. private _dofDarken;
  59360. private _dofPentagon;
  59361. private _blurNoise;
  59362. /**
  59363. * @constructor
  59364. *
  59365. * Effect parameters are as follow:
  59366. * {
  59367. * chromatic_aberration: number; // from 0 to x (1 for realism)
  59368. * edge_blur: number; // from 0 to x (1 for realism)
  59369. * distortion: number; // from 0 to x (1 for realism)
  59370. * grain_amount: number; // from 0 to 1
  59371. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  59372. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  59373. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  59374. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  59375. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  59376. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  59377. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  59378. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  59379. * }
  59380. * Note: if an effect parameter is unset, effect is disabled
  59381. *
  59382. * @param name The rendering pipeline name
  59383. * @param parameters - An object containing all parameters (see above)
  59384. * @param scene The scene linked to this pipeline
  59385. * @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)
  59386. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59387. */
  59388. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  59389. /**
  59390. * Get the class name
  59391. * @returns "LensRenderingPipeline"
  59392. */
  59393. getClassName(): string;
  59394. /**
  59395. * Gets associated scene
  59396. */
  59397. readonly scene: Scene;
  59398. /**
  59399. * Gets or sets the edge blur
  59400. */
  59401. edgeBlur: number;
  59402. /**
  59403. * Gets or sets the grain amount
  59404. */
  59405. grainAmount: number;
  59406. /**
  59407. * Gets or sets the chromatic aberration amount
  59408. */
  59409. chromaticAberration: number;
  59410. /**
  59411. * Gets or sets the depth of field aperture
  59412. */
  59413. dofAperture: number;
  59414. /**
  59415. * Gets or sets the edge distortion
  59416. */
  59417. edgeDistortion: number;
  59418. /**
  59419. * Gets or sets the depth of field distortion
  59420. */
  59421. dofDistortion: number;
  59422. /**
  59423. * Gets or sets the darken out of focus amount
  59424. */
  59425. darkenOutOfFocus: number;
  59426. /**
  59427. * Gets or sets a boolean indicating if blur noise is enabled
  59428. */
  59429. blurNoise: boolean;
  59430. /**
  59431. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  59432. */
  59433. pentagonBokeh: boolean;
  59434. /**
  59435. * Gets or sets the highlight grain amount
  59436. */
  59437. highlightsGain: number;
  59438. /**
  59439. * Gets or sets the highlight threshold
  59440. */
  59441. highlightsThreshold: number;
  59442. /**
  59443. * Sets the amount of blur at the edges
  59444. * @param amount blur amount
  59445. */
  59446. setEdgeBlur(amount: number): void;
  59447. /**
  59448. * Sets edge blur to 0
  59449. */
  59450. disableEdgeBlur(): void;
  59451. /**
  59452. * Sets the amout of grain
  59453. * @param amount Amount of grain
  59454. */
  59455. setGrainAmount(amount: number): void;
  59456. /**
  59457. * Set grain amount to 0
  59458. */
  59459. disableGrain(): void;
  59460. /**
  59461. * Sets the chromatic aberration amount
  59462. * @param amount amount of chromatic aberration
  59463. */
  59464. setChromaticAberration(amount: number): void;
  59465. /**
  59466. * Sets chromatic aberration amount to 0
  59467. */
  59468. disableChromaticAberration(): void;
  59469. /**
  59470. * Sets the EdgeDistortion amount
  59471. * @param amount amount of EdgeDistortion
  59472. */
  59473. setEdgeDistortion(amount: number): void;
  59474. /**
  59475. * Sets edge distortion to 0
  59476. */
  59477. disableEdgeDistortion(): void;
  59478. /**
  59479. * Sets the FocusDistance amount
  59480. * @param amount amount of FocusDistance
  59481. */
  59482. setFocusDistance(amount: number): void;
  59483. /**
  59484. * Disables depth of field
  59485. */
  59486. disableDepthOfField(): void;
  59487. /**
  59488. * Sets the Aperture amount
  59489. * @param amount amount of Aperture
  59490. */
  59491. setAperture(amount: number): void;
  59492. /**
  59493. * Sets the DarkenOutOfFocus amount
  59494. * @param amount amount of DarkenOutOfFocus
  59495. */
  59496. setDarkenOutOfFocus(amount: number): void;
  59497. private _pentagonBokehIsEnabled;
  59498. /**
  59499. * Creates a pentagon bokeh effect
  59500. */
  59501. enablePentagonBokeh(): void;
  59502. /**
  59503. * Disables the pentagon bokeh effect
  59504. */
  59505. disablePentagonBokeh(): void;
  59506. /**
  59507. * Enables noise blur
  59508. */
  59509. enableNoiseBlur(): void;
  59510. /**
  59511. * Disables noise blur
  59512. */
  59513. disableNoiseBlur(): void;
  59514. /**
  59515. * Sets the HighlightsGain amount
  59516. * @param amount amount of HighlightsGain
  59517. */
  59518. setHighlightsGain(amount: number): void;
  59519. /**
  59520. * Sets the HighlightsThreshold amount
  59521. * @param amount amount of HighlightsThreshold
  59522. */
  59523. setHighlightsThreshold(amount: number): void;
  59524. /**
  59525. * Disables highlights
  59526. */
  59527. disableHighlights(): void;
  59528. /**
  59529. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  59530. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  59531. */
  59532. dispose(disableDepthRender?: boolean): void;
  59533. private _createChromaticAberrationPostProcess;
  59534. private _createHighlightsPostProcess;
  59535. private _createDepthOfFieldPostProcess;
  59536. private _createGrainTexture;
  59537. }
  59538. }
  59539. declare module "babylonjs/Shaders/ssao2.fragment" {
  59540. /** @hidden */
  59541. export var ssao2PixelShader: {
  59542. name: string;
  59543. shader: string;
  59544. };
  59545. }
  59546. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  59547. /** @hidden */
  59548. export var ssaoCombinePixelShader: {
  59549. name: string;
  59550. shader: string;
  59551. };
  59552. }
  59553. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  59554. import { Camera } from "babylonjs/Cameras/camera";
  59555. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59556. import { Scene } from "babylonjs/scene";
  59557. import "babylonjs/Shaders/ssao2.fragment";
  59558. import "babylonjs/Shaders/ssaoCombine.fragment";
  59559. /**
  59560. * Render pipeline to produce ssao effect
  59561. */
  59562. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  59563. /**
  59564. * @ignore
  59565. * The PassPostProcess id in the pipeline that contains the original scene color
  59566. */
  59567. SSAOOriginalSceneColorEffect: string;
  59568. /**
  59569. * @ignore
  59570. * The SSAO PostProcess id in the pipeline
  59571. */
  59572. SSAORenderEffect: string;
  59573. /**
  59574. * @ignore
  59575. * The horizontal blur PostProcess id in the pipeline
  59576. */
  59577. SSAOBlurHRenderEffect: string;
  59578. /**
  59579. * @ignore
  59580. * The vertical blur PostProcess id in the pipeline
  59581. */
  59582. SSAOBlurVRenderEffect: string;
  59583. /**
  59584. * @ignore
  59585. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59586. */
  59587. SSAOCombineRenderEffect: string;
  59588. /**
  59589. * The output strength of the SSAO post-process. Default value is 1.0.
  59590. */
  59591. totalStrength: number;
  59592. /**
  59593. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  59594. */
  59595. maxZ: number;
  59596. /**
  59597. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  59598. */
  59599. minZAspect: number;
  59600. private _samples;
  59601. /**
  59602. * Number of samples used for the SSAO calculations. Default value is 8
  59603. */
  59604. samples: number;
  59605. private _textureSamples;
  59606. /**
  59607. * Number of samples to use for antialiasing
  59608. */
  59609. textureSamples: number;
  59610. /**
  59611. * Ratio object used for SSAO ratio and blur ratio
  59612. */
  59613. private _ratio;
  59614. /**
  59615. * Dynamically generated sphere sampler.
  59616. */
  59617. private _sampleSphere;
  59618. /**
  59619. * Blur filter offsets
  59620. */
  59621. private _samplerOffsets;
  59622. private _expensiveBlur;
  59623. /**
  59624. * If bilateral blur should be used
  59625. */
  59626. expensiveBlur: boolean;
  59627. /**
  59628. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  59629. */
  59630. radius: number;
  59631. /**
  59632. * The base color of the SSAO post-process
  59633. * The final result is "base + ssao" between [0, 1]
  59634. */
  59635. base: number;
  59636. /**
  59637. * Support test.
  59638. */
  59639. static readonly IsSupported: boolean;
  59640. private _scene;
  59641. private _depthTexture;
  59642. private _normalTexture;
  59643. private _randomTexture;
  59644. private _originalColorPostProcess;
  59645. private _ssaoPostProcess;
  59646. private _blurHPostProcess;
  59647. private _blurVPostProcess;
  59648. private _ssaoCombinePostProcess;
  59649. private _firstUpdate;
  59650. /**
  59651. * Gets active scene
  59652. */
  59653. readonly scene: Scene;
  59654. /**
  59655. * @constructor
  59656. * @param name The rendering pipeline name
  59657. * @param scene The scene linked to this pipeline
  59658. * @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 }
  59659. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59660. */
  59661. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59662. /**
  59663. * Get the class name
  59664. * @returns "SSAO2RenderingPipeline"
  59665. */
  59666. getClassName(): string;
  59667. /**
  59668. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59669. */
  59670. dispose(disableGeometryBufferRenderer?: boolean): void;
  59671. private _createBlurPostProcess;
  59672. /** @hidden */
  59673. _rebuild(): void;
  59674. private _bits;
  59675. private _radicalInverse_VdC;
  59676. private _hammersley;
  59677. private _hemisphereSample_uniform;
  59678. private _generateHemisphere;
  59679. private _createSSAOPostProcess;
  59680. private _createSSAOCombinePostProcess;
  59681. private _createRandomTexture;
  59682. /**
  59683. * Serialize the rendering pipeline (Used when exporting)
  59684. * @returns the serialized object
  59685. */
  59686. serialize(): any;
  59687. /**
  59688. * Parse the serialized pipeline
  59689. * @param source Source pipeline.
  59690. * @param scene The scene to load the pipeline to.
  59691. * @param rootUrl The URL of the serialized pipeline.
  59692. * @returns An instantiated pipeline from the serialized object.
  59693. */
  59694. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  59695. }
  59696. }
  59697. declare module "babylonjs/Shaders/ssao.fragment" {
  59698. /** @hidden */
  59699. export var ssaoPixelShader: {
  59700. name: string;
  59701. shader: string;
  59702. };
  59703. }
  59704. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  59705. import { Camera } from "babylonjs/Cameras/camera";
  59706. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59707. import { Scene } from "babylonjs/scene";
  59708. import "babylonjs/Shaders/ssao.fragment";
  59709. import "babylonjs/Shaders/ssaoCombine.fragment";
  59710. /**
  59711. * Render pipeline to produce ssao effect
  59712. */
  59713. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  59714. /**
  59715. * @ignore
  59716. * The PassPostProcess id in the pipeline that contains the original scene color
  59717. */
  59718. SSAOOriginalSceneColorEffect: string;
  59719. /**
  59720. * @ignore
  59721. * The SSAO PostProcess id in the pipeline
  59722. */
  59723. SSAORenderEffect: string;
  59724. /**
  59725. * @ignore
  59726. * The horizontal blur PostProcess id in the pipeline
  59727. */
  59728. SSAOBlurHRenderEffect: string;
  59729. /**
  59730. * @ignore
  59731. * The vertical blur PostProcess id in the pipeline
  59732. */
  59733. SSAOBlurVRenderEffect: string;
  59734. /**
  59735. * @ignore
  59736. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59737. */
  59738. SSAOCombineRenderEffect: string;
  59739. /**
  59740. * The output strength of the SSAO post-process. Default value is 1.0.
  59741. */
  59742. totalStrength: number;
  59743. /**
  59744. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  59745. */
  59746. radius: number;
  59747. /**
  59748. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  59749. * Must not be equal to fallOff and superior to fallOff.
  59750. * Default value is 0.0075
  59751. */
  59752. area: number;
  59753. /**
  59754. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  59755. * Must not be equal to area and inferior to area.
  59756. * Default value is 0.000001
  59757. */
  59758. fallOff: number;
  59759. /**
  59760. * The base color of the SSAO post-process
  59761. * The final result is "base + ssao" between [0, 1]
  59762. */
  59763. base: number;
  59764. private _scene;
  59765. private _depthTexture;
  59766. private _randomTexture;
  59767. private _originalColorPostProcess;
  59768. private _ssaoPostProcess;
  59769. private _blurHPostProcess;
  59770. private _blurVPostProcess;
  59771. private _ssaoCombinePostProcess;
  59772. private _firstUpdate;
  59773. /**
  59774. * Gets active scene
  59775. */
  59776. readonly scene: Scene;
  59777. /**
  59778. * @constructor
  59779. * @param name - The rendering pipeline name
  59780. * @param scene - The scene linked to this pipeline
  59781. * @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 }
  59782. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  59783. */
  59784. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59785. /**
  59786. * Get the class name
  59787. * @returns "SSAORenderingPipeline"
  59788. */
  59789. getClassName(): string;
  59790. /**
  59791. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59792. */
  59793. dispose(disableDepthRender?: boolean): void;
  59794. private _createBlurPostProcess;
  59795. /** @hidden */
  59796. _rebuild(): void;
  59797. private _createSSAOPostProcess;
  59798. private _createSSAOCombinePostProcess;
  59799. private _createRandomTexture;
  59800. }
  59801. }
  59802. declare module "babylonjs/Shaders/standard.fragment" {
  59803. /** @hidden */
  59804. export var standardPixelShader: {
  59805. name: string;
  59806. shader: string;
  59807. };
  59808. }
  59809. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  59810. import { Nullable } from "babylonjs/types";
  59811. import { IAnimatable } from "babylonjs/Misc/tools";
  59812. import { Camera } from "babylonjs/Cameras/camera";
  59813. import { Texture } from "babylonjs/Materials/Textures/texture";
  59814. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59815. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59816. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  59817. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  59818. import { IDisposable } from "babylonjs/scene";
  59819. import { SpotLight } from "babylonjs/Lights/spotLight";
  59820. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  59821. import { Scene } from "babylonjs/scene";
  59822. import { Animation } from "babylonjs/Animations/animation";
  59823. import "babylonjs/Shaders/standard.fragment";
  59824. /**
  59825. * Standard rendering pipeline
  59826. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59827. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  59828. */
  59829. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59830. /**
  59831. * Public members
  59832. */
  59833. /**
  59834. * Post-process which contains the original scene color before the pipeline applies all the effects
  59835. */
  59836. originalPostProcess: Nullable<PostProcess>;
  59837. /**
  59838. * Post-process used to down scale an image x4
  59839. */
  59840. downSampleX4PostProcess: Nullable<PostProcess>;
  59841. /**
  59842. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  59843. */
  59844. brightPassPostProcess: Nullable<PostProcess>;
  59845. /**
  59846. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  59847. */
  59848. blurHPostProcesses: PostProcess[];
  59849. /**
  59850. * Post-process array storing all the vertical blur post-processes used by the pipeline
  59851. */
  59852. blurVPostProcesses: PostProcess[];
  59853. /**
  59854. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  59855. */
  59856. textureAdderPostProcess: Nullable<PostProcess>;
  59857. /**
  59858. * Post-process used to create volumetric lighting effect
  59859. */
  59860. volumetricLightPostProcess: Nullable<PostProcess>;
  59861. /**
  59862. * Post-process used to smooth the previous volumetric light post-process on the X axis
  59863. */
  59864. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  59865. /**
  59866. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  59867. */
  59868. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  59869. /**
  59870. * Post-process used to merge the volumetric light effect and the real scene color
  59871. */
  59872. volumetricLightMergePostProces: Nullable<PostProcess>;
  59873. /**
  59874. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  59875. */
  59876. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  59877. /**
  59878. * Base post-process used to calculate the average luminance of the final image for HDR
  59879. */
  59880. luminancePostProcess: Nullable<PostProcess>;
  59881. /**
  59882. * Post-processes used to create down sample post-processes in order to get
  59883. * the average luminance of the final image for HDR
  59884. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  59885. */
  59886. luminanceDownSamplePostProcesses: PostProcess[];
  59887. /**
  59888. * Post-process used to create a HDR effect (light adaptation)
  59889. */
  59890. hdrPostProcess: Nullable<PostProcess>;
  59891. /**
  59892. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  59893. */
  59894. textureAdderFinalPostProcess: Nullable<PostProcess>;
  59895. /**
  59896. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  59897. */
  59898. lensFlareFinalPostProcess: Nullable<PostProcess>;
  59899. /**
  59900. * Post-process used to merge the final HDR post-process and the real scene color
  59901. */
  59902. hdrFinalPostProcess: Nullable<PostProcess>;
  59903. /**
  59904. * Post-process used to create a lens flare effect
  59905. */
  59906. lensFlarePostProcess: Nullable<PostProcess>;
  59907. /**
  59908. * Post-process that merges the result of the lens flare post-process and the real scene color
  59909. */
  59910. lensFlareComposePostProcess: Nullable<PostProcess>;
  59911. /**
  59912. * Post-process used to create a motion blur effect
  59913. */
  59914. motionBlurPostProcess: Nullable<PostProcess>;
  59915. /**
  59916. * Post-process used to create a depth of field effect
  59917. */
  59918. depthOfFieldPostProcess: Nullable<PostProcess>;
  59919. /**
  59920. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59921. */
  59922. fxaaPostProcess: Nullable<FxaaPostProcess>;
  59923. /**
  59924. * Represents the brightness threshold in order to configure the illuminated surfaces
  59925. */
  59926. brightThreshold: number;
  59927. /**
  59928. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  59929. */
  59930. blurWidth: number;
  59931. /**
  59932. * Sets if the blur for highlighted surfaces must be only horizontal
  59933. */
  59934. horizontalBlur: boolean;
  59935. /**
  59936. * Gets the overall exposure used by the pipeline
  59937. */
  59938. /**
  59939. * Sets the overall exposure used by the pipeline
  59940. */
  59941. exposure: number;
  59942. /**
  59943. * Texture used typically to simulate "dirty" on camera lens
  59944. */
  59945. lensTexture: Nullable<Texture>;
  59946. /**
  59947. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  59948. */
  59949. volumetricLightCoefficient: number;
  59950. /**
  59951. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  59952. */
  59953. volumetricLightPower: number;
  59954. /**
  59955. * Used the set the blur intensity to smooth the volumetric lights
  59956. */
  59957. volumetricLightBlurScale: number;
  59958. /**
  59959. * Light (spot or directional) used to generate the volumetric lights rays
  59960. * The source light must have a shadow generate so the pipeline can get its
  59961. * depth map
  59962. */
  59963. sourceLight: Nullable<SpotLight | DirectionalLight>;
  59964. /**
  59965. * For eye adaptation, represents the minimum luminance the eye can see
  59966. */
  59967. hdrMinimumLuminance: number;
  59968. /**
  59969. * For eye adaptation, represents the decrease luminance speed
  59970. */
  59971. hdrDecreaseRate: number;
  59972. /**
  59973. * For eye adaptation, represents the increase luminance speed
  59974. */
  59975. hdrIncreaseRate: number;
  59976. /**
  59977. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59978. */
  59979. /**
  59980. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59981. */
  59982. hdrAutoExposure: boolean;
  59983. /**
  59984. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  59985. */
  59986. lensColorTexture: Nullable<Texture>;
  59987. /**
  59988. * The overall strengh for the lens flare effect
  59989. */
  59990. lensFlareStrength: number;
  59991. /**
  59992. * Dispersion coefficient for lens flare ghosts
  59993. */
  59994. lensFlareGhostDispersal: number;
  59995. /**
  59996. * Main lens flare halo width
  59997. */
  59998. lensFlareHaloWidth: number;
  59999. /**
  60000. * Based on the lens distortion effect, defines how much the lens flare result
  60001. * is distorted
  60002. */
  60003. lensFlareDistortionStrength: number;
  60004. /**
  60005. * Lens star texture must be used to simulate rays on the flares and is available
  60006. * in the documentation
  60007. */
  60008. lensStarTexture: Nullable<Texture>;
  60009. /**
  60010. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  60011. * flare effect by taking account of the dirt texture
  60012. */
  60013. lensFlareDirtTexture: Nullable<Texture>;
  60014. /**
  60015. * Represents the focal length for the depth of field effect
  60016. */
  60017. depthOfFieldDistance: number;
  60018. /**
  60019. * Represents the blur intensity for the blurred part of the depth of field effect
  60020. */
  60021. depthOfFieldBlurWidth: number;
  60022. /**
  60023. * Gets how much the image is blurred by the movement while using the motion blur post-process
  60024. */
  60025. /**
  60026. * Sets how much the image is blurred by the movement while using the motion blur post-process
  60027. */
  60028. motionStrength: number;
  60029. /**
  60030. * Gets wether or not the motion blur post-process is object based or screen based.
  60031. */
  60032. /**
  60033. * Sets wether or not the motion blur post-process should be object based or screen based
  60034. */
  60035. objectBasedMotionBlur: boolean;
  60036. /**
  60037. * List of animations for the pipeline (IAnimatable implementation)
  60038. */
  60039. animations: Animation[];
  60040. /**
  60041. * Private members
  60042. */
  60043. private _scene;
  60044. private _currentDepthOfFieldSource;
  60045. private _basePostProcess;
  60046. private _fixedExposure;
  60047. private _currentExposure;
  60048. private _hdrAutoExposure;
  60049. private _hdrCurrentLuminance;
  60050. private _motionStrength;
  60051. private _isObjectBasedMotionBlur;
  60052. private _floatTextureType;
  60053. private _ratio;
  60054. private _bloomEnabled;
  60055. private _depthOfFieldEnabled;
  60056. private _vlsEnabled;
  60057. private _lensFlareEnabled;
  60058. private _hdrEnabled;
  60059. private _motionBlurEnabled;
  60060. private _fxaaEnabled;
  60061. private _motionBlurSamples;
  60062. private _volumetricLightStepsCount;
  60063. private _samples;
  60064. /**
  60065. * @ignore
  60066. * Specifies if the bloom pipeline is enabled
  60067. */
  60068. BloomEnabled: boolean;
  60069. /**
  60070. * @ignore
  60071. * Specifies if the depth of field pipeline is enabed
  60072. */
  60073. DepthOfFieldEnabled: boolean;
  60074. /**
  60075. * @ignore
  60076. * Specifies if the lens flare pipeline is enabed
  60077. */
  60078. LensFlareEnabled: boolean;
  60079. /**
  60080. * @ignore
  60081. * Specifies if the HDR pipeline is enabled
  60082. */
  60083. HDREnabled: boolean;
  60084. /**
  60085. * @ignore
  60086. * Specifies if the volumetric lights scattering effect is enabled
  60087. */
  60088. VLSEnabled: boolean;
  60089. /**
  60090. * @ignore
  60091. * Specifies if the motion blur effect is enabled
  60092. */
  60093. MotionBlurEnabled: boolean;
  60094. /**
  60095. * Specifies if anti-aliasing is enabled
  60096. */
  60097. fxaaEnabled: boolean;
  60098. /**
  60099. * Specifies the number of steps used to calculate the volumetric lights
  60100. * Typically in interval [50, 200]
  60101. */
  60102. volumetricLightStepsCount: number;
  60103. /**
  60104. * Specifies the number of samples used for the motion blur effect
  60105. * Typically in interval [16, 64]
  60106. */
  60107. motionBlurSamples: number;
  60108. /**
  60109. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60110. */
  60111. samples: number;
  60112. /**
  60113. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60114. * @constructor
  60115. * @param name The rendering pipeline name
  60116. * @param scene The scene linked to this pipeline
  60117. * @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)
  60118. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  60119. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60120. */
  60121. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  60122. private _buildPipeline;
  60123. private _createDownSampleX4PostProcess;
  60124. private _createBrightPassPostProcess;
  60125. private _createBlurPostProcesses;
  60126. private _createTextureAdderPostProcess;
  60127. private _createVolumetricLightPostProcess;
  60128. private _createLuminancePostProcesses;
  60129. private _createHdrPostProcess;
  60130. private _createLensFlarePostProcess;
  60131. private _createDepthOfFieldPostProcess;
  60132. private _createMotionBlurPostProcess;
  60133. private _getDepthTexture;
  60134. private _disposePostProcesses;
  60135. /**
  60136. * Dispose of the pipeline and stop all post processes
  60137. */
  60138. dispose(): void;
  60139. /**
  60140. * Serialize the rendering pipeline (Used when exporting)
  60141. * @returns the serialized object
  60142. */
  60143. serialize(): any;
  60144. /**
  60145. * Parse the serialized pipeline
  60146. * @param source Source pipeline.
  60147. * @param scene The scene to load the pipeline to.
  60148. * @param rootUrl The URL of the serialized pipeline.
  60149. * @returns An instantiated pipeline from the serialized object.
  60150. */
  60151. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  60152. /**
  60153. * Luminance steps
  60154. */
  60155. static LuminanceSteps: number;
  60156. }
  60157. }
  60158. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  60159. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  60160. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  60161. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  60162. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  60163. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  60164. }
  60165. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  60166. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  60167. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60168. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60169. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  60170. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  60171. }
  60172. declare module "babylonjs/Shaders/tonemap.fragment" {
  60173. /** @hidden */
  60174. export var tonemapPixelShader: {
  60175. name: string;
  60176. shader: string;
  60177. };
  60178. }
  60179. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  60180. import { Camera } from "babylonjs/Cameras/camera";
  60181. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60182. import "babylonjs/Shaders/tonemap.fragment";
  60183. import { Engine } from "babylonjs/Engines/engine";
  60184. /** Defines operator used for tonemapping */
  60185. export enum TonemappingOperator {
  60186. /** Hable */
  60187. Hable = 0,
  60188. /** Reinhard */
  60189. Reinhard = 1,
  60190. /** HejiDawson */
  60191. HejiDawson = 2,
  60192. /** Photographic */
  60193. Photographic = 3
  60194. }
  60195. /**
  60196. * Defines a post process to apply tone mapping
  60197. */
  60198. export class TonemapPostProcess extends PostProcess {
  60199. private _operator;
  60200. /** Defines the required exposure adjustement */
  60201. exposureAdjustment: number;
  60202. /**
  60203. * Creates a new TonemapPostProcess
  60204. * @param name defines the name of the postprocess
  60205. * @param _operator defines the operator to use
  60206. * @param exposureAdjustment defines the required exposure adjustement
  60207. * @param camera defines the camera to use (can be null)
  60208. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  60209. * @param engine defines the hosting engine (can be ignore if camera is set)
  60210. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60211. */
  60212. constructor(name: string, _operator: TonemappingOperator,
  60213. /** Defines the required exposure adjustement */
  60214. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  60215. }
  60216. }
  60217. declare module "babylonjs/Shaders/depth.vertex" {
  60218. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60219. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60220. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60221. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60222. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60223. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60224. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60225. /** @hidden */
  60226. export var depthVertexShader: {
  60227. name: string;
  60228. shader: string;
  60229. };
  60230. }
  60231. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  60232. /** @hidden */
  60233. export var volumetricLightScatteringPixelShader: {
  60234. name: string;
  60235. shader: string;
  60236. };
  60237. }
  60238. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  60239. /** @hidden */
  60240. export var volumetricLightScatteringPassPixelShader: {
  60241. name: string;
  60242. shader: string;
  60243. };
  60244. }
  60245. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  60246. import { Vector3 } from "babylonjs/Maths/math";
  60247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60248. import { Mesh } from "babylonjs/Meshes/mesh";
  60249. import { Camera } from "babylonjs/Cameras/camera";
  60250. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60251. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60252. import { Scene } from "babylonjs/scene";
  60253. import "babylonjs/Meshes/Builders/planeBuilder";
  60254. import "babylonjs/Shaders/depth.vertex";
  60255. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  60256. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  60257. import { Engine } from "babylonjs/Engines/engine";
  60258. /**
  60259. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  60260. */
  60261. export class VolumetricLightScatteringPostProcess extends PostProcess {
  60262. private _volumetricLightScatteringPass;
  60263. private _volumetricLightScatteringRTT;
  60264. private _viewPort;
  60265. private _screenCoordinates;
  60266. private _cachedDefines;
  60267. /**
  60268. * If not undefined, the mesh position is computed from the attached node position
  60269. */
  60270. attachedNode: {
  60271. position: Vector3;
  60272. };
  60273. /**
  60274. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  60275. */
  60276. customMeshPosition: Vector3;
  60277. /**
  60278. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  60279. */
  60280. useCustomMeshPosition: boolean;
  60281. /**
  60282. * If the post-process should inverse the light scattering direction
  60283. */
  60284. invert: boolean;
  60285. /**
  60286. * The internal mesh used by the post-process
  60287. */
  60288. mesh: Mesh;
  60289. /**
  60290. * @hidden
  60291. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  60292. */
  60293. useDiffuseColor: boolean;
  60294. /**
  60295. * Array containing the excluded meshes not rendered in the internal pass
  60296. */
  60297. excludedMeshes: AbstractMesh[];
  60298. /**
  60299. * Controls the overall intensity of the post-process
  60300. */
  60301. exposure: number;
  60302. /**
  60303. * Dissipates each sample's contribution in range [0, 1]
  60304. */
  60305. decay: number;
  60306. /**
  60307. * Controls the overall intensity of each sample
  60308. */
  60309. weight: number;
  60310. /**
  60311. * Controls the density of each sample
  60312. */
  60313. density: number;
  60314. /**
  60315. * @constructor
  60316. * @param name The post-process name
  60317. * @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)
  60318. * @param camera The camera that the post-process will be attached to
  60319. * @param mesh The mesh used to create the light scattering
  60320. * @param samples The post-process quality, default 100
  60321. * @param samplingModeThe post-process filtering mode
  60322. * @param engine The babylon engine
  60323. * @param reusable If the post-process is reusable
  60324. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  60325. */
  60326. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  60327. /**
  60328. * Returns the string "VolumetricLightScatteringPostProcess"
  60329. * @returns "VolumetricLightScatteringPostProcess"
  60330. */
  60331. getClassName(): string;
  60332. private _isReady;
  60333. /**
  60334. * Sets the new light position for light scattering effect
  60335. * @param position The new custom light position
  60336. */
  60337. setCustomMeshPosition(position: Vector3): void;
  60338. /**
  60339. * Returns the light position for light scattering effect
  60340. * @return Vector3 The custom light position
  60341. */
  60342. getCustomMeshPosition(): Vector3;
  60343. /**
  60344. * Disposes the internal assets and detaches the post-process from the camera
  60345. */
  60346. dispose(camera: Camera): void;
  60347. /**
  60348. * Returns the render target texture used by the post-process
  60349. * @return the render target texture used by the post-process
  60350. */
  60351. getPass(): RenderTargetTexture;
  60352. private _meshExcluded;
  60353. private _createPass;
  60354. private _updateMeshScreenCoordinates;
  60355. /**
  60356. * Creates a default mesh for the Volumeric Light Scattering post-process
  60357. * @param name The mesh name
  60358. * @param scene The scene where to create the mesh
  60359. * @return the default mesh
  60360. */
  60361. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  60362. }
  60363. }
  60364. declare module "babylonjs/PostProcesses/index" {
  60365. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  60366. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  60367. export * from "babylonjs/PostProcesses/bloomEffect";
  60368. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  60369. export * from "babylonjs/PostProcesses/blurPostProcess";
  60370. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  60371. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  60372. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  60373. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  60374. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  60375. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  60376. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  60377. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  60378. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  60379. export * from "babylonjs/PostProcesses/filterPostProcess";
  60380. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  60381. export * from "babylonjs/PostProcesses/grainPostProcess";
  60382. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  60383. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  60384. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  60385. export * from "babylonjs/PostProcesses/passPostProcess";
  60386. export * from "babylonjs/PostProcesses/postProcess";
  60387. export * from "babylonjs/PostProcesses/postProcessManager";
  60388. export * from "babylonjs/PostProcesses/refractionPostProcess";
  60389. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  60390. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  60391. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  60392. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  60393. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  60394. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  60395. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  60396. }
  60397. declare module "babylonjs/Probes/index" {
  60398. export * from "babylonjs/Probes/reflectionProbe";
  60399. }
  60400. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  60401. import { Scene } from "babylonjs/scene";
  60402. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60403. import { Color3 } from "babylonjs/Maths/math";
  60404. import { SmartArray } from "babylonjs/Misc/smartArray";
  60405. import { ISceneComponent } from "babylonjs/sceneComponent";
  60406. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  60407. import "babylonjs/Meshes/Builders/boxBuilder";
  60408. import "babylonjs/Shaders/color.fragment";
  60409. import "babylonjs/Shaders/color.vertex";
  60410. module "babylonjs/scene" {
  60411. interface Scene {
  60412. /** @hidden (Backing field) */
  60413. _boundingBoxRenderer: BoundingBoxRenderer;
  60414. /** @hidden (Backing field) */
  60415. _forceShowBoundingBoxes: boolean;
  60416. /**
  60417. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  60418. */
  60419. forceShowBoundingBoxes: boolean;
  60420. /**
  60421. * Gets the bounding box renderer associated with the scene
  60422. * @returns a BoundingBoxRenderer
  60423. */
  60424. getBoundingBoxRenderer(): BoundingBoxRenderer;
  60425. }
  60426. }
  60427. module "babylonjs/Meshes/abstractMesh" {
  60428. interface AbstractMesh {
  60429. /** @hidden (Backing field) */
  60430. _showBoundingBox: boolean;
  60431. /**
  60432. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  60433. */
  60434. showBoundingBox: boolean;
  60435. }
  60436. }
  60437. /**
  60438. * Component responsible of rendering the bounding box of the meshes in a scene.
  60439. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  60440. */
  60441. export class BoundingBoxRenderer implements ISceneComponent {
  60442. /**
  60443. * The component name helpfull to identify the component in the list of scene components.
  60444. */
  60445. readonly name: string;
  60446. /**
  60447. * The scene the component belongs to.
  60448. */
  60449. scene: Scene;
  60450. /**
  60451. * Color of the bounding box lines placed in front of an object
  60452. */
  60453. frontColor: Color3;
  60454. /**
  60455. * Color of the bounding box lines placed behind an object
  60456. */
  60457. backColor: Color3;
  60458. /**
  60459. * Defines if the renderer should show the back lines or not
  60460. */
  60461. showBackLines: boolean;
  60462. /**
  60463. * @hidden
  60464. */
  60465. renderList: SmartArray<BoundingBox>;
  60466. private _colorShader;
  60467. private _vertexBuffers;
  60468. private _indexBuffer;
  60469. private _fillIndexBuffer;
  60470. private _fillIndexData;
  60471. /**
  60472. * Instantiates a new bounding box renderer in a scene.
  60473. * @param scene the scene the renderer renders in
  60474. */
  60475. constructor(scene: Scene);
  60476. /**
  60477. * Registers the component in a given scene
  60478. */
  60479. register(): void;
  60480. private _evaluateSubMesh;
  60481. private _activeMesh;
  60482. private _prepareRessources;
  60483. private _createIndexBuffer;
  60484. /**
  60485. * Rebuilds the elements related to this component in case of
  60486. * context lost for instance.
  60487. */
  60488. rebuild(): void;
  60489. /**
  60490. * @hidden
  60491. */
  60492. reset(): void;
  60493. /**
  60494. * Render the bounding boxes of a specific rendering group
  60495. * @param renderingGroupId defines the rendering group to render
  60496. */
  60497. render(renderingGroupId: number): void;
  60498. /**
  60499. * In case of occlusion queries, we can render the occlusion bounding box through this method
  60500. * @param mesh Define the mesh to render the occlusion bounding box for
  60501. */
  60502. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  60503. /**
  60504. * Dispose and release the resources attached to this renderer.
  60505. */
  60506. dispose(): void;
  60507. }
  60508. }
  60509. declare module "babylonjs/Shaders/depth.fragment" {
  60510. /** @hidden */
  60511. export var depthPixelShader: {
  60512. name: string;
  60513. shader: string;
  60514. };
  60515. }
  60516. declare module "babylonjs/Rendering/depthRenderer" {
  60517. import { Nullable } from "babylonjs/types";
  60518. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60519. import { Scene } from "babylonjs/scene";
  60520. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60521. import { Camera } from "babylonjs/Cameras/camera";
  60522. import "babylonjs/Shaders/depth.fragment";
  60523. import "babylonjs/Shaders/depth.vertex";
  60524. /**
  60525. * This represents a depth renderer in Babylon.
  60526. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60527. */
  60528. export class DepthRenderer {
  60529. private _scene;
  60530. private _depthMap;
  60531. private _effect;
  60532. private _cachedDefines;
  60533. private _camera;
  60534. /**
  60535. * Specifiess that the depth renderer will only be used within
  60536. * the camera it is created for.
  60537. * This can help forcing its rendering during the camera processing.
  60538. */
  60539. useOnlyInActiveCamera: boolean;
  60540. /** @hidden */
  60541. static _SceneComponentInitialization: (scene: Scene) => void;
  60542. /**
  60543. * Instantiates a depth renderer
  60544. * @param scene The scene the renderer belongs to
  60545. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60546. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60547. */
  60548. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  60549. /**
  60550. * Creates the depth rendering effect and checks if the effect is ready.
  60551. * @param subMesh The submesh to be used to render the depth map of
  60552. * @param useInstances If multiple world instances should be used
  60553. * @returns if the depth renderer is ready to render the depth map
  60554. */
  60555. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60556. /**
  60557. * Gets the texture which the depth map will be written to.
  60558. * @returns The depth map texture
  60559. */
  60560. getDepthMap(): RenderTargetTexture;
  60561. /**
  60562. * Disposes of the depth renderer.
  60563. */
  60564. dispose(): void;
  60565. }
  60566. }
  60567. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  60568. import { Nullable } from "babylonjs/types";
  60569. import { Scene } from "babylonjs/scene";
  60570. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  60571. import { Camera } from "babylonjs/Cameras/camera";
  60572. import { ISceneComponent } from "babylonjs/sceneComponent";
  60573. module "babylonjs/scene" {
  60574. interface Scene {
  60575. /** @hidden (Backing field) */
  60576. _depthRenderer: {
  60577. [id: string]: DepthRenderer;
  60578. };
  60579. /**
  60580. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  60581. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  60582. * @returns the created depth renderer
  60583. */
  60584. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  60585. /**
  60586. * Disables a depth renderer for a given camera
  60587. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  60588. */
  60589. disableDepthRenderer(camera?: Nullable<Camera>): void;
  60590. }
  60591. }
  60592. /**
  60593. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  60594. * in several rendering techniques.
  60595. */
  60596. export class DepthRendererSceneComponent implements ISceneComponent {
  60597. /**
  60598. * The component name helpfull to identify the component in the list of scene components.
  60599. */
  60600. readonly name: string;
  60601. /**
  60602. * The scene the component belongs to.
  60603. */
  60604. scene: Scene;
  60605. /**
  60606. * Creates a new instance of the component for the given scene
  60607. * @param scene Defines the scene to register the component in
  60608. */
  60609. constructor(scene: Scene);
  60610. /**
  60611. * Registers the component in a given scene
  60612. */
  60613. register(): void;
  60614. /**
  60615. * Rebuilds the elements related to this component in case of
  60616. * context lost for instance.
  60617. */
  60618. rebuild(): void;
  60619. /**
  60620. * Disposes the component and the associated ressources
  60621. */
  60622. dispose(): void;
  60623. private _gatherRenderTargets;
  60624. private _gatherActiveCameraRenderTargets;
  60625. }
  60626. }
  60627. declare module "babylonjs/Shaders/outline.fragment" {
  60628. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  60629. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  60630. /** @hidden */
  60631. export var outlinePixelShader: {
  60632. name: string;
  60633. shader: string;
  60634. };
  60635. }
  60636. declare module "babylonjs/Shaders/outline.vertex" {
  60637. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60638. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60639. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60640. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60641. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  60642. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60643. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60644. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60645. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  60646. /** @hidden */
  60647. export var outlineVertexShader: {
  60648. name: string;
  60649. shader: string;
  60650. };
  60651. }
  60652. declare module "babylonjs/Rendering/outlineRenderer" {
  60653. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60654. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  60655. import { Scene } from "babylonjs/scene";
  60656. import { ISceneComponent } from "babylonjs/sceneComponent";
  60657. import "babylonjs/Shaders/outline.fragment";
  60658. import "babylonjs/Shaders/outline.vertex";
  60659. module "babylonjs/scene" {
  60660. interface Scene {
  60661. /** @hidden */
  60662. _outlineRenderer: OutlineRenderer;
  60663. /**
  60664. * Gets the outline renderer associated with the scene
  60665. * @returns a OutlineRenderer
  60666. */
  60667. getOutlineRenderer(): OutlineRenderer;
  60668. }
  60669. }
  60670. module "babylonjs/Meshes/abstractMesh" {
  60671. interface AbstractMesh {
  60672. /** @hidden (Backing field) */
  60673. _renderOutline: boolean;
  60674. /**
  60675. * Gets or sets a boolean indicating if the outline must be rendered as well
  60676. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  60677. */
  60678. renderOutline: boolean;
  60679. /** @hidden (Backing field) */
  60680. _renderOverlay: boolean;
  60681. /**
  60682. * Gets or sets a boolean indicating if the overlay must be rendered as well
  60683. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  60684. */
  60685. renderOverlay: boolean;
  60686. }
  60687. }
  60688. /**
  60689. * This class is responsible to draw bothe outline/overlay of meshes.
  60690. * It should not be used directly but through the available method on mesh.
  60691. */
  60692. export class OutlineRenderer implements ISceneComponent {
  60693. /**
  60694. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  60695. */
  60696. private static _StencilReference;
  60697. /**
  60698. * The name of the component. Each component must have a unique name.
  60699. */
  60700. name: string;
  60701. /**
  60702. * The scene the component belongs to.
  60703. */
  60704. scene: Scene;
  60705. /**
  60706. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  60707. */
  60708. zOffset: number;
  60709. private _engine;
  60710. private _effect;
  60711. private _cachedDefines;
  60712. private _savedDepthWrite;
  60713. /**
  60714. * Instantiates a new outline renderer. (There could be only one per scene).
  60715. * @param scene Defines the scene it belongs to
  60716. */
  60717. constructor(scene: Scene);
  60718. /**
  60719. * Register the component to one instance of a scene.
  60720. */
  60721. register(): void;
  60722. /**
  60723. * Rebuilds the elements related to this component in case of
  60724. * context lost for instance.
  60725. */
  60726. rebuild(): void;
  60727. /**
  60728. * Disposes the component and the associated ressources.
  60729. */
  60730. dispose(): void;
  60731. /**
  60732. * Renders the outline in the canvas.
  60733. * @param subMesh Defines the sumesh to render
  60734. * @param batch Defines the batch of meshes in case of instances
  60735. * @param useOverlay Defines if the rendering is for the overlay or the outline
  60736. */
  60737. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  60738. /**
  60739. * Returns whether or not the outline renderer is ready for a given submesh.
  60740. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  60741. * @param subMesh Defines the submesh to check readyness for
  60742. * @param useInstances Defines wheter wee are trying to render instances or not
  60743. * @returns true if ready otherwise false
  60744. */
  60745. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60746. private _beforeRenderingMesh;
  60747. private _afterRenderingMesh;
  60748. }
  60749. }
  60750. declare module "babylonjs/Rendering/index" {
  60751. export * from "babylonjs/Rendering/boundingBoxRenderer";
  60752. export * from "babylonjs/Rendering/depthRenderer";
  60753. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  60754. export * from "babylonjs/Rendering/edgesRenderer";
  60755. export * from "babylonjs/Rendering/geometryBufferRenderer";
  60756. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  60757. export * from "babylonjs/Rendering/outlineRenderer";
  60758. export * from "babylonjs/Rendering/renderingGroup";
  60759. export * from "babylonjs/Rendering/renderingManager";
  60760. export * from "babylonjs/Rendering/utilityLayerRenderer";
  60761. }
  60762. declare module "babylonjs/Sprites/index" {
  60763. export * from "babylonjs/Sprites/sprite";
  60764. export * from "babylonjs/Sprites/spriteManager";
  60765. export * from "babylonjs/Sprites/spriteSceneComponent";
  60766. }
  60767. declare module "babylonjs/Misc/assetsManager" {
  60768. import { Scene } from "babylonjs/scene";
  60769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60770. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60771. import { Skeleton } from "babylonjs/Bones/skeleton";
  60772. import { Observable } from "babylonjs/Misc/observable";
  60773. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60774. import { Texture } from "babylonjs/Materials/Textures/texture";
  60775. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  60776. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  60777. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  60778. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  60779. /**
  60780. * Defines the list of states available for a task inside a AssetsManager
  60781. */
  60782. export enum AssetTaskState {
  60783. /**
  60784. * Initialization
  60785. */
  60786. INIT = 0,
  60787. /**
  60788. * Running
  60789. */
  60790. RUNNING = 1,
  60791. /**
  60792. * Done
  60793. */
  60794. DONE = 2,
  60795. /**
  60796. * Error
  60797. */
  60798. ERROR = 3
  60799. }
  60800. /**
  60801. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  60802. */
  60803. export abstract class AbstractAssetTask {
  60804. /**
  60805. * Task name
  60806. */ name: string;
  60807. /**
  60808. * Callback called when the task is successful
  60809. */
  60810. onSuccess: (task: any) => void;
  60811. /**
  60812. * Callback called when the task is not successful
  60813. */
  60814. onError: (task: any, message?: string, exception?: any) => void;
  60815. /**
  60816. * Creates a new AssetsManager
  60817. * @param name defines the name of the task
  60818. */
  60819. constructor(
  60820. /**
  60821. * Task name
  60822. */ name: string);
  60823. private _isCompleted;
  60824. private _taskState;
  60825. private _errorObject;
  60826. /**
  60827. * Get if the task is completed
  60828. */
  60829. readonly isCompleted: boolean;
  60830. /**
  60831. * Gets the current state of the task
  60832. */
  60833. readonly taskState: AssetTaskState;
  60834. /**
  60835. * Gets the current error object (if task is in error)
  60836. */
  60837. readonly errorObject: {
  60838. message?: string;
  60839. exception?: any;
  60840. };
  60841. /**
  60842. * Internal only
  60843. * @hidden
  60844. */
  60845. _setErrorObject(message?: string, exception?: any): void;
  60846. /**
  60847. * Execute the current task
  60848. * @param scene defines the scene where you want your assets to be loaded
  60849. * @param onSuccess is a callback called when the task is successfully executed
  60850. * @param onError is a callback called if an error occurs
  60851. */
  60852. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60853. /**
  60854. * Execute the current task
  60855. * @param scene defines the scene where you want your assets to be loaded
  60856. * @param onSuccess is a callback called when the task is successfully executed
  60857. * @param onError is a callback called if an error occurs
  60858. */
  60859. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60860. /**
  60861. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  60862. * This can be used with failed tasks that have the reason for failure fixed.
  60863. */
  60864. reset(): void;
  60865. private onErrorCallback;
  60866. private onDoneCallback;
  60867. }
  60868. /**
  60869. * Define the interface used by progress events raised during assets loading
  60870. */
  60871. export interface IAssetsProgressEvent {
  60872. /**
  60873. * Defines the number of remaining tasks to process
  60874. */
  60875. remainingCount: number;
  60876. /**
  60877. * Defines the total number of tasks
  60878. */
  60879. totalCount: number;
  60880. /**
  60881. * Defines the task that was just processed
  60882. */
  60883. task: AbstractAssetTask;
  60884. }
  60885. /**
  60886. * Class used to share progress information about assets loading
  60887. */
  60888. export class AssetsProgressEvent implements IAssetsProgressEvent {
  60889. /**
  60890. * Defines the number of remaining tasks to process
  60891. */
  60892. remainingCount: number;
  60893. /**
  60894. * Defines the total number of tasks
  60895. */
  60896. totalCount: number;
  60897. /**
  60898. * Defines the task that was just processed
  60899. */
  60900. task: AbstractAssetTask;
  60901. /**
  60902. * Creates a AssetsProgressEvent
  60903. * @param remainingCount defines the number of remaining tasks to process
  60904. * @param totalCount defines the total number of tasks
  60905. * @param task defines the task that was just processed
  60906. */
  60907. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  60908. }
  60909. /**
  60910. * Define a task used by AssetsManager to load meshes
  60911. */
  60912. export class MeshAssetTask extends AbstractAssetTask {
  60913. /**
  60914. * Defines the name of the task
  60915. */
  60916. name: string;
  60917. /**
  60918. * Defines the list of mesh's names you want to load
  60919. */
  60920. meshesNames: any;
  60921. /**
  60922. * Defines the root url to use as a base to load your meshes and associated resources
  60923. */
  60924. rootUrl: string;
  60925. /**
  60926. * Defines the filename of the scene to load from
  60927. */
  60928. sceneFilename: string;
  60929. /**
  60930. * Gets the list of loaded meshes
  60931. */
  60932. loadedMeshes: Array<AbstractMesh>;
  60933. /**
  60934. * Gets the list of loaded particle systems
  60935. */
  60936. loadedParticleSystems: Array<IParticleSystem>;
  60937. /**
  60938. * Gets the list of loaded skeletons
  60939. */
  60940. loadedSkeletons: Array<Skeleton>;
  60941. /**
  60942. * Gets the list of loaded animation groups
  60943. */
  60944. loadedAnimationGroups: Array<AnimationGroup>;
  60945. /**
  60946. * Callback called when the task is successful
  60947. */
  60948. onSuccess: (task: MeshAssetTask) => void;
  60949. /**
  60950. * Callback called when the task is successful
  60951. */
  60952. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  60953. /**
  60954. * Creates a new MeshAssetTask
  60955. * @param name defines the name of the task
  60956. * @param meshesNames defines the list of mesh's names you want to load
  60957. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  60958. * @param sceneFilename defines the filename of the scene to load from
  60959. */
  60960. constructor(
  60961. /**
  60962. * Defines the name of the task
  60963. */
  60964. name: string,
  60965. /**
  60966. * Defines the list of mesh's names you want to load
  60967. */
  60968. meshesNames: any,
  60969. /**
  60970. * Defines the root url to use as a base to load your meshes and associated resources
  60971. */
  60972. rootUrl: string,
  60973. /**
  60974. * Defines the filename of the scene to load from
  60975. */
  60976. sceneFilename: string);
  60977. /**
  60978. * Execute the current task
  60979. * @param scene defines the scene where you want your assets to be loaded
  60980. * @param onSuccess is a callback called when the task is successfully executed
  60981. * @param onError is a callback called if an error occurs
  60982. */
  60983. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60984. }
  60985. /**
  60986. * Define a task used by AssetsManager to load text content
  60987. */
  60988. export class TextFileAssetTask extends AbstractAssetTask {
  60989. /**
  60990. * Defines the name of the task
  60991. */
  60992. name: string;
  60993. /**
  60994. * Defines the location of the file to load
  60995. */
  60996. url: string;
  60997. /**
  60998. * Gets the loaded text string
  60999. */
  61000. text: string;
  61001. /**
  61002. * Callback called when the task is successful
  61003. */
  61004. onSuccess: (task: TextFileAssetTask) => void;
  61005. /**
  61006. * Callback called when the task is successful
  61007. */
  61008. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  61009. /**
  61010. * Creates a new TextFileAssetTask object
  61011. * @param name defines the name of the task
  61012. * @param url defines the location of the file to load
  61013. */
  61014. constructor(
  61015. /**
  61016. * Defines the name of the task
  61017. */
  61018. name: string,
  61019. /**
  61020. * Defines the location of the file to load
  61021. */
  61022. url: string);
  61023. /**
  61024. * Execute the current task
  61025. * @param scene defines the scene where you want your assets to be loaded
  61026. * @param onSuccess is a callback called when the task is successfully executed
  61027. * @param onError is a callback called if an error occurs
  61028. */
  61029. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61030. }
  61031. /**
  61032. * Define a task used by AssetsManager to load binary data
  61033. */
  61034. export class BinaryFileAssetTask extends AbstractAssetTask {
  61035. /**
  61036. * Defines the name of the task
  61037. */
  61038. name: string;
  61039. /**
  61040. * Defines the location of the file to load
  61041. */
  61042. url: string;
  61043. /**
  61044. * Gets the lodaded data (as an array buffer)
  61045. */
  61046. data: ArrayBuffer;
  61047. /**
  61048. * Callback called when the task is successful
  61049. */
  61050. onSuccess: (task: BinaryFileAssetTask) => void;
  61051. /**
  61052. * Callback called when the task is successful
  61053. */
  61054. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  61055. /**
  61056. * Creates a new BinaryFileAssetTask object
  61057. * @param name defines the name of the new task
  61058. * @param url defines the location of the file to load
  61059. */
  61060. constructor(
  61061. /**
  61062. * Defines the name of the task
  61063. */
  61064. name: string,
  61065. /**
  61066. * Defines the location of the file to load
  61067. */
  61068. url: string);
  61069. /**
  61070. * Execute the current task
  61071. * @param scene defines the scene where you want your assets to be loaded
  61072. * @param onSuccess is a callback called when the task is successfully executed
  61073. * @param onError is a callback called if an error occurs
  61074. */
  61075. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61076. }
  61077. /**
  61078. * Define a task used by AssetsManager to load images
  61079. */
  61080. export class ImageAssetTask extends AbstractAssetTask {
  61081. /**
  61082. * Defines the name of the task
  61083. */
  61084. name: string;
  61085. /**
  61086. * Defines the location of the image to load
  61087. */
  61088. url: string;
  61089. /**
  61090. * Gets the loaded images
  61091. */
  61092. image: HTMLImageElement;
  61093. /**
  61094. * Callback called when the task is successful
  61095. */
  61096. onSuccess: (task: ImageAssetTask) => void;
  61097. /**
  61098. * Callback called when the task is successful
  61099. */
  61100. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  61101. /**
  61102. * Creates a new ImageAssetTask
  61103. * @param name defines the name of the task
  61104. * @param url defines the location of the image to load
  61105. */
  61106. constructor(
  61107. /**
  61108. * Defines the name of the task
  61109. */
  61110. name: string,
  61111. /**
  61112. * Defines the location of the image to load
  61113. */
  61114. url: string);
  61115. /**
  61116. * Execute the current task
  61117. * @param scene defines the scene where you want your assets to be loaded
  61118. * @param onSuccess is a callback called when the task is successfully executed
  61119. * @param onError is a callback called if an error occurs
  61120. */
  61121. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61122. }
  61123. /**
  61124. * Defines the interface used by texture loading tasks
  61125. */
  61126. export interface ITextureAssetTask<TEX extends BaseTexture> {
  61127. /**
  61128. * Gets the loaded texture
  61129. */
  61130. texture: TEX;
  61131. }
  61132. /**
  61133. * Define a task used by AssetsManager to load 2D textures
  61134. */
  61135. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  61136. /**
  61137. * Defines the name of the task
  61138. */
  61139. name: string;
  61140. /**
  61141. * Defines the location of the file to load
  61142. */
  61143. url: string;
  61144. /**
  61145. * Defines if mipmap should not be generated (default is false)
  61146. */
  61147. noMipmap?: boolean | undefined;
  61148. /**
  61149. * Defines if texture must be inverted on Y axis (default is false)
  61150. */
  61151. invertY?: boolean | undefined;
  61152. /**
  61153. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61154. */
  61155. samplingMode: number;
  61156. /**
  61157. * Gets the loaded texture
  61158. */
  61159. texture: Texture;
  61160. /**
  61161. * Callback called when the task is successful
  61162. */
  61163. onSuccess: (task: TextureAssetTask) => void;
  61164. /**
  61165. * Callback called when the task is successful
  61166. */
  61167. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  61168. /**
  61169. * Creates a new TextureAssetTask object
  61170. * @param name defines the name of the task
  61171. * @param url defines the location of the file to load
  61172. * @param noMipmap defines if mipmap should not be generated (default is false)
  61173. * @param invertY defines if texture must be inverted on Y axis (default is false)
  61174. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61175. */
  61176. constructor(
  61177. /**
  61178. * Defines the name of the task
  61179. */
  61180. name: string,
  61181. /**
  61182. * Defines the location of the file to load
  61183. */
  61184. url: string,
  61185. /**
  61186. * Defines if mipmap should not be generated (default is false)
  61187. */
  61188. noMipmap?: boolean | undefined,
  61189. /**
  61190. * Defines if texture must be inverted on Y axis (default is false)
  61191. */
  61192. invertY?: boolean | undefined,
  61193. /**
  61194. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61195. */
  61196. samplingMode?: number);
  61197. /**
  61198. * Execute the current task
  61199. * @param scene defines the scene where you want your assets to be loaded
  61200. * @param onSuccess is a callback called when the task is successfully executed
  61201. * @param onError is a callback called if an error occurs
  61202. */
  61203. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61204. }
  61205. /**
  61206. * Define a task used by AssetsManager to load cube textures
  61207. */
  61208. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  61209. /**
  61210. * Defines the name of the task
  61211. */
  61212. name: string;
  61213. /**
  61214. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61215. */
  61216. url: string;
  61217. /**
  61218. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61219. */
  61220. extensions?: string[] | undefined;
  61221. /**
  61222. * Defines if mipmaps should not be generated (default is false)
  61223. */
  61224. noMipmap?: boolean | undefined;
  61225. /**
  61226. * Defines the explicit list of files (undefined by default)
  61227. */
  61228. files?: string[] | undefined;
  61229. /**
  61230. * Gets the loaded texture
  61231. */
  61232. texture: CubeTexture;
  61233. /**
  61234. * Callback called when the task is successful
  61235. */
  61236. onSuccess: (task: CubeTextureAssetTask) => void;
  61237. /**
  61238. * Callback called when the task is successful
  61239. */
  61240. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  61241. /**
  61242. * Creates a new CubeTextureAssetTask
  61243. * @param name defines the name of the task
  61244. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61245. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61246. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61247. * @param files defines the explicit list of files (undefined by default)
  61248. */
  61249. constructor(
  61250. /**
  61251. * Defines the name of the task
  61252. */
  61253. name: string,
  61254. /**
  61255. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61256. */
  61257. url: string,
  61258. /**
  61259. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61260. */
  61261. extensions?: string[] | undefined,
  61262. /**
  61263. * Defines if mipmaps should not be generated (default is false)
  61264. */
  61265. noMipmap?: boolean | undefined,
  61266. /**
  61267. * Defines the explicit list of files (undefined by default)
  61268. */
  61269. files?: string[] | undefined);
  61270. /**
  61271. * Execute the current task
  61272. * @param scene defines the scene where you want your assets to be loaded
  61273. * @param onSuccess is a callback called when the task is successfully executed
  61274. * @param onError is a callback called if an error occurs
  61275. */
  61276. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61277. }
  61278. /**
  61279. * Define a task used by AssetsManager to load HDR cube textures
  61280. */
  61281. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  61282. /**
  61283. * Defines the name of the task
  61284. */
  61285. name: string;
  61286. /**
  61287. * Defines the location of the file to load
  61288. */
  61289. url: string;
  61290. /**
  61291. * Defines the desired size (the more it increases the longer the generation will be)
  61292. */
  61293. size: number;
  61294. /**
  61295. * Defines if mipmaps should not be generated (default is false)
  61296. */
  61297. noMipmap: boolean;
  61298. /**
  61299. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61300. */
  61301. generateHarmonics: boolean;
  61302. /**
  61303. * 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)
  61304. */
  61305. gammaSpace: boolean;
  61306. /**
  61307. * Internal Use Only
  61308. */
  61309. reserved: boolean;
  61310. /**
  61311. * Gets the loaded texture
  61312. */
  61313. texture: HDRCubeTexture;
  61314. /**
  61315. * Callback called when the task is successful
  61316. */
  61317. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  61318. /**
  61319. * Callback called when the task is successful
  61320. */
  61321. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  61322. /**
  61323. * Creates a new HDRCubeTextureAssetTask object
  61324. * @param name defines the name of the task
  61325. * @param url defines the location of the file to load
  61326. * @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.
  61327. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61328. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61329. * @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)
  61330. * @param reserved Internal use only
  61331. */
  61332. constructor(
  61333. /**
  61334. * Defines the name of the task
  61335. */
  61336. name: string,
  61337. /**
  61338. * Defines the location of the file to load
  61339. */
  61340. url: string,
  61341. /**
  61342. * Defines the desired size (the more it increases the longer the generation will be)
  61343. */
  61344. size: number,
  61345. /**
  61346. * Defines if mipmaps should not be generated (default is false)
  61347. */
  61348. noMipmap?: boolean,
  61349. /**
  61350. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61351. */
  61352. generateHarmonics?: boolean,
  61353. /**
  61354. * 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)
  61355. */
  61356. gammaSpace?: boolean,
  61357. /**
  61358. * Internal Use Only
  61359. */
  61360. reserved?: boolean);
  61361. /**
  61362. * Execute the current task
  61363. * @param scene defines the scene where you want your assets to be loaded
  61364. * @param onSuccess is a callback called when the task is successfully executed
  61365. * @param onError is a callback called if an error occurs
  61366. */
  61367. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61368. }
  61369. /**
  61370. * Define a task used by AssetsManager to load Equirectangular cube textures
  61371. */
  61372. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  61373. /**
  61374. * Defines the name of the task
  61375. */
  61376. name: string;
  61377. /**
  61378. * Defines the location of the file to load
  61379. */
  61380. url: string;
  61381. /**
  61382. * Defines the desired size (the more it increases the longer the generation will be)
  61383. */
  61384. size: number;
  61385. /**
  61386. * Defines if mipmaps should not be generated (default is false)
  61387. */
  61388. noMipmap: boolean;
  61389. /**
  61390. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61391. * but the standard material would require them in Gamma space) (default is true)
  61392. */
  61393. gammaSpace: boolean;
  61394. /**
  61395. * Gets the loaded texture
  61396. */
  61397. texture: EquiRectangularCubeTexture;
  61398. /**
  61399. * Callback called when the task is successful
  61400. */
  61401. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  61402. /**
  61403. * Callback called when the task is successful
  61404. */
  61405. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  61406. /**
  61407. * Creates a new EquiRectangularCubeTextureAssetTask object
  61408. * @param name defines the name of the task
  61409. * @param url defines the location of the file to load
  61410. * @param size defines the desired size (the more it increases the longer the generation will be)
  61411. * If the size is omitted this implies you are using a preprocessed cubemap.
  61412. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61413. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  61414. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  61415. * (default is true)
  61416. */
  61417. constructor(
  61418. /**
  61419. * Defines the name of the task
  61420. */
  61421. name: string,
  61422. /**
  61423. * Defines the location of the file to load
  61424. */
  61425. url: string,
  61426. /**
  61427. * Defines the desired size (the more it increases the longer the generation will be)
  61428. */
  61429. size: number,
  61430. /**
  61431. * Defines if mipmaps should not be generated (default is false)
  61432. */
  61433. noMipmap?: boolean,
  61434. /**
  61435. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61436. * but the standard material would require them in Gamma space) (default is true)
  61437. */
  61438. gammaSpace?: boolean);
  61439. /**
  61440. * Execute the current task
  61441. * @param scene defines the scene where you want your assets to be loaded
  61442. * @param onSuccess is a callback called when the task is successfully executed
  61443. * @param onError is a callback called if an error occurs
  61444. */
  61445. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61446. }
  61447. /**
  61448. * This class can be used to easily import assets into a scene
  61449. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  61450. */
  61451. export class AssetsManager {
  61452. private _scene;
  61453. private _isLoading;
  61454. protected _tasks: AbstractAssetTask[];
  61455. protected _waitingTasksCount: number;
  61456. protected _totalTasksCount: number;
  61457. /**
  61458. * Callback called when all tasks are processed
  61459. */
  61460. onFinish: (tasks: AbstractAssetTask[]) => void;
  61461. /**
  61462. * Callback called when a task is successful
  61463. */
  61464. onTaskSuccess: (task: AbstractAssetTask) => void;
  61465. /**
  61466. * Callback called when a task had an error
  61467. */
  61468. onTaskError: (task: AbstractAssetTask) => void;
  61469. /**
  61470. * Callback called when a task is done (whatever the result is)
  61471. */
  61472. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  61473. /**
  61474. * Observable called when all tasks are processed
  61475. */
  61476. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  61477. /**
  61478. * Observable called when a task had an error
  61479. */
  61480. onTaskErrorObservable: Observable<AbstractAssetTask>;
  61481. /**
  61482. * Observable called when all tasks were executed
  61483. */
  61484. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  61485. /**
  61486. * Observable called when a task is done (whatever the result is)
  61487. */
  61488. onProgressObservable: Observable<IAssetsProgressEvent>;
  61489. /**
  61490. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  61491. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  61492. */
  61493. useDefaultLoadingScreen: boolean;
  61494. /**
  61495. * Creates a new AssetsManager
  61496. * @param scene defines the scene to work on
  61497. */
  61498. constructor(scene: Scene);
  61499. /**
  61500. * Add a MeshAssetTask to the list of active tasks
  61501. * @param taskName defines the name of the new task
  61502. * @param meshesNames defines the name of meshes to load
  61503. * @param rootUrl defines the root url to use to locate files
  61504. * @param sceneFilename defines the filename of the scene file
  61505. * @returns a new MeshAssetTask object
  61506. */
  61507. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  61508. /**
  61509. * Add a TextFileAssetTask to the list of active tasks
  61510. * @param taskName defines the name of the new task
  61511. * @param url defines the url of the file to load
  61512. * @returns a new TextFileAssetTask object
  61513. */
  61514. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  61515. /**
  61516. * Add a BinaryFileAssetTask to the list of active tasks
  61517. * @param taskName defines the name of the new task
  61518. * @param url defines the url of the file to load
  61519. * @returns a new BinaryFileAssetTask object
  61520. */
  61521. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  61522. /**
  61523. * Add a ImageAssetTask to the list of active tasks
  61524. * @param taskName defines the name of the new task
  61525. * @param url defines the url of the file to load
  61526. * @returns a new ImageAssetTask object
  61527. */
  61528. addImageTask(taskName: string, url: string): ImageAssetTask;
  61529. /**
  61530. * Add a TextureAssetTask to the list of active tasks
  61531. * @param taskName defines the name of the new task
  61532. * @param url defines the url of the file to load
  61533. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61534. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  61535. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61536. * @returns a new TextureAssetTask object
  61537. */
  61538. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  61539. /**
  61540. * Add a CubeTextureAssetTask to the list of active tasks
  61541. * @param taskName defines the name of the new task
  61542. * @param url defines the url of the file to load
  61543. * @param extensions defines the extension to use to load the cube map (can be null)
  61544. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61545. * @param files defines the list of files to load (can be null)
  61546. * @returns a new CubeTextureAssetTask object
  61547. */
  61548. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  61549. /**
  61550. *
  61551. * Add a HDRCubeTextureAssetTask to the list of active tasks
  61552. * @param taskName defines the name of the new task
  61553. * @param url defines the url of the file to load
  61554. * @param size defines the size you want for the cubemap (can be null)
  61555. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61556. * @param generateHarmonics defines if you want to automatically generate (true by default)
  61557. * @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)
  61558. * @param reserved Internal use only
  61559. * @returns a new HDRCubeTextureAssetTask object
  61560. */
  61561. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  61562. /**
  61563. *
  61564. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  61565. * @param taskName defines the name of the new task
  61566. * @param url defines the url of the file to load
  61567. * @param size defines the size you want for the cubemap (can be null)
  61568. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61569. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61570. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61571. * @returns a new EquiRectangularCubeTextureAssetTask object
  61572. */
  61573. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  61574. /**
  61575. * Remove a task from the assets manager.
  61576. * @param task the task to remove
  61577. */
  61578. removeTask(task: AbstractAssetTask): void;
  61579. private _decreaseWaitingTasksCount;
  61580. private _runTask;
  61581. /**
  61582. * Reset the AssetsManager and remove all tasks
  61583. * @return the current instance of the AssetsManager
  61584. */
  61585. reset(): AssetsManager;
  61586. /**
  61587. * Start the loading process
  61588. * @return the current instance of the AssetsManager
  61589. */
  61590. load(): AssetsManager;
  61591. /**
  61592. * Start the loading process as an async operation
  61593. * @return a promise returning the list of failed tasks
  61594. */
  61595. loadAsync(): Promise<void>;
  61596. }
  61597. }
  61598. declare module "babylonjs/Misc/deferred" {
  61599. /**
  61600. * Wrapper class for promise with external resolve and reject.
  61601. */
  61602. export class Deferred<T> {
  61603. /**
  61604. * The promise associated with this deferred object.
  61605. */
  61606. readonly promise: Promise<T>;
  61607. private _resolve;
  61608. private _reject;
  61609. /**
  61610. * The resolve method of the promise associated with this deferred object.
  61611. */
  61612. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  61613. /**
  61614. * The reject method of the promise associated with this deferred object.
  61615. */
  61616. readonly reject: (reason?: any) => void;
  61617. /**
  61618. * Constructor for this deferred object.
  61619. */
  61620. constructor();
  61621. }
  61622. }
  61623. declare module "babylonjs/Misc/meshExploder" {
  61624. import { Mesh } from "babylonjs/Meshes/mesh";
  61625. /**
  61626. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  61627. */
  61628. export class MeshExploder {
  61629. private _centerMesh;
  61630. private _meshes;
  61631. private _meshesOrigins;
  61632. private _toCenterVectors;
  61633. private _scaledDirection;
  61634. private _newPosition;
  61635. private _centerPosition;
  61636. /**
  61637. * Explodes meshes from a center mesh.
  61638. * @param meshes The meshes to explode.
  61639. * @param centerMesh The mesh to be center of explosion.
  61640. */
  61641. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  61642. private _setCenterMesh;
  61643. /**
  61644. * Get class name
  61645. * @returns "MeshExploder"
  61646. */
  61647. getClassName(): string;
  61648. /**
  61649. * "Exploded meshes"
  61650. * @returns Array of meshes with the centerMesh at index 0.
  61651. */
  61652. getMeshes(): Array<Mesh>;
  61653. /**
  61654. * Explodes meshes giving a specific direction
  61655. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  61656. */
  61657. explode(direction?: number): void;
  61658. }
  61659. }
  61660. declare module "babylonjs/Misc/filesInput" {
  61661. import { Engine } from "babylonjs/Engines/engine";
  61662. import { Scene } from "babylonjs/scene";
  61663. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  61664. /**
  61665. * Class used to help managing file picking and drag'n'drop
  61666. */
  61667. export class FilesInput {
  61668. /**
  61669. * List of files ready to be loaded
  61670. */
  61671. static readonly FilesToLoad: {
  61672. [key: string]: File;
  61673. };
  61674. /**
  61675. * Callback called when a file is processed
  61676. */
  61677. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  61678. private _engine;
  61679. private _currentScene;
  61680. private _sceneLoadedCallback;
  61681. private _progressCallback;
  61682. private _additionalRenderLoopLogicCallback;
  61683. private _textureLoadingCallback;
  61684. private _startingProcessingFilesCallback;
  61685. private _onReloadCallback;
  61686. private _errorCallback;
  61687. private _elementToMonitor;
  61688. private _sceneFileToLoad;
  61689. private _filesToLoad;
  61690. /**
  61691. * Creates a new FilesInput
  61692. * @param engine defines the rendering engine
  61693. * @param scene defines the hosting scene
  61694. * @param sceneLoadedCallback callback called when scene is loaded
  61695. * @param progressCallback callback called to track progress
  61696. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  61697. * @param textureLoadingCallback callback called when a texture is loading
  61698. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  61699. * @param onReloadCallback callback called when a reload is requested
  61700. * @param errorCallback callback call if an error occurs
  61701. */
  61702. 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);
  61703. private _dragEnterHandler;
  61704. private _dragOverHandler;
  61705. private _dropHandler;
  61706. /**
  61707. * Calls this function to listen to drag'n'drop events on a specific DOM element
  61708. * @param elementToMonitor defines the DOM element to track
  61709. */
  61710. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  61711. /**
  61712. * Release all associated resources
  61713. */
  61714. dispose(): void;
  61715. private renderFunction;
  61716. private drag;
  61717. private drop;
  61718. private _traverseFolder;
  61719. private _processFiles;
  61720. /**
  61721. * Load files from a drop event
  61722. * @param event defines the drop event to use as source
  61723. */
  61724. loadFiles(event: any): void;
  61725. private _processReload;
  61726. /**
  61727. * Reload the current scene from the loaded files
  61728. */
  61729. reload(): void;
  61730. }
  61731. }
  61732. declare module "babylonjs/Misc/HighDynamicRange/index" {
  61733. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  61734. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  61735. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  61736. }
  61737. declare module "babylonjs/Misc/sceneOptimizer" {
  61738. import { Scene, IDisposable } from "babylonjs/scene";
  61739. import { Observable } from "babylonjs/Misc/observable";
  61740. /**
  61741. * Defines the root class used to create scene optimization to use with SceneOptimizer
  61742. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61743. */
  61744. export class SceneOptimization {
  61745. /**
  61746. * Defines the priority of this optimization (0 by default which means first in the list)
  61747. */
  61748. priority: number;
  61749. /**
  61750. * Gets a string describing the action executed by the current optimization
  61751. * @returns description string
  61752. */
  61753. getDescription(): string;
  61754. /**
  61755. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61756. * @param scene defines the current scene where to apply this optimization
  61757. * @param optimizer defines the current optimizer
  61758. * @returns true if everything that can be done was applied
  61759. */
  61760. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61761. /**
  61762. * Creates the SceneOptimization object
  61763. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61764. * @param desc defines the description associated with the optimization
  61765. */
  61766. constructor(
  61767. /**
  61768. * Defines the priority of this optimization (0 by default which means first in the list)
  61769. */
  61770. priority?: number);
  61771. }
  61772. /**
  61773. * Defines an optimization used to reduce the size of render target textures
  61774. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61775. */
  61776. export class TextureOptimization extends SceneOptimization {
  61777. /**
  61778. * Defines the priority of this optimization (0 by default which means first in the list)
  61779. */
  61780. priority: number;
  61781. /**
  61782. * 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
  61783. */
  61784. maximumSize: number;
  61785. /**
  61786. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61787. */
  61788. step: number;
  61789. /**
  61790. * Gets a string describing the action executed by the current optimization
  61791. * @returns description string
  61792. */
  61793. getDescription(): string;
  61794. /**
  61795. * Creates the TextureOptimization object
  61796. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61797. * @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
  61798. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61799. */
  61800. constructor(
  61801. /**
  61802. * Defines the priority of this optimization (0 by default which means first in the list)
  61803. */
  61804. priority?: number,
  61805. /**
  61806. * 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
  61807. */
  61808. maximumSize?: number,
  61809. /**
  61810. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61811. */
  61812. step?: number);
  61813. /**
  61814. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61815. * @param scene defines the current scene where to apply this optimization
  61816. * @param optimizer defines the current optimizer
  61817. * @returns true if everything that can be done was applied
  61818. */
  61819. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61820. }
  61821. /**
  61822. * Defines an optimization used to increase or decrease the rendering resolution
  61823. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61824. */
  61825. export class HardwareScalingOptimization extends SceneOptimization {
  61826. /**
  61827. * Defines the priority of this optimization (0 by default which means first in the list)
  61828. */
  61829. priority: number;
  61830. /**
  61831. * Defines the maximum scale to use (2 by default)
  61832. */
  61833. maximumScale: number;
  61834. /**
  61835. * Defines the step to use between two passes (0.5 by default)
  61836. */
  61837. step: number;
  61838. private _currentScale;
  61839. private _directionOffset;
  61840. /**
  61841. * Gets a string describing the action executed by the current optimization
  61842. * @return description string
  61843. */
  61844. getDescription(): string;
  61845. /**
  61846. * Creates the HardwareScalingOptimization object
  61847. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61848. * @param maximumScale defines the maximum scale to use (2 by default)
  61849. * @param step defines the step to use between two passes (0.5 by default)
  61850. */
  61851. constructor(
  61852. /**
  61853. * Defines the priority of this optimization (0 by default which means first in the list)
  61854. */
  61855. priority?: number,
  61856. /**
  61857. * Defines the maximum scale to use (2 by default)
  61858. */
  61859. maximumScale?: number,
  61860. /**
  61861. * Defines the step to use between two passes (0.5 by default)
  61862. */
  61863. step?: number);
  61864. /**
  61865. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61866. * @param scene defines the current scene where to apply this optimization
  61867. * @param optimizer defines the current optimizer
  61868. * @returns true if everything that can be done was applied
  61869. */
  61870. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61871. }
  61872. /**
  61873. * Defines an optimization used to remove shadows
  61874. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61875. */
  61876. export class ShadowsOptimization extends SceneOptimization {
  61877. /**
  61878. * Gets a string describing the action executed by the current optimization
  61879. * @return description string
  61880. */
  61881. getDescription(): string;
  61882. /**
  61883. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61884. * @param scene defines the current scene where to apply this optimization
  61885. * @param optimizer defines the current optimizer
  61886. * @returns true if everything that can be done was applied
  61887. */
  61888. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61889. }
  61890. /**
  61891. * Defines an optimization used to turn post-processes off
  61892. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61893. */
  61894. export class PostProcessesOptimization extends SceneOptimization {
  61895. /**
  61896. * Gets a string describing the action executed by the current optimization
  61897. * @return description string
  61898. */
  61899. getDescription(): string;
  61900. /**
  61901. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61902. * @param scene defines the current scene where to apply this optimization
  61903. * @param optimizer defines the current optimizer
  61904. * @returns true if everything that can be done was applied
  61905. */
  61906. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61907. }
  61908. /**
  61909. * Defines an optimization used to turn lens flares off
  61910. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61911. */
  61912. export class LensFlaresOptimization extends SceneOptimization {
  61913. /**
  61914. * Gets a string describing the action executed by the current optimization
  61915. * @return description string
  61916. */
  61917. getDescription(): string;
  61918. /**
  61919. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61920. * @param scene defines the current scene where to apply this optimization
  61921. * @param optimizer defines the current optimizer
  61922. * @returns true if everything that can be done was applied
  61923. */
  61924. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61925. }
  61926. /**
  61927. * Defines an optimization based on user defined callback.
  61928. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61929. */
  61930. export class CustomOptimization extends SceneOptimization {
  61931. /**
  61932. * Callback called to apply the custom optimization.
  61933. */
  61934. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  61935. /**
  61936. * Callback called to get custom description
  61937. */
  61938. onGetDescription: () => string;
  61939. /**
  61940. * Gets a string describing the action executed by the current optimization
  61941. * @returns description string
  61942. */
  61943. getDescription(): string;
  61944. /**
  61945. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61946. * @param scene defines the current scene where to apply this optimization
  61947. * @param optimizer defines the current optimizer
  61948. * @returns true if everything that can be done was applied
  61949. */
  61950. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61951. }
  61952. /**
  61953. * Defines an optimization used to turn particles off
  61954. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61955. */
  61956. export class ParticlesOptimization extends SceneOptimization {
  61957. /**
  61958. * Gets a string describing the action executed by the current optimization
  61959. * @return description string
  61960. */
  61961. getDescription(): string;
  61962. /**
  61963. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61964. * @param scene defines the current scene where to apply this optimization
  61965. * @param optimizer defines the current optimizer
  61966. * @returns true if everything that can be done was applied
  61967. */
  61968. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61969. }
  61970. /**
  61971. * Defines an optimization used to turn render targets off
  61972. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61973. */
  61974. export class RenderTargetsOptimization extends SceneOptimization {
  61975. /**
  61976. * Gets a string describing the action executed by the current optimization
  61977. * @return description string
  61978. */
  61979. getDescription(): string;
  61980. /**
  61981. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61982. * @param scene defines the current scene where to apply this optimization
  61983. * @param optimizer defines the current optimizer
  61984. * @returns true if everything that can be done was applied
  61985. */
  61986. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61987. }
  61988. /**
  61989. * Defines an optimization used to merge meshes with compatible materials
  61990. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61991. */
  61992. export class MergeMeshesOptimization extends SceneOptimization {
  61993. private static _UpdateSelectionTree;
  61994. /**
  61995. * Gets or sets a boolean which defines if optimization octree has to be updated
  61996. */
  61997. /**
  61998. * Gets or sets a boolean which defines if optimization octree has to be updated
  61999. */
  62000. static UpdateSelectionTree: boolean;
  62001. /**
  62002. * Gets a string describing the action executed by the current optimization
  62003. * @return description string
  62004. */
  62005. getDescription(): string;
  62006. private _canBeMerged;
  62007. /**
  62008. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62009. * @param scene defines the current scene where to apply this optimization
  62010. * @param optimizer defines the current optimizer
  62011. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  62012. * @returns true if everything that can be done was applied
  62013. */
  62014. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  62015. }
  62016. /**
  62017. * Defines a list of options used by SceneOptimizer
  62018. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62019. */
  62020. export class SceneOptimizerOptions {
  62021. /**
  62022. * Defines the target frame rate to reach (60 by default)
  62023. */
  62024. targetFrameRate: number;
  62025. /**
  62026. * Defines the interval between two checkes (2000ms by default)
  62027. */
  62028. trackerDuration: number;
  62029. /**
  62030. * Gets the list of optimizations to apply
  62031. */
  62032. optimizations: SceneOptimization[];
  62033. /**
  62034. * Creates a new list of options used by SceneOptimizer
  62035. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  62036. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  62037. */
  62038. constructor(
  62039. /**
  62040. * Defines the target frame rate to reach (60 by default)
  62041. */
  62042. targetFrameRate?: number,
  62043. /**
  62044. * Defines the interval between two checkes (2000ms by default)
  62045. */
  62046. trackerDuration?: number);
  62047. /**
  62048. * Add a new optimization
  62049. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  62050. * @returns the current SceneOptimizerOptions
  62051. */
  62052. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  62053. /**
  62054. * Add a new custom optimization
  62055. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  62056. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  62057. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62058. * @returns the current SceneOptimizerOptions
  62059. */
  62060. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  62061. /**
  62062. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  62063. * @param targetFrameRate defines the target frame rate (60 by default)
  62064. * @returns a SceneOptimizerOptions object
  62065. */
  62066. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62067. /**
  62068. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  62069. * @param targetFrameRate defines the target frame rate (60 by default)
  62070. * @returns a SceneOptimizerOptions object
  62071. */
  62072. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62073. /**
  62074. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  62075. * @param targetFrameRate defines the target frame rate (60 by default)
  62076. * @returns a SceneOptimizerOptions object
  62077. */
  62078. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62079. }
  62080. /**
  62081. * Class used to run optimizations in order to reach a target frame rate
  62082. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62083. */
  62084. export class SceneOptimizer implements IDisposable {
  62085. private _isRunning;
  62086. private _options;
  62087. private _scene;
  62088. private _currentPriorityLevel;
  62089. private _targetFrameRate;
  62090. private _trackerDuration;
  62091. private _currentFrameRate;
  62092. private _sceneDisposeObserver;
  62093. private _improvementMode;
  62094. /**
  62095. * Defines an observable called when the optimizer reaches the target frame rate
  62096. */
  62097. onSuccessObservable: Observable<SceneOptimizer>;
  62098. /**
  62099. * Defines an observable called when the optimizer enables an optimization
  62100. */
  62101. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  62102. /**
  62103. * Defines an observable called when the optimizer is not able to reach the target frame rate
  62104. */
  62105. onFailureObservable: Observable<SceneOptimizer>;
  62106. /**
  62107. * Gets a boolean indicating if the optimizer is in improvement mode
  62108. */
  62109. readonly isInImprovementMode: boolean;
  62110. /**
  62111. * Gets the current priority level (0 at start)
  62112. */
  62113. readonly currentPriorityLevel: number;
  62114. /**
  62115. * Gets the current frame rate checked by the SceneOptimizer
  62116. */
  62117. readonly currentFrameRate: number;
  62118. /**
  62119. * Gets or sets the current target frame rate (60 by default)
  62120. */
  62121. /**
  62122. * Gets or sets the current target frame rate (60 by default)
  62123. */
  62124. targetFrameRate: number;
  62125. /**
  62126. * Gets or sets the current interval between two checks (every 2000ms by default)
  62127. */
  62128. /**
  62129. * Gets or sets the current interval between two checks (every 2000ms by default)
  62130. */
  62131. trackerDuration: number;
  62132. /**
  62133. * Gets the list of active optimizations
  62134. */
  62135. readonly optimizations: SceneOptimization[];
  62136. /**
  62137. * Creates a new SceneOptimizer
  62138. * @param scene defines the scene to work on
  62139. * @param options defines the options to use with the SceneOptimizer
  62140. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  62141. * @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)
  62142. */
  62143. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  62144. /**
  62145. * Stops the current optimizer
  62146. */
  62147. stop(): void;
  62148. /**
  62149. * Reset the optimizer to initial step (current priority level = 0)
  62150. */
  62151. reset(): void;
  62152. /**
  62153. * Start the optimizer. By default it will try to reach a specific framerate
  62154. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  62155. */
  62156. start(): void;
  62157. private _checkCurrentState;
  62158. /**
  62159. * Release all resources
  62160. */
  62161. dispose(): void;
  62162. /**
  62163. * Helper function to create a SceneOptimizer with one single line of code
  62164. * @param scene defines the scene to work on
  62165. * @param options defines the options to use with the SceneOptimizer
  62166. * @param onSuccess defines a callback to call on success
  62167. * @param onFailure defines a callback to call on failure
  62168. * @returns the new SceneOptimizer object
  62169. */
  62170. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  62171. }
  62172. }
  62173. declare module "babylonjs/Misc/sceneSerializer" {
  62174. import { Scene } from "babylonjs/scene";
  62175. /**
  62176. * Class used to serialize a scene into a string
  62177. */
  62178. export class SceneSerializer {
  62179. /**
  62180. * Clear cache used by a previous serialization
  62181. */
  62182. static ClearCache(): void;
  62183. /**
  62184. * Serialize a scene into a JSON compatible object
  62185. * @param scene defines the scene to serialize
  62186. * @returns a JSON compatible object
  62187. */
  62188. static Serialize(scene: Scene): any;
  62189. /**
  62190. * Serialize a mesh into a JSON compatible object
  62191. * @param toSerialize defines the mesh to serialize
  62192. * @param withParents defines if parents must be serialized as well
  62193. * @param withChildren defines if children must be serialized as well
  62194. * @returns a JSON compatible object
  62195. */
  62196. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  62197. }
  62198. }
  62199. declare module "babylonjs/Misc/textureTools" {
  62200. import { Texture } from "babylonjs/Materials/Textures/texture";
  62201. /**
  62202. * Class used to host texture specific utilities
  62203. */
  62204. export class TextureTools {
  62205. /**
  62206. * Uses the GPU to create a copy texture rescaled at a given size
  62207. * @param texture Texture to copy from
  62208. * @param width defines the desired width
  62209. * @param height defines the desired height
  62210. * @param useBilinearMode defines if bilinear mode has to be used
  62211. * @return the generated texture
  62212. */
  62213. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  62214. }
  62215. }
  62216. declare module "babylonjs/Misc/videoRecorder" {
  62217. import { Nullable } from "babylonjs/types";
  62218. import { Engine } from "babylonjs/Engines/engine";
  62219. /**
  62220. * This represents the different options available for the video capture.
  62221. */
  62222. export interface VideoRecorderOptions {
  62223. /** Defines the mime type of the video. */
  62224. mimeType: string;
  62225. /** Defines the FPS the video should be recorded at. */
  62226. fps: number;
  62227. /** Defines the chunk size for the recording data. */
  62228. recordChunckSize: number;
  62229. /** The audio tracks to attach to the recording. */
  62230. audioTracks?: MediaStreamTrack[];
  62231. }
  62232. /**
  62233. * This can help with recording videos from BabylonJS.
  62234. * This is based on the available WebRTC functionalities of the browser.
  62235. *
  62236. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  62237. */
  62238. export class VideoRecorder {
  62239. private static readonly _defaultOptions;
  62240. /**
  62241. * Returns whether or not the VideoRecorder is available in your browser.
  62242. * @param engine Defines the Babylon Engine.
  62243. * @returns true if supported otherwise false.
  62244. */
  62245. static IsSupported(engine: Engine): boolean;
  62246. private readonly _options;
  62247. private _canvas;
  62248. private _mediaRecorder;
  62249. private _recordedChunks;
  62250. private _fileName;
  62251. private _resolve;
  62252. private _reject;
  62253. /**
  62254. * True when a recording is already in progress.
  62255. */
  62256. readonly isRecording: boolean;
  62257. /**
  62258. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  62259. * @param engine Defines the BabylonJS Engine you wish to record.
  62260. * @param options Defines options that can be used to customize the capture.
  62261. */
  62262. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  62263. /**
  62264. * Stops the current recording before the default capture timeout passed in the startRecording function.
  62265. */
  62266. stopRecording(): void;
  62267. /**
  62268. * Starts recording the canvas for a max duration specified in parameters.
  62269. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  62270. * If null no automatic download will start and you can rely on the promise to get the data back.
  62271. * @param maxDuration Defines the maximum recording time in seconds.
  62272. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  62273. * @return A promise callback at the end of the recording with the video data in Blob.
  62274. */
  62275. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  62276. /**
  62277. * Releases internal resources used during the recording.
  62278. */
  62279. dispose(): void;
  62280. private _handleDataAvailable;
  62281. private _handleError;
  62282. private _handleStop;
  62283. }
  62284. }
  62285. declare module "babylonjs/Misc/screenshotTools" {
  62286. import { Camera } from "babylonjs/Cameras/camera";
  62287. import { Engine } from "babylonjs/Engines/engine";
  62288. /**
  62289. * Class containing a set of static utilities functions for screenshots
  62290. */
  62291. export class ScreenshotTools {
  62292. /**
  62293. * Captures a screenshot of the current rendering
  62294. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62295. * @param engine defines the rendering engine
  62296. * @param camera defines the source camera
  62297. * @param size This parameter can be set to a single number or to an object with the
  62298. * following (optional) properties: precision, width, height. If a single number is passed,
  62299. * it will be used for both width and height. If an object is passed, the screenshot size
  62300. * will be derived from the parameters. The precision property is a multiplier allowing
  62301. * rendering at a higher or lower resolution
  62302. * @param successCallback defines the callback receives a single parameter which contains the
  62303. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62304. * src parameter of an <img> to display it
  62305. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62306. * Check your browser for supported MIME types
  62307. */
  62308. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  62309. /**
  62310. * Generates an image screenshot from the specified camera.
  62311. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62312. * @param engine The engine to use for rendering
  62313. * @param camera The camera to use for rendering
  62314. * @param size This parameter can be set to a single number or to an object with the
  62315. * following (optional) properties: precision, width, height. If a single number is passed,
  62316. * it will be used for both width and height. If an object is passed, the screenshot size
  62317. * will be derived from the parameters. The precision property is a multiplier allowing
  62318. * rendering at a higher or lower resolution
  62319. * @param successCallback The callback receives a single parameter which contains the
  62320. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62321. * src parameter of an <img> to display it
  62322. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62323. * Check your browser for supported MIME types
  62324. * @param samples Texture samples (default: 1)
  62325. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62326. * @param fileName A name for for the downloaded file.
  62327. */
  62328. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  62329. }
  62330. }
  62331. declare module "babylonjs/Misc/index" {
  62332. export * from "babylonjs/Misc/andOrNotEvaluator";
  62333. export * from "babylonjs/Misc/assetsManager";
  62334. export * from "babylonjs/Misc/dds";
  62335. export * from "babylonjs/Misc/decorators";
  62336. export * from "babylonjs/Misc/deferred";
  62337. export * from "babylonjs/Misc/environmentTextureTools";
  62338. export * from "babylonjs/Misc/meshExploder";
  62339. export * from "babylonjs/Misc/filesInput";
  62340. export * from "babylonjs/Misc/HighDynamicRange/index";
  62341. export * from "babylonjs/Misc/khronosTextureContainer";
  62342. export * from "babylonjs/Misc/observable";
  62343. export * from "babylonjs/Misc/performanceMonitor";
  62344. export * from "babylonjs/Misc/promise";
  62345. export * from "babylonjs/Misc/sceneOptimizer";
  62346. export * from "babylonjs/Misc/sceneSerializer";
  62347. export * from "babylonjs/Misc/smartArray";
  62348. export * from "babylonjs/Misc/stringDictionary";
  62349. export * from "babylonjs/Misc/tags";
  62350. export * from "babylonjs/Misc/textureTools";
  62351. export * from "babylonjs/Misc/tga";
  62352. export * from "babylonjs/Misc/tools";
  62353. export * from "babylonjs/Misc/videoRecorder";
  62354. export * from "babylonjs/Misc/virtualJoystick";
  62355. export * from "babylonjs/Misc/workerPool";
  62356. export * from "babylonjs/Misc/logger";
  62357. export * from "babylonjs/Misc/typeStore";
  62358. export * from "babylonjs/Misc/filesInputStore";
  62359. export * from "babylonjs/Misc/deepCopier";
  62360. export * from "babylonjs/Misc/pivotTools";
  62361. export * from "babylonjs/Misc/precisionDate";
  62362. export * from "babylonjs/Misc/screenshotTools";
  62363. export * from "babylonjs/Misc/typeStore";
  62364. export * from "babylonjs/Misc/webRequest";
  62365. export * from "babylonjs/Misc/iInspectable";
  62366. export * from "babylonjs/Misc/brdfTextureTools";
  62367. }
  62368. declare module "babylonjs/index" {
  62369. export * from "babylonjs/abstractScene";
  62370. export * from "babylonjs/Actions/index";
  62371. export * from "babylonjs/Animations/index";
  62372. export * from "babylonjs/assetContainer";
  62373. export * from "babylonjs/Audio/index";
  62374. export * from "babylonjs/Behaviors/index";
  62375. export * from "babylonjs/Bones/index";
  62376. export * from "babylonjs/Cameras/index";
  62377. export * from "babylonjs/Collisions/index";
  62378. export * from "babylonjs/Culling/index";
  62379. export * from "babylonjs/Debug/index";
  62380. export * from "babylonjs/Engines/index";
  62381. export * from "babylonjs/Events/index";
  62382. export * from "babylonjs/Gamepads/index";
  62383. export * from "babylonjs/Gizmos/index";
  62384. export * from "babylonjs/Helpers/index";
  62385. export * from "babylonjs/Instrumentation/index";
  62386. export * from "babylonjs/Layers/index";
  62387. export * from "babylonjs/LensFlares/index";
  62388. export * from "babylonjs/Lights/index";
  62389. export * from "babylonjs/Loading/index";
  62390. export * from "babylonjs/Materials/index";
  62391. export * from "babylonjs/Maths/index";
  62392. export * from "babylonjs/Meshes/index";
  62393. export * from "babylonjs/Morph/index";
  62394. export * from "babylonjs/node";
  62395. export * from "babylonjs/Offline/index";
  62396. export * from "babylonjs/Particles/index";
  62397. export * from "babylonjs/Physics/index";
  62398. export * from "babylonjs/PostProcesses/index";
  62399. export * from "babylonjs/Probes/index";
  62400. export * from "babylonjs/Rendering/index";
  62401. export * from "babylonjs/scene";
  62402. export * from "babylonjs/sceneComponent";
  62403. export * from "babylonjs/Sprites/index";
  62404. export * from "babylonjs/States/index";
  62405. export * from "babylonjs/Misc/index";
  62406. export * from "babylonjs/types";
  62407. }
  62408. declare module "babylonjs/Animations/pathCursor" {
  62409. import { Path2, Vector3 } from "babylonjs/Maths/math";
  62410. /**
  62411. * A cursor which tracks a point on a path
  62412. */
  62413. export class PathCursor {
  62414. private path;
  62415. /**
  62416. * Stores path cursor callbacks for when an onchange event is triggered
  62417. */
  62418. private _onchange;
  62419. /**
  62420. * The value of the path cursor
  62421. */
  62422. value: number;
  62423. /**
  62424. * The animation array of the path cursor
  62425. */
  62426. animations: Animation[];
  62427. /**
  62428. * Initializes the path cursor
  62429. * @param path The path to track
  62430. */
  62431. constructor(path: Path2);
  62432. /**
  62433. * Gets the cursor point on the path
  62434. * @returns A point on the path cursor at the cursor location
  62435. */
  62436. getPoint(): Vector3;
  62437. /**
  62438. * Moves the cursor ahead by the step amount
  62439. * @param step The amount to move the cursor forward
  62440. * @returns This path cursor
  62441. */
  62442. moveAhead(step?: number): PathCursor;
  62443. /**
  62444. * Moves the cursor behind by the step amount
  62445. * @param step The amount to move the cursor back
  62446. * @returns This path cursor
  62447. */
  62448. moveBack(step?: number): PathCursor;
  62449. /**
  62450. * Moves the cursor by the step amount
  62451. * If the step amount is greater than one, an exception is thrown
  62452. * @param step The amount to move the cursor
  62453. * @returns This path cursor
  62454. */
  62455. move(step: number): PathCursor;
  62456. /**
  62457. * Ensures that the value is limited between zero and one
  62458. * @returns This path cursor
  62459. */
  62460. private ensureLimits;
  62461. /**
  62462. * Runs onchange callbacks on change (used by the animation engine)
  62463. * @returns This path cursor
  62464. */
  62465. private raiseOnChange;
  62466. /**
  62467. * Executes a function on change
  62468. * @param f A path cursor onchange callback
  62469. * @returns This path cursor
  62470. */
  62471. onchange(f: (cursor: PathCursor) => void): PathCursor;
  62472. }
  62473. }
  62474. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  62475. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  62476. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  62477. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  62478. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  62479. }
  62480. declare module "babylonjs/Engines/Processors/Expressions/index" {
  62481. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  62482. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  62483. }
  62484. declare module "babylonjs/Engines/Processors/index" {
  62485. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  62486. export * from "babylonjs/Engines/Processors/Expressions/index";
  62487. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  62488. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  62489. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  62490. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  62491. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  62492. export * from "babylonjs/Engines/Processors/shaderProcessor";
  62493. }
  62494. declare module "babylonjs/Legacy/legacy" {
  62495. import * as Babylon from "babylonjs/index";
  62496. export * from "babylonjs/index";
  62497. }
  62498. declare module "babylonjs/Shaders/blur.fragment" {
  62499. /** @hidden */
  62500. export var blurPixelShader: {
  62501. name: string;
  62502. shader: string;
  62503. };
  62504. }
  62505. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  62506. /** @hidden */
  62507. export var pointCloudVertexDeclaration: {
  62508. name: string;
  62509. shader: string;
  62510. };
  62511. }
  62512. // Mixins
  62513. interface Window {
  62514. mozIndexedDB: IDBFactory;
  62515. webkitIndexedDB: IDBFactory;
  62516. msIndexedDB: IDBFactory;
  62517. webkitURL: typeof URL;
  62518. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  62519. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  62520. WebGLRenderingContext: WebGLRenderingContext;
  62521. MSGesture: MSGesture;
  62522. CANNON: any;
  62523. AudioContext: AudioContext;
  62524. webkitAudioContext: AudioContext;
  62525. PointerEvent: any;
  62526. Math: Math;
  62527. Uint8Array: Uint8ArrayConstructor;
  62528. Float32Array: Float32ArrayConstructor;
  62529. mozURL: typeof URL;
  62530. msURL: typeof URL;
  62531. VRFrameData: any; // WebVR, from specs 1.1
  62532. DracoDecoderModule: any;
  62533. setImmediate(handler: (...args: any[]) => void): number;
  62534. }
  62535. interface HTMLCanvasElement {
  62536. requestPointerLock(): void;
  62537. msRequestPointerLock?(): void;
  62538. mozRequestPointerLock?(): void;
  62539. webkitRequestPointerLock?(): void;
  62540. /** Track wether a record is in progress */
  62541. isRecording: boolean;
  62542. /** Capture Stream method defined by some browsers */
  62543. captureStream(fps?: number): MediaStream;
  62544. }
  62545. interface CanvasRenderingContext2D {
  62546. msImageSmoothingEnabled: boolean;
  62547. }
  62548. interface MouseEvent {
  62549. mozMovementX: number;
  62550. mozMovementY: number;
  62551. webkitMovementX: number;
  62552. webkitMovementY: number;
  62553. msMovementX: number;
  62554. msMovementY: number;
  62555. }
  62556. interface Navigator {
  62557. mozGetVRDevices: (any: any) => any;
  62558. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62559. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62560. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62561. webkitGetGamepads(): Gamepad[];
  62562. msGetGamepads(): Gamepad[];
  62563. webkitGamepads(): Gamepad[];
  62564. }
  62565. interface HTMLVideoElement {
  62566. mozSrcObject: any;
  62567. }
  62568. interface Math {
  62569. fround(x: number): number;
  62570. imul(a: number, b: number): number;
  62571. }
  62572. interface WebGLRenderingContext {
  62573. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  62574. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  62575. vertexAttribDivisor(index: number, divisor: number): void;
  62576. createVertexArray(): any;
  62577. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  62578. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  62579. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  62580. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  62581. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  62582. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  62583. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  62584. // Queries
  62585. createQuery(): WebGLQuery;
  62586. deleteQuery(query: WebGLQuery): void;
  62587. beginQuery(target: number, query: WebGLQuery): void;
  62588. endQuery(target: number): void;
  62589. getQueryParameter(query: WebGLQuery, pname: number): any;
  62590. getQuery(target: number, pname: number): any;
  62591. MAX_SAMPLES: number;
  62592. RGBA8: number;
  62593. READ_FRAMEBUFFER: number;
  62594. DRAW_FRAMEBUFFER: number;
  62595. UNIFORM_BUFFER: number;
  62596. HALF_FLOAT_OES: number;
  62597. RGBA16F: number;
  62598. RGBA32F: number;
  62599. R32F: number;
  62600. RG32F: number;
  62601. RGB32F: number;
  62602. R16F: number;
  62603. RG16F: number;
  62604. RGB16F: number;
  62605. RED: number;
  62606. RG: number;
  62607. R8: number;
  62608. RG8: number;
  62609. UNSIGNED_INT_24_8: number;
  62610. DEPTH24_STENCIL8: number;
  62611. /* Multiple Render Targets */
  62612. drawBuffers(buffers: number[]): void;
  62613. readBuffer(src: number): void;
  62614. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  62615. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  62616. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  62617. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  62618. // Occlusion Query
  62619. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  62620. ANY_SAMPLES_PASSED: number;
  62621. QUERY_RESULT_AVAILABLE: number;
  62622. QUERY_RESULT: number;
  62623. }
  62624. interface WebGLProgram {
  62625. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  62626. }
  62627. interface EXT_disjoint_timer_query {
  62628. QUERY_COUNTER_BITS_EXT: number;
  62629. TIME_ELAPSED_EXT: number;
  62630. TIMESTAMP_EXT: number;
  62631. GPU_DISJOINT_EXT: number;
  62632. QUERY_RESULT_EXT: number;
  62633. QUERY_RESULT_AVAILABLE_EXT: number;
  62634. queryCounterEXT(query: WebGLQuery, target: number): void;
  62635. createQueryEXT(): WebGLQuery;
  62636. beginQueryEXT(target: number, query: WebGLQuery): void;
  62637. endQueryEXT(target: number): void;
  62638. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  62639. deleteQueryEXT(query: WebGLQuery): void;
  62640. }
  62641. interface WebGLUniformLocation {
  62642. _currentState: any;
  62643. }
  62644. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  62645. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  62646. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  62647. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62648. interface WebGLRenderingContext {
  62649. readonly RASTERIZER_DISCARD: number;
  62650. readonly DEPTH_COMPONENT24: number;
  62651. readonly TEXTURE_3D: number;
  62652. readonly TEXTURE_2D_ARRAY: number;
  62653. readonly TEXTURE_COMPARE_FUNC: number;
  62654. readonly TEXTURE_COMPARE_MODE: number;
  62655. readonly COMPARE_REF_TO_TEXTURE: number;
  62656. readonly TEXTURE_WRAP_R: number;
  62657. readonly HALF_FLOAT: number;
  62658. readonly RGB8: number;
  62659. readonly RED_INTEGER: number;
  62660. readonly RG_INTEGER: number;
  62661. readonly RGB_INTEGER: number;
  62662. readonly RGBA_INTEGER: number;
  62663. readonly R8_SNORM: number;
  62664. readonly RG8_SNORM: number;
  62665. readonly RGB8_SNORM: number;
  62666. readonly RGBA8_SNORM: number;
  62667. readonly R8I: number;
  62668. readonly RG8I: number;
  62669. readonly RGB8I: number;
  62670. readonly RGBA8I: number;
  62671. readonly R8UI: number;
  62672. readonly RG8UI: number;
  62673. readonly RGB8UI: number;
  62674. readonly RGBA8UI: number;
  62675. readonly R16I: number;
  62676. readonly RG16I: number;
  62677. readonly RGB16I: number;
  62678. readonly RGBA16I: number;
  62679. readonly R16UI: number;
  62680. readonly RG16UI: number;
  62681. readonly RGB16UI: number;
  62682. readonly RGBA16UI: number;
  62683. readonly R32I: number;
  62684. readonly RG32I: number;
  62685. readonly RGB32I: number;
  62686. readonly RGBA32I: number;
  62687. readonly R32UI: number;
  62688. readonly RG32UI: number;
  62689. readonly RGB32UI: number;
  62690. readonly RGBA32UI: number;
  62691. readonly RGB10_A2UI: number;
  62692. readonly R11F_G11F_B10F: number;
  62693. readonly RGB9_E5: number;
  62694. readonly RGB10_A2: number;
  62695. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  62696. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  62697. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  62698. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62699. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  62700. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  62701. 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;
  62702. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  62703. readonly TRANSFORM_FEEDBACK: number;
  62704. readonly INTERLEAVED_ATTRIBS: number;
  62705. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  62706. createTransformFeedback(): WebGLTransformFeedback;
  62707. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  62708. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  62709. beginTransformFeedback(primitiveMode: number): void;
  62710. endTransformFeedback(): void;
  62711. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  62712. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62713. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62714. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62715. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  62716. }
  62717. interface ImageBitmap {
  62718. readonly width: number;
  62719. readonly height: number;
  62720. close(): void;
  62721. }
  62722. interface WebGLQuery extends WebGLObject {
  62723. }
  62724. declare var WebGLQuery: {
  62725. prototype: WebGLQuery;
  62726. new(): WebGLQuery;
  62727. };
  62728. interface WebGLSampler extends WebGLObject {
  62729. }
  62730. declare var WebGLSampler: {
  62731. prototype: WebGLSampler;
  62732. new(): WebGLSampler;
  62733. };
  62734. interface WebGLSync extends WebGLObject {
  62735. }
  62736. declare var WebGLSync: {
  62737. prototype: WebGLSync;
  62738. new(): WebGLSync;
  62739. };
  62740. interface WebGLTransformFeedback extends WebGLObject {
  62741. }
  62742. declare var WebGLTransformFeedback: {
  62743. prototype: WebGLTransformFeedback;
  62744. new(): WebGLTransformFeedback;
  62745. };
  62746. interface WebGLVertexArrayObject extends WebGLObject {
  62747. }
  62748. declare var WebGLVertexArrayObject: {
  62749. prototype: WebGLVertexArrayObject;
  62750. new(): WebGLVertexArrayObject;
  62751. };
  62752. // Type definitions for WebVR API
  62753. // Project: https://w3c.github.io/webvr/
  62754. // Definitions by: six a <https://github.com/lostfictions>
  62755. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62756. interface VRDisplay extends EventTarget {
  62757. /**
  62758. * Dictionary of capabilities describing the VRDisplay.
  62759. */
  62760. readonly capabilities: VRDisplayCapabilities;
  62761. /**
  62762. * z-depth defining the far plane of the eye view frustum
  62763. * enables mapping of values in the render target depth
  62764. * attachment to scene coordinates. Initially set to 10000.0.
  62765. */
  62766. depthFar: number;
  62767. /**
  62768. * z-depth defining the near plane of the eye view frustum
  62769. * enables mapping of values in the render target depth
  62770. * attachment to scene coordinates. Initially set to 0.01.
  62771. */
  62772. depthNear: number;
  62773. /**
  62774. * An identifier for this distinct VRDisplay. Used as an
  62775. * association point in the Gamepad API.
  62776. */
  62777. readonly displayId: number;
  62778. /**
  62779. * A display name, a user-readable name identifying it.
  62780. */
  62781. readonly displayName: string;
  62782. readonly isConnected: boolean;
  62783. readonly isPresenting: boolean;
  62784. /**
  62785. * If this VRDisplay supports room-scale experiences, the optional
  62786. * stage attribute contains details on the room-scale parameters.
  62787. */
  62788. readonly stageParameters: VRStageParameters | null;
  62789. /**
  62790. * Passing the value returned by `requestAnimationFrame` to
  62791. * `cancelAnimationFrame` will unregister the callback.
  62792. * @param handle Define the hanle of the request to cancel
  62793. */
  62794. cancelAnimationFrame(handle: number): void;
  62795. /**
  62796. * Stops presenting to the VRDisplay.
  62797. * @returns a promise to know when it stopped
  62798. */
  62799. exitPresent(): Promise<void>;
  62800. /**
  62801. * Return the current VREyeParameters for the given eye.
  62802. * @param whichEye Define the eye we want the parameter for
  62803. * @returns the eye parameters
  62804. */
  62805. getEyeParameters(whichEye: string): VREyeParameters;
  62806. /**
  62807. * Populates the passed VRFrameData with the information required to render
  62808. * the current frame.
  62809. * @param frameData Define the data structure to populate
  62810. * @returns true if ok otherwise false
  62811. */
  62812. getFrameData(frameData: VRFrameData): boolean;
  62813. /**
  62814. * Get the layers currently being presented.
  62815. * @returns the list of VR layers
  62816. */
  62817. getLayers(): VRLayer[];
  62818. /**
  62819. * Return a VRPose containing the future predicted pose of the VRDisplay
  62820. * when the current frame will be presented. The value returned will not
  62821. * change until JavaScript has returned control to the browser.
  62822. *
  62823. * The VRPose will contain the position, orientation, velocity,
  62824. * and acceleration of each of these properties.
  62825. * @returns the pose object
  62826. */
  62827. getPose(): VRPose;
  62828. /**
  62829. * Return the current instantaneous pose of the VRDisplay, with no
  62830. * prediction applied.
  62831. * @returns the current instantaneous pose
  62832. */
  62833. getImmediatePose(): VRPose;
  62834. /**
  62835. * The callback passed to `requestAnimationFrame` will be called
  62836. * any time a new frame should be rendered. When the VRDisplay is
  62837. * presenting the callback will be called at the native refresh
  62838. * rate of the HMD. When not presenting this function acts
  62839. * identically to how window.requestAnimationFrame acts. Content should
  62840. * make no assumptions of frame rate or vsync behavior as the HMD runs
  62841. * asynchronously from other displays and at differing refresh rates.
  62842. * @param callback Define the eaction to run next frame
  62843. * @returns the request handle it
  62844. */
  62845. requestAnimationFrame(callback: FrameRequestCallback): number;
  62846. /**
  62847. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  62848. * Repeat calls while already presenting will update the VRLayers being displayed.
  62849. * @param layers Define the list of layer to present
  62850. * @returns a promise to know when the request has been fulfilled
  62851. */
  62852. requestPresent(layers: VRLayer[]): Promise<void>;
  62853. /**
  62854. * Reset the pose for this display, treating its current position and
  62855. * orientation as the "origin/zero" values. VRPose.position,
  62856. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  62857. * updated when calling resetPose(). This should be called in only
  62858. * sitting-space experiences.
  62859. */
  62860. resetPose(): void;
  62861. /**
  62862. * The VRLayer provided to the VRDisplay will be captured and presented
  62863. * in the HMD. Calling this function has the same effect on the source
  62864. * canvas as any other operation that uses its source image, and canvases
  62865. * created without preserveDrawingBuffer set to true will be cleared.
  62866. * @param pose Define the pose to submit
  62867. */
  62868. submitFrame(pose?: VRPose): void;
  62869. }
  62870. declare var VRDisplay: {
  62871. prototype: VRDisplay;
  62872. new(): VRDisplay;
  62873. };
  62874. interface VRLayer {
  62875. leftBounds?: number[] | Float32Array | null;
  62876. rightBounds?: number[] | Float32Array | null;
  62877. source?: HTMLCanvasElement | null;
  62878. }
  62879. interface VRDisplayCapabilities {
  62880. readonly canPresent: boolean;
  62881. readonly hasExternalDisplay: boolean;
  62882. readonly hasOrientation: boolean;
  62883. readonly hasPosition: boolean;
  62884. readonly maxLayers: number;
  62885. }
  62886. interface VREyeParameters {
  62887. /** @deprecated */
  62888. readonly fieldOfView: VRFieldOfView;
  62889. readonly offset: Float32Array;
  62890. readonly renderHeight: number;
  62891. readonly renderWidth: number;
  62892. }
  62893. interface VRFieldOfView {
  62894. readonly downDegrees: number;
  62895. readonly leftDegrees: number;
  62896. readonly rightDegrees: number;
  62897. readonly upDegrees: number;
  62898. }
  62899. interface VRFrameData {
  62900. readonly leftProjectionMatrix: Float32Array;
  62901. readonly leftViewMatrix: Float32Array;
  62902. readonly pose: VRPose;
  62903. readonly rightProjectionMatrix: Float32Array;
  62904. readonly rightViewMatrix: Float32Array;
  62905. readonly timestamp: number;
  62906. }
  62907. interface VRPose {
  62908. readonly angularAcceleration: Float32Array | null;
  62909. readonly angularVelocity: Float32Array | null;
  62910. readonly linearAcceleration: Float32Array | null;
  62911. readonly linearVelocity: Float32Array | null;
  62912. readonly orientation: Float32Array | null;
  62913. readonly position: Float32Array | null;
  62914. readonly timestamp: number;
  62915. }
  62916. interface VRStageParameters {
  62917. sittingToStandingTransform?: Float32Array;
  62918. sizeX?: number;
  62919. sizeY?: number;
  62920. }
  62921. interface Navigator {
  62922. getVRDisplays(): Promise<VRDisplay[]>;
  62923. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  62924. }
  62925. interface Window {
  62926. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  62927. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  62928. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  62929. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62930. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62931. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  62932. }
  62933. interface Gamepad {
  62934. readonly displayId: number;
  62935. }
  62936. interface XRDevice {
  62937. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  62938. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  62939. }
  62940. interface XRSession {
  62941. getInputSources(): Array<any>;
  62942. baseLayer: XRWebGLLayer;
  62943. requestFrameOfReference(type: string): Promise<void>;
  62944. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  62945. end(): Promise<void>;
  62946. requestAnimationFrame: Function;
  62947. addEventListener: Function;
  62948. }
  62949. interface XRSessionCreationOptions {
  62950. outputContext?: WebGLRenderingContext | null;
  62951. immersive?: boolean;
  62952. environmentIntegration?: boolean;
  62953. }
  62954. interface XRLayer {
  62955. getViewport: Function;
  62956. framebufferWidth: number;
  62957. framebufferHeight: number;
  62958. }
  62959. interface XRView {
  62960. projectionMatrix: Float32Array;
  62961. }
  62962. interface XRFrame {
  62963. getDevicePose: Function;
  62964. getInputPose: Function;
  62965. views: Array<XRView>;
  62966. baseLayer: XRLayer;
  62967. }
  62968. interface XRFrameOfReference {
  62969. }
  62970. interface XRWebGLLayer extends XRLayer {
  62971. framebuffer: WebGLFramebuffer;
  62972. }
  62973. declare var XRWebGLLayer: {
  62974. prototype: XRWebGLLayer;
  62975. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  62976. };
  62977. declare module "babylonjs" {
  62978. export * from "babylonjs/Legacy/legacy";
  62979. }
  62980. declare module BABYLON {
  62981. /** Alias type for value that can be null */
  62982. export type Nullable<T> = T | null;
  62983. /**
  62984. * Alias type for number that are floats
  62985. * @ignorenaming
  62986. */
  62987. export type float = number;
  62988. /**
  62989. * Alias type for number that are doubles.
  62990. * @ignorenaming
  62991. */
  62992. export type double = number;
  62993. /**
  62994. * Alias type for number that are integer
  62995. * @ignorenaming
  62996. */
  62997. export type int = number;
  62998. /** Alias type for number array or Float32Array */
  62999. export type FloatArray = number[] | Float32Array;
  63000. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  63001. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  63002. /**
  63003. * Alias for types that can be used by a Buffer or VertexBuffer.
  63004. */
  63005. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  63006. /**
  63007. * Alias type for primitive types
  63008. * @ignorenaming
  63009. */
  63010. type Primitive = undefined | null | boolean | string | number | Function;
  63011. /**
  63012. * Type modifier to make all the properties of an object Readonly
  63013. */
  63014. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  63015. /**
  63016. * Type modifier to make all the properties of an object Readonly recursively
  63017. */
  63018. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  63019. /** @hidden */
  63020. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  63021. }
  63022. /** @hidden */
  63023. /** @hidden */
  63024. type DeepImmutableObject<T> = {
  63025. readonly [K in keyof T]: DeepImmutable<T[K]>;
  63026. };
  63027. }
  63028. declare module BABYLON {
  63029. /**
  63030. * Class containing a set of static utilities functions for arrays.
  63031. */
  63032. export class ArrayTools {
  63033. /**
  63034. * Returns an array of the given size filled with element built from the given constructor and the paramters
  63035. * @param size the number of element to construct and put in the array
  63036. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  63037. * @returns a new array filled with new objects
  63038. */
  63039. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  63040. }
  63041. }
  63042. declare module BABYLON {
  63043. /**
  63044. * Scalar computation library
  63045. */
  63046. export class Scalar {
  63047. /**
  63048. * Two pi constants convenient for computation.
  63049. */
  63050. static TwoPi: number;
  63051. /**
  63052. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  63053. * @param a number
  63054. * @param b number
  63055. * @param epsilon (default = 1.401298E-45)
  63056. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  63057. */
  63058. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  63059. /**
  63060. * Returns a string : the upper case translation of the number i to hexadecimal.
  63061. * @param i number
  63062. * @returns the upper case translation of the number i to hexadecimal.
  63063. */
  63064. static ToHex(i: number): string;
  63065. /**
  63066. * Returns -1 if value is negative and +1 is value is positive.
  63067. * @param value the value
  63068. * @returns the value itself if it's equal to zero.
  63069. */
  63070. static Sign(value: number): number;
  63071. /**
  63072. * Returns the value itself if it's between min and max.
  63073. * Returns min if the value is lower than min.
  63074. * Returns max if the value is greater than max.
  63075. * @param value the value to clmap
  63076. * @param min the min value to clamp to (default: 0)
  63077. * @param max the max value to clamp to (default: 1)
  63078. * @returns the clamped value
  63079. */
  63080. static Clamp(value: number, min?: number, max?: number): number;
  63081. /**
  63082. * the log2 of value.
  63083. * @param value the value to compute log2 of
  63084. * @returns the log2 of value.
  63085. */
  63086. static Log2(value: number): number;
  63087. /**
  63088. * Loops the value, so that it is never larger than length and never smaller than 0.
  63089. *
  63090. * This is similar to the modulo operator but it works with floating point numbers.
  63091. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  63092. * With t = 5 and length = 2.5, the result would be 0.0.
  63093. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  63094. * @param value the value
  63095. * @param length the length
  63096. * @returns the looped value
  63097. */
  63098. static Repeat(value: number, length: number): number;
  63099. /**
  63100. * Normalize the value between 0.0 and 1.0 using min and max values
  63101. * @param value value to normalize
  63102. * @param min max to normalize between
  63103. * @param max min to normalize between
  63104. * @returns the normalized value
  63105. */
  63106. static Normalize(value: number, min: number, max: number): number;
  63107. /**
  63108. * Denormalize the value from 0.0 and 1.0 using min and max values
  63109. * @param normalized value to denormalize
  63110. * @param min max to denormalize between
  63111. * @param max min to denormalize between
  63112. * @returns the denormalized value
  63113. */
  63114. static Denormalize(normalized: number, min: number, max: number): number;
  63115. /**
  63116. * Calculates the shortest difference between two given angles given in degrees.
  63117. * @param current current angle in degrees
  63118. * @param target target angle in degrees
  63119. * @returns the delta
  63120. */
  63121. static DeltaAngle(current: number, target: number): number;
  63122. /**
  63123. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  63124. * @param tx value
  63125. * @param length length
  63126. * @returns The returned value will move back and forth between 0 and length
  63127. */
  63128. static PingPong(tx: number, length: number): number;
  63129. /**
  63130. * Interpolates between min and max with smoothing at the limits.
  63131. *
  63132. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  63133. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  63134. * @param from from
  63135. * @param to to
  63136. * @param tx value
  63137. * @returns the smooth stepped value
  63138. */
  63139. static SmoothStep(from: number, to: number, tx: number): number;
  63140. /**
  63141. * Moves a value current towards target.
  63142. *
  63143. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  63144. * Negative values of maxDelta pushes the value away from target.
  63145. * @param current current value
  63146. * @param target target value
  63147. * @param maxDelta max distance to move
  63148. * @returns resulting value
  63149. */
  63150. static MoveTowards(current: number, target: number, maxDelta: number): number;
  63151. /**
  63152. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  63153. *
  63154. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  63155. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  63156. * @param current current value
  63157. * @param target target value
  63158. * @param maxDelta max distance to move
  63159. * @returns resulting angle
  63160. */
  63161. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  63162. /**
  63163. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  63164. * @param start start value
  63165. * @param end target value
  63166. * @param amount amount to lerp between
  63167. * @returns the lerped value
  63168. */
  63169. static Lerp(start: number, end: number, amount: number): number;
  63170. /**
  63171. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  63172. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  63173. * @param start start value
  63174. * @param end target value
  63175. * @param amount amount to lerp between
  63176. * @returns the lerped value
  63177. */
  63178. static LerpAngle(start: number, end: number, amount: number): number;
  63179. /**
  63180. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  63181. * @param a start value
  63182. * @param b target value
  63183. * @param value value between a and b
  63184. * @returns the inverseLerp value
  63185. */
  63186. static InverseLerp(a: number, b: number, value: number): number;
  63187. /**
  63188. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  63189. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  63190. * @param value1 spline value
  63191. * @param tangent1 spline value
  63192. * @param value2 spline value
  63193. * @param tangent2 spline value
  63194. * @param amount input value
  63195. * @returns hermite result
  63196. */
  63197. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  63198. /**
  63199. * Returns a random float number between and min and max values
  63200. * @param min min value of random
  63201. * @param max max value of random
  63202. * @returns random value
  63203. */
  63204. static RandomRange(min: number, max: number): number;
  63205. /**
  63206. * This function returns percentage of a number in a given range.
  63207. *
  63208. * RangeToPercent(40,20,60) will return 0.5 (50%)
  63209. * RangeToPercent(34,0,100) will return 0.34 (34%)
  63210. * @param number to convert to percentage
  63211. * @param min min range
  63212. * @param max max range
  63213. * @returns the percentage
  63214. */
  63215. static RangeToPercent(number: number, min: number, max: number): number;
  63216. /**
  63217. * This function returns number that corresponds to the percentage in a given range.
  63218. *
  63219. * PercentToRange(0.34,0,100) will return 34.
  63220. * @param percent to convert to number
  63221. * @param min min range
  63222. * @param max max range
  63223. * @returns the number
  63224. */
  63225. static PercentToRange(percent: number, min: number, max: number): number;
  63226. /**
  63227. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  63228. * @param angle The angle to normalize in radian.
  63229. * @return The converted angle.
  63230. */
  63231. static NormalizeRadians(angle: number): number;
  63232. }
  63233. }
  63234. declare module BABYLON {
  63235. /**
  63236. * Constant used to convert a value to gamma space
  63237. * @ignorenaming
  63238. */
  63239. export const ToGammaSpace: number;
  63240. /**
  63241. * Constant used to convert a value to linear space
  63242. * @ignorenaming
  63243. */
  63244. export const ToLinearSpace = 2.2;
  63245. /**
  63246. * Constant used to define the minimal number value in Babylon.js
  63247. * @ignorenaming
  63248. */
  63249. let Epsilon: number;
  63250. /**
  63251. * Class used to hold a RBG color
  63252. */
  63253. export class Color3 {
  63254. /**
  63255. * Defines the red component (between 0 and 1, default is 0)
  63256. */
  63257. r: number;
  63258. /**
  63259. * Defines the green component (between 0 and 1, default is 0)
  63260. */
  63261. g: number;
  63262. /**
  63263. * Defines the blue component (between 0 and 1, default is 0)
  63264. */
  63265. b: number;
  63266. /**
  63267. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  63268. * @param r defines the red component (between 0 and 1, default is 0)
  63269. * @param g defines the green component (between 0 and 1, default is 0)
  63270. * @param b defines the blue component (between 0 and 1, default is 0)
  63271. */
  63272. constructor(
  63273. /**
  63274. * Defines the red component (between 0 and 1, default is 0)
  63275. */
  63276. r?: number,
  63277. /**
  63278. * Defines the green component (between 0 and 1, default is 0)
  63279. */
  63280. g?: number,
  63281. /**
  63282. * Defines the blue component (between 0 and 1, default is 0)
  63283. */
  63284. b?: number);
  63285. /**
  63286. * Creates a string with the Color3 current values
  63287. * @returns the string representation of the Color3 object
  63288. */
  63289. toString(): string;
  63290. /**
  63291. * Returns the string "Color3"
  63292. * @returns "Color3"
  63293. */
  63294. getClassName(): string;
  63295. /**
  63296. * Compute the Color3 hash code
  63297. * @returns an unique number that can be used to hash Color3 objects
  63298. */
  63299. getHashCode(): number;
  63300. /**
  63301. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  63302. * @param array defines the array where to store the r,g,b components
  63303. * @param index defines an optional index in the target array to define where to start storing values
  63304. * @returns the current Color3 object
  63305. */
  63306. toArray(array: FloatArray, index?: number): Color3;
  63307. /**
  63308. * Returns a new Color4 object from the current Color3 and the given alpha
  63309. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  63310. * @returns a new Color4 object
  63311. */
  63312. toColor4(alpha?: number): Color4;
  63313. /**
  63314. * Returns a new array populated with 3 numeric elements : red, green and blue values
  63315. * @returns the new array
  63316. */
  63317. asArray(): number[];
  63318. /**
  63319. * Returns the luminance value
  63320. * @returns a float value
  63321. */
  63322. toLuminance(): number;
  63323. /**
  63324. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  63325. * @param otherColor defines the second operand
  63326. * @returns the new Color3 object
  63327. */
  63328. multiply(otherColor: DeepImmutable<Color3>): Color3;
  63329. /**
  63330. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  63331. * @param otherColor defines the second operand
  63332. * @param result defines the Color3 object where to store the result
  63333. * @returns the current Color3
  63334. */
  63335. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  63336. /**
  63337. * Determines equality between Color3 objects
  63338. * @param otherColor defines the second operand
  63339. * @returns true if the rgb values are equal to the given ones
  63340. */
  63341. equals(otherColor: DeepImmutable<Color3>): boolean;
  63342. /**
  63343. * Determines equality between the current Color3 object and a set of r,b,g values
  63344. * @param r defines the red component to check
  63345. * @param g defines the green component to check
  63346. * @param b defines the blue component to check
  63347. * @returns true if the rgb values are equal to the given ones
  63348. */
  63349. equalsFloats(r: number, g: number, b: number): boolean;
  63350. /**
  63351. * Multiplies in place each rgb value by scale
  63352. * @param scale defines the scaling factor
  63353. * @returns the updated Color3
  63354. */
  63355. scale(scale: number): Color3;
  63356. /**
  63357. * Multiplies the rgb values by scale and stores the result into "result"
  63358. * @param scale defines the scaling factor
  63359. * @param result defines the Color3 object where to store the result
  63360. * @returns the unmodified current Color3
  63361. */
  63362. scaleToRef(scale: number, result: Color3): Color3;
  63363. /**
  63364. * Scale the current Color3 values by a factor and add the result to a given Color3
  63365. * @param scale defines the scale factor
  63366. * @param result defines color to store the result into
  63367. * @returns the unmodified current Color3
  63368. */
  63369. scaleAndAddToRef(scale: number, result: Color3): Color3;
  63370. /**
  63371. * Clamps the rgb values by the min and max values and stores the result into "result"
  63372. * @param min defines minimum clamping value (default is 0)
  63373. * @param max defines maximum clamping value (default is 1)
  63374. * @param result defines color to store the result into
  63375. * @returns the original Color3
  63376. */
  63377. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  63378. /**
  63379. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  63380. * @param otherColor defines the second operand
  63381. * @returns the new Color3
  63382. */
  63383. add(otherColor: DeepImmutable<Color3>): Color3;
  63384. /**
  63385. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  63386. * @param otherColor defines the second operand
  63387. * @param result defines Color3 object to store the result into
  63388. * @returns the unmodified current Color3
  63389. */
  63390. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  63391. /**
  63392. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  63393. * @param otherColor defines the second operand
  63394. * @returns the new Color3
  63395. */
  63396. subtract(otherColor: DeepImmutable<Color3>): Color3;
  63397. /**
  63398. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  63399. * @param otherColor defines the second operand
  63400. * @param result defines Color3 object to store the result into
  63401. * @returns the unmodified current Color3
  63402. */
  63403. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  63404. /**
  63405. * Copy the current object
  63406. * @returns a new Color3 copied the current one
  63407. */
  63408. clone(): Color3;
  63409. /**
  63410. * Copies the rgb values from the source in the current Color3
  63411. * @param source defines the source Color3 object
  63412. * @returns the updated Color3 object
  63413. */
  63414. copyFrom(source: DeepImmutable<Color3>): Color3;
  63415. /**
  63416. * Updates the Color3 rgb values from the given floats
  63417. * @param r defines the red component to read from
  63418. * @param g defines the green component to read from
  63419. * @param b defines the blue component to read from
  63420. * @returns the current Color3 object
  63421. */
  63422. copyFromFloats(r: number, g: number, b: number): Color3;
  63423. /**
  63424. * Updates the Color3 rgb values from the given floats
  63425. * @param r defines the red component to read from
  63426. * @param g defines the green component to read from
  63427. * @param b defines the blue component to read from
  63428. * @returns the current Color3 object
  63429. */
  63430. set(r: number, g: number, b: number): Color3;
  63431. /**
  63432. * Compute the Color3 hexadecimal code as a string
  63433. * @returns a string containing the hexadecimal representation of the Color3 object
  63434. */
  63435. toHexString(): string;
  63436. /**
  63437. * Computes a new Color3 converted from the current one to linear space
  63438. * @returns a new Color3 object
  63439. */
  63440. toLinearSpace(): Color3;
  63441. /**
  63442. * Converts current color in rgb space to HSV values
  63443. * @returns a new color3 representing the HSV values
  63444. */
  63445. toHSV(): Color3;
  63446. /**
  63447. * Converts current color in rgb space to HSV values
  63448. * @param result defines the Color3 where to store the HSV values
  63449. */
  63450. toHSVToRef(result: Color3): void;
  63451. /**
  63452. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  63453. * @param convertedColor defines the Color3 object where to store the linear space version
  63454. * @returns the unmodified Color3
  63455. */
  63456. toLinearSpaceToRef(convertedColor: Color3): Color3;
  63457. /**
  63458. * Computes a new Color3 converted from the current one to gamma space
  63459. * @returns a new Color3 object
  63460. */
  63461. toGammaSpace(): Color3;
  63462. /**
  63463. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  63464. * @param convertedColor defines the Color3 object where to store the gamma space version
  63465. * @returns the unmodified Color3
  63466. */
  63467. toGammaSpaceToRef(convertedColor: Color3): Color3;
  63468. private static _BlackReadOnly;
  63469. /**
  63470. * Convert Hue, saturation and value to a Color3 (RGB)
  63471. * @param hue defines the hue
  63472. * @param saturation defines the saturation
  63473. * @param value defines the value
  63474. * @param result defines the Color3 where to store the RGB values
  63475. */
  63476. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  63477. /**
  63478. * Creates a new Color3 from the string containing valid hexadecimal values
  63479. * @param hex defines a string containing valid hexadecimal values
  63480. * @returns a new Color3 object
  63481. */
  63482. static FromHexString(hex: string): Color3;
  63483. /**
  63484. * Creates a new Color3 from the starting index of the given array
  63485. * @param array defines the source array
  63486. * @param offset defines an offset in the source array
  63487. * @returns a new Color3 object
  63488. */
  63489. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  63490. /**
  63491. * Creates a new Color3 from integer values (< 256)
  63492. * @param r defines the red component to read from (value between 0 and 255)
  63493. * @param g defines the green component to read from (value between 0 and 255)
  63494. * @param b defines the blue component to read from (value between 0 and 255)
  63495. * @returns a new Color3 object
  63496. */
  63497. static FromInts(r: number, g: number, b: number): Color3;
  63498. /**
  63499. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  63500. * @param start defines the start Color3 value
  63501. * @param end defines the end Color3 value
  63502. * @param amount defines the gradient value between start and end
  63503. * @returns a new Color3 object
  63504. */
  63505. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  63506. /**
  63507. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  63508. * @param left defines the start value
  63509. * @param right defines the end value
  63510. * @param amount defines the gradient factor
  63511. * @param result defines the Color3 object where to store the result
  63512. */
  63513. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  63514. /**
  63515. * Returns a Color3 value containing a red color
  63516. * @returns a new Color3 object
  63517. */
  63518. static Red(): Color3;
  63519. /**
  63520. * Returns a Color3 value containing a green color
  63521. * @returns a new Color3 object
  63522. */
  63523. static Green(): Color3;
  63524. /**
  63525. * Returns a Color3 value containing a blue color
  63526. * @returns a new Color3 object
  63527. */
  63528. static Blue(): Color3;
  63529. /**
  63530. * Returns a Color3 value containing a black color
  63531. * @returns a new Color3 object
  63532. */
  63533. static Black(): Color3;
  63534. /**
  63535. * Gets a Color3 value containing a black color that must not be updated
  63536. */
  63537. static readonly BlackReadOnly: DeepImmutable<Color3>;
  63538. /**
  63539. * Returns a Color3 value containing a white color
  63540. * @returns a new Color3 object
  63541. */
  63542. static White(): Color3;
  63543. /**
  63544. * Returns a Color3 value containing a purple color
  63545. * @returns a new Color3 object
  63546. */
  63547. static Purple(): Color3;
  63548. /**
  63549. * Returns a Color3 value containing a magenta color
  63550. * @returns a new Color3 object
  63551. */
  63552. static Magenta(): Color3;
  63553. /**
  63554. * Returns a Color3 value containing a yellow color
  63555. * @returns a new Color3 object
  63556. */
  63557. static Yellow(): Color3;
  63558. /**
  63559. * Returns a Color3 value containing a gray color
  63560. * @returns a new Color3 object
  63561. */
  63562. static Gray(): Color3;
  63563. /**
  63564. * Returns a Color3 value containing a teal color
  63565. * @returns a new Color3 object
  63566. */
  63567. static Teal(): Color3;
  63568. /**
  63569. * Returns a Color3 value containing a random color
  63570. * @returns a new Color3 object
  63571. */
  63572. static Random(): Color3;
  63573. }
  63574. /**
  63575. * Class used to hold a RBGA color
  63576. */
  63577. export class Color4 {
  63578. /**
  63579. * Defines the red component (between 0 and 1, default is 0)
  63580. */
  63581. r: number;
  63582. /**
  63583. * Defines the green component (between 0 and 1, default is 0)
  63584. */
  63585. g: number;
  63586. /**
  63587. * Defines the blue component (between 0 and 1, default is 0)
  63588. */
  63589. b: number;
  63590. /**
  63591. * Defines the alpha component (between 0 and 1, default is 1)
  63592. */
  63593. a: number;
  63594. /**
  63595. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  63596. * @param r defines the red component (between 0 and 1, default is 0)
  63597. * @param g defines the green component (between 0 and 1, default is 0)
  63598. * @param b defines the blue component (between 0 and 1, default is 0)
  63599. * @param a defines the alpha component (between 0 and 1, default is 1)
  63600. */
  63601. constructor(
  63602. /**
  63603. * Defines the red component (between 0 and 1, default is 0)
  63604. */
  63605. r?: number,
  63606. /**
  63607. * Defines the green component (between 0 and 1, default is 0)
  63608. */
  63609. g?: number,
  63610. /**
  63611. * Defines the blue component (between 0 and 1, default is 0)
  63612. */
  63613. b?: number,
  63614. /**
  63615. * Defines the alpha component (between 0 and 1, default is 1)
  63616. */
  63617. a?: number);
  63618. /**
  63619. * Adds in place the given Color4 values to the current Color4 object
  63620. * @param right defines the second operand
  63621. * @returns the current updated Color4 object
  63622. */
  63623. addInPlace(right: DeepImmutable<Color4>): Color4;
  63624. /**
  63625. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  63626. * @returns the new array
  63627. */
  63628. asArray(): number[];
  63629. /**
  63630. * Stores from the starting index in the given array the Color4 successive values
  63631. * @param array defines the array where to store the r,g,b components
  63632. * @param index defines an optional index in the target array to define where to start storing values
  63633. * @returns the current Color4 object
  63634. */
  63635. toArray(array: number[], index?: number): Color4;
  63636. /**
  63637. * Determines equality between Color4 objects
  63638. * @param otherColor defines the second operand
  63639. * @returns true if the rgba values are equal to the given ones
  63640. */
  63641. equals(otherColor: DeepImmutable<Color4>): boolean;
  63642. /**
  63643. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  63644. * @param right defines the second operand
  63645. * @returns a new Color4 object
  63646. */
  63647. add(right: DeepImmutable<Color4>): Color4;
  63648. /**
  63649. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  63650. * @param right defines the second operand
  63651. * @returns a new Color4 object
  63652. */
  63653. subtract(right: DeepImmutable<Color4>): Color4;
  63654. /**
  63655. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  63656. * @param right defines the second operand
  63657. * @param result defines the Color4 object where to store the result
  63658. * @returns the current Color4 object
  63659. */
  63660. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  63661. /**
  63662. * Creates a new Color4 with the current Color4 values multiplied by scale
  63663. * @param scale defines the scaling factor to apply
  63664. * @returns a new Color4 object
  63665. */
  63666. scale(scale: number): Color4;
  63667. /**
  63668. * Multiplies the current Color4 values by scale and stores the result in "result"
  63669. * @param scale defines the scaling factor to apply
  63670. * @param result defines the Color4 object where to store the result
  63671. * @returns the current unmodified Color4
  63672. */
  63673. scaleToRef(scale: number, result: Color4): Color4;
  63674. /**
  63675. * Scale the current Color4 values by a factor and add the result to a given Color4
  63676. * @param scale defines the scale factor
  63677. * @param result defines the Color4 object where to store the result
  63678. * @returns the unmodified current Color4
  63679. */
  63680. scaleAndAddToRef(scale: number, result: Color4): Color4;
  63681. /**
  63682. * Clamps the rgb values by the min and max values and stores the result into "result"
  63683. * @param min defines minimum clamping value (default is 0)
  63684. * @param max defines maximum clamping value (default is 1)
  63685. * @param result defines color to store the result into.
  63686. * @returns the cuurent Color4
  63687. */
  63688. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  63689. /**
  63690. * Multipy an Color4 value by another and return a new Color4 object
  63691. * @param color defines the Color4 value to multiply by
  63692. * @returns a new Color4 object
  63693. */
  63694. multiply(color: Color4): Color4;
  63695. /**
  63696. * Multipy a Color4 value by another and push the result in a reference value
  63697. * @param color defines the Color4 value to multiply by
  63698. * @param result defines the Color4 to fill the result in
  63699. * @returns the result Color4
  63700. */
  63701. multiplyToRef(color: Color4, result: Color4): Color4;
  63702. /**
  63703. * Creates a string with the Color4 current values
  63704. * @returns the string representation of the Color4 object
  63705. */
  63706. toString(): string;
  63707. /**
  63708. * Returns the string "Color4"
  63709. * @returns "Color4"
  63710. */
  63711. getClassName(): string;
  63712. /**
  63713. * Compute the Color4 hash code
  63714. * @returns an unique number that can be used to hash Color4 objects
  63715. */
  63716. getHashCode(): number;
  63717. /**
  63718. * Creates a new Color4 copied from the current one
  63719. * @returns a new Color4 object
  63720. */
  63721. clone(): Color4;
  63722. /**
  63723. * Copies the given Color4 values into the current one
  63724. * @param source defines the source Color4 object
  63725. * @returns the current updated Color4 object
  63726. */
  63727. copyFrom(source: Color4): Color4;
  63728. /**
  63729. * Copies the given float values into the current one
  63730. * @param r defines the red component to read from
  63731. * @param g defines the green component to read from
  63732. * @param b defines the blue component to read from
  63733. * @param a defines the alpha component to read from
  63734. * @returns the current updated Color4 object
  63735. */
  63736. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  63737. /**
  63738. * Copies the given float values into the current one
  63739. * @param r defines the red component to read from
  63740. * @param g defines the green component to read from
  63741. * @param b defines the blue component to read from
  63742. * @param a defines the alpha component to read from
  63743. * @returns the current updated Color4 object
  63744. */
  63745. set(r: number, g: number, b: number, a: number): Color4;
  63746. /**
  63747. * Compute the Color4 hexadecimal code as a string
  63748. * @returns a string containing the hexadecimal representation of the Color4 object
  63749. */
  63750. toHexString(): string;
  63751. /**
  63752. * Computes a new Color4 converted from the current one to linear space
  63753. * @returns a new Color4 object
  63754. */
  63755. toLinearSpace(): Color4;
  63756. /**
  63757. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  63758. * @param convertedColor defines the Color4 object where to store the linear space version
  63759. * @returns the unmodified Color4
  63760. */
  63761. toLinearSpaceToRef(convertedColor: Color4): Color4;
  63762. /**
  63763. * Computes a new Color4 converted from the current one to gamma space
  63764. * @returns a new Color4 object
  63765. */
  63766. toGammaSpace(): Color4;
  63767. /**
  63768. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  63769. * @param convertedColor defines the Color4 object where to store the gamma space version
  63770. * @returns the unmodified Color4
  63771. */
  63772. toGammaSpaceToRef(convertedColor: Color4): Color4;
  63773. /**
  63774. * Creates a new Color4 from the string containing valid hexadecimal values
  63775. * @param hex defines a string containing valid hexadecimal values
  63776. * @returns a new Color4 object
  63777. */
  63778. static FromHexString(hex: string): Color4;
  63779. /**
  63780. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  63781. * @param left defines the start value
  63782. * @param right defines the end value
  63783. * @param amount defines the gradient factor
  63784. * @returns a new Color4 object
  63785. */
  63786. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  63787. /**
  63788. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  63789. * @param left defines the start value
  63790. * @param right defines the end value
  63791. * @param amount defines the gradient factor
  63792. * @param result defines the Color4 object where to store data
  63793. */
  63794. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  63795. /**
  63796. * Creates a new Color4 from a Color3 and an alpha value
  63797. * @param color3 defines the source Color3 to read from
  63798. * @param alpha defines the alpha component (1.0 by default)
  63799. * @returns a new Color4 object
  63800. */
  63801. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  63802. /**
  63803. * Creates a new Color4 from the starting index element of the given array
  63804. * @param array defines the source array to read from
  63805. * @param offset defines the offset in the source array
  63806. * @returns a new Color4 object
  63807. */
  63808. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  63809. /**
  63810. * Creates a new Color3 from integer values (< 256)
  63811. * @param r defines the red component to read from (value between 0 and 255)
  63812. * @param g defines the green component to read from (value between 0 and 255)
  63813. * @param b defines the blue component to read from (value between 0 and 255)
  63814. * @param a defines the alpha component to read from (value between 0 and 255)
  63815. * @returns a new Color3 object
  63816. */
  63817. static FromInts(r: number, g: number, b: number, a: number): Color4;
  63818. /**
  63819. * Check the content of a given array and convert it to an array containing RGBA data
  63820. * If the original array was already containing count * 4 values then it is returned directly
  63821. * @param colors defines the array to check
  63822. * @param count defines the number of RGBA data to expect
  63823. * @returns an array containing count * 4 values (RGBA)
  63824. */
  63825. static CheckColors4(colors: number[], count: number): number[];
  63826. }
  63827. /**
  63828. * Class representing a vector containing 2 coordinates
  63829. */
  63830. export class Vector2 {
  63831. /** defines the first coordinate */
  63832. x: number;
  63833. /** defines the second coordinate */
  63834. y: number;
  63835. /**
  63836. * Creates a new Vector2 from the given x and y coordinates
  63837. * @param x defines the first coordinate
  63838. * @param y defines the second coordinate
  63839. */
  63840. constructor(
  63841. /** defines the first coordinate */
  63842. x?: number,
  63843. /** defines the second coordinate */
  63844. y?: number);
  63845. /**
  63846. * Gets a string with the Vector2 coordinates
  63847. * @returns a string with the Vector2 coordinates
  63848. */
  63849. toString(): string;
  63850. /**
  63851. * Gets class name
  63852. * @returns the string "Vector2"
  63853. */
  63854. getClassName(): string;
  63855. /**
  63856. * Gets current vector hash code
  63857. * @returns the Vector2 hash code as a number
  63858. */
  63859. getHashCode(): number;
  63860. /**
  63861. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  63862. * @param array defines the source array
  63863. * @param index defines the offset in source array
  63864. * @returns the current Vector2
  63865. */
  63866. toArray(array: FloatArray, index?: number): Vector2;
  63867. /**
  63868. * Copy the current vector to an array
  63869. * @returns a new array with 2 elements: the Vector2 coordinates.
  63870. */
  63871. asArray(): number[];
  63872. /**
  63873. * Sets the Vector2 coordinates with the given Vector2 coordinates
  63874. * @param source defines the source Vector2
  63875. * @returns the current updated Vector2
  63876. */
  63877. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  63878. /**
  63879. * Sets the Vector2 coordinates with the given floats
  63880. * @param x defines the first coordinate
  63881. * @param y defines the second coordinate
  63882. * @returns the current updated Vector2
  63883. */
  63884. copyFromFloats(x: number, y: number): Vector2;
  63885. /**
  63886. * Sets the Vector2 coordinates with the given floats
  63887. * @param x defines the first coordinate
  63888. * @param y defines the second coordinate
  63889. * @returns the current updated Vector2
  63890. */
  63891. set(x: number, y: number): Vector2;
  63892. /**
  63893. * Add another vector with the current one
  63894. * @param otherVector defines the other vector
  63895. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  63896. */
  63897. add(otherVector: DeepImmutable<Vector2>): Vector2;
  63898. /**
  63899. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  63900. * @param otherVector defines the other vector
  63901. * @param result defines the target vector
  63902. * @returns the unmodified current Vector2
  63903. */
  63904. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63905. /**
  63906. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  63907. * @param otherVector defines the other vector
  63908. * @returns the current updated Vector2
  63909. */
  63910. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63911. /**
  63912. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  63913. * @param otherVector defines the other vector
  63914. * @returns a new Vector2
  63915. */
  63916. addVector3(otherVector: Vector3): Vector2;
  63917. /**
  63918. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  63919. * @param otherVector defines the other vector
  63920. * @returns a new Vector2
  63921. */
  63922. subtract(otherVector: Vector2): Vector2;
  63923. /**
  63924. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  63925. * @param otherVector defines the other vector
  63926. * @param result defines the target vector
  63927. * @returns the unmodified current Vector2
  63928. */
  63929. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63930. /**
  63931. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  63932. * @param otherVector defines the other vector
  63933. * @returns the current updated Vector2
  63934. */
  63935. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63936. /**
  63937. * Multiplies in place the current Vector2 coordinates by the given ones
  63938. * @param otherVector defines the other vector
  63939. * @returns the current updated Vector2
  63940. */
  63941. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63942. /**
  63943. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  63944. * @param otherVector defines the other vector
  63945. * @returns a new Vector2
  63946. */
  63947. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  63948. /**
  63949. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  63950. * @param otherVector defines the other vector
  63951. * @param result defines the target vector
  63952. * @returns the unmodified current Vector2
  63953. */
  63954. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63955. /**
  63956. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  63957. * @param x defines the first coordinate
  63958. * @param y defines the second coordinate
  63959. * @returns a new Vector2
  63960. */
  63961. multiplyByFloats(x: number, y: number): Vector2;
  63962. /**
  63963. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  63964. * @param otherVector defines the other vector
  63965. * @returns a new Vector2
  63966. */
  63967. divide(otherVector: Vector2): Vector2;
  63968. /**
  63969. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  63970. * @param otherVector defines the other vector
  63971. * @param result defines the target vector
  63972. * @returns the unmodified current Vector2
  63973. */
  63974. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63975. /**
  63976. * Divides the current Vector2 coordinates by the given ones
  63977. * @param otherVector defines the other vector
  63978. * @returns the current updated Vector2
  63979. */
  63980. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63981. /**
  63982. * Gets a new Vector2 with current Vector2 negated coordinates
  63983. * @returns a new Vector2
  63984. */
  63985. negate(): Vector2;
  63986. /**
  63987. * Multiply the Vector2 coordinates by scale
  63988. * @param scale defines the scaling factor
  63989. * @returns the current updated Vector2
  63990. */
  63991. scaleInPlace(scale: number): Vector2;
  63992. /**
  63993. * Returns a new Vector2 scaled by "scale" from the current Vector2
  63994. * @param scale defines the scaling factor
  63995. * @returns a new Vector2
  63996. */
  63997. scale(scale: number): Vector2;
  63998. /**
  63999. * Scale the current Vector2 values by a factor to a given Vector2
  64000. * @param scale defines the scale factor
  64001. * @param result defines the Vector2 object where to store the result
  64002. * @returns the unmodified current Vector2
  64003. */
  64004. scaleToRef(scale: number, result: Vector2): Vector2;
  64005. /**
  64006. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  64007. * @param scale defines the scale factor
  64008. * @param result defines the Vector2 object where to store the result
  64009. * @returns the unmodified current Vector2
  64010. */
  64011. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  64012. /**
  64013. * Gets a boolean if two vectors are equals
  64014. * @param otherVector defines the other vector
  64015. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  64016. */
  64017. equals(otherVector: DeepImmutable<Vector2>): boolean;
  64018. /**
  64019. * Gets a boolean if two vectors are equals (using an epsilon value)
  64020. * @param otherVector defines the other vector
  64021. * @param epsilon defines the minimal distance to consider equality
  64022. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  64023. */
  64024. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  64025. /**
  64026. * Gets a new Vector2 from current Vector2 floored values
  64027. * @returns a new Vector2
  64028. */
  64029. floor(): Vector2;
  64030. /**
  64031. * Gets a new Vector2 from current Vector2 floored values
  64032. * @returns a new Vector2
  64033. */
  64034. fract(): Vector2;
  64035. /**
  64036. * Gets the length of the vector
  64037. * @returns the vector length (float)
  64038. */
  64039. length(): number;
  64040. /**
  64041. * Gets the vector squared length
  64042. * @returns the vector squared length (float)
  64043. */
  64044. lengthSquared(): number;
  64045. /**
  64046. * Normalize the vector
  64047. * @returns the current updated Vector2
  64048. */
  64049. normalize(): Vector2;
  64050. /**
  64051. * Gets a new Vector2 copied from the Vector2
  64052. * @returns a new Vector2
  64053. */
  64054. clone(): Vector2;
  64055. /**
  64056. * Gets a new Vector2(0, 0)
  64057. * @returns a new Vector2
  64058. */
  64059. static Zero(): Vector2;
  64060. /**
  64061. * Gets a new Vector2(1, 1)
  64062. * @returns a new Vector2
  64063. */
  64064. static One(): Vector2;
  64065. /**
  64066. * Gets a new Vector2 set from the given index element of the given array
  64067. * @param array defines the data source
  64068. * @param offset defines the offset in the data source
  64069. * @returns a new Vector2
  64070. */
  64071. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  64072. /**
  64073. * Sets "result" from the given index element of the given array
  64074. * @param array defines the data source
  64075. * @param offset defines the offset in the data source
  64076. * @param result defines the target vector
  64077. */
  64078. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  64079. /**
  64080. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  64081. * @param value1 defines 1st point of control
  64082. * @param value2 defines 2nd point of control
  64083. * @param value3 defines 3rd point of control
  64084. * @param value4 defines 4th point of control
  64085. * @param amount defines the interpolation factor
  64086. * @returns a new Vector2
  64087. */
  64088. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  64089. /**
  64090. * 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".
  64091. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  64092. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  64093. * @param value defines the value to clamp
  64094. * @param min defines the lower limit
  64095. * @param max defines the upper limit
  64096. * @returns a new Vector2
  64097. */
  64098. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  64099. /**
  64100. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  64101. * @param value1 defines the 1st control point
  64102. * @param tangent1 defines the outgoing tangent
  64103. * @param value2 defines the 2nd control point
  64104. * @param tangent2 defines the incoming tangent
  64105. * @param amount defines the interpolation factor
  64106. * @returns a new Vector2
  64107. */
  64108. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  64109. /**
  64110. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  64111. * @param start defines the start vector
  64112. * @param end defines the end vector
  64113. * @param amount defines the interpolation factor
  64114. * @returns a new Vector2
  64115. */
  64116. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  64117. /**
  64118. * Gets the dot product of the vector "left" and the vector "right"
  64119. * @param left defines first vector
  64120. * @param right defines second vector
  64121. * @returns the dot product (float)
  64122. */
  64123. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  64124. /**
  64125. * Returns a new Vector2 equal to the normalized given vector
  64126. * @param vector defines the vector to normalize
  64127. * @returns a new Vector2
  64128. */
  64129. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  64130. /**
  64131. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  64132. * @param left defines 1st vector
  64133. * @param right defines 2nd vector
  64134. * @returns a new Vector2
  64135. */
  64136. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  64137. /**
  64138. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  64139. * @param left defines 1st vector
  64140. * @param right defines 2nd vector
  64141. * @returns a new Vector2
  64142. */
  64143. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  64144. /**
  64145. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  64146. * @param vector defines the vector to transform
  64147. * @param transformation defines the matrix to apply
  64148. * @returns a new Vector2
  64149. */
  64150. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  64151. /**
  64152. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  64153. * @param vector defines the vector to transform
  64154. * @param transformation defines the matrix to apply
  64155. * @param result defines the target vector
  64156. */
  64157. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  64158. /**
  64159. * Determines if a given vector is included in a triangle
  64160. * @param p defines the vector to test
  64161. * @param p0 defines 1st triangle point
  64162. * @param p1 defines 2nd triangle point
  64163. * @param p2 defines 3rd triangle point
  64164. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  64165. */
  64166. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  64167. /**
  64168. * Gets the distance between the vectors "value1" and "value2"
  64169. * @param value1 defines first vector
  64170. * @param value2 defines second vector
  64171. * @returns the distance between vectors
  64172. */
  64173. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  64174. /**
  64175. * Returns the squared distance between the vectors "value1" and "value2"
  64176. * @param value1 defines first vector
  64177. * @param value2 defines second vector
  64178. * @returns the squared distance between vectors
  64179. */
  64180. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  64181. /**
  64182. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  64183. * @param value1 defines first vector
  64184. * @param value2 defines second vector
  64185. * @returns a new Vector2
  64186. */
  64187. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  64188. /**
  64189. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  64190. * @param p defines the middle point
  64191. * @param segA defines one point of the segment
  64192. * @param segB defines the other point of the segment
  64193. * @returns the shortest distance
  64194. */
  64195. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  64196. }
  64197. /**
  64198. * Classed used to store (x,y,z) vector representation
  64199. * A Vector3 is the main object used in 3D geometry
  64200. * It can represent etiher the coordinates of a point the space, either a direction
  64201. * Reminder: js uses a left handed forward facing system
  64202. */
  64203. export class Vector3 {
  64204. /**
  64205. * Defines the first coordinates (on X axis)
  64206. */
  64207. x: number;
  64208. /**
  64209. * Defines the second coordinates (on Y axis)
  64210. */
  64211. y: number;
  64212. /**
  64213. * Defines the third coordinates (on Z axis)
  64214. */
  64215. z: number;
  64216. private static _UpReadOnly;
  64217. private static _ZeroReadOnly;
  64218. /**
  64219. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  64220. * @param x defines the first coordinates (on X axis)
  64221. * @param y defines the second coordinates (on Y axis)
  64222. * @param z defines the third coordinates (on Z axis)
  64223. */
  64224. constructor(
  64225. /**
  64226. * Defines the first coordinates (on X axis)
  64227. */
  64228. x?: number,
  64229. /**
  64230. * Defines the second coordinates (on Y axis)
  64231. */
  64232. y?: number,
  64233. /**
  64234. * Defines the third coordinates (on Z axis)
  64235. */
  64236. z?: number);
  64237. /**
  64238. * Creates a string representation of the Vector3
  64239. * @returns a string with the Vector3 coordinates.
  64240. */
  64241. toString(): string;
  64242. /**
  64243. * Gets the class name
  64244. * @returns the string "Vector3"
  64245. */
  64246. getClassName(): string;
  64247. /**
  64248. * Creates the Vector3 hash code
  64249. * @returns a number which tends to be unique between Vector3 instances
  64250. */
  64251. getHashCode(): number;
  64252. /**
  64253. * Creates an array containing three elements : the coordinates of the Vector3
  64254. * @returns a new array of numbers
  64255. */
  64256. asArray(): number[];
  64257. /**
  64258. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  64259. * @param array defines the destination array
  64260. * @param index defines the offset in the destination array
  64261. * @returns the current Vector3
  64262. */
  64263. toArray(array: FloatArray, index?: number): Vector3;
  64264. /**
  64265. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  64266. * @returns a new Quaternion object, computed from the Vector3 coordinates
  64267. */
  64268. toQuaternion(): Quaternion;
  64269. /**
  64270. * Adds the given vector to the current Vector3
  64271. * @param otherVector defines the second operand
  64272. * @returns the current updated Vector3
  64273. */
  64274. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  64275. /**
  64276. * Adds the given coordinates to the current Vector3
  64277. * @param x defines the x coordinate of the operand
  64278. * @param y defines the y coordinate of the operand
  64279. * @param z defines the z coordinate of the operand
  64280. * @returns the current updated Vector3
  64281. */
  64282. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  64283. /**
  64284. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  64285. * @param otherVector defines the second operand
  64286. * @returns the resulting Vector3
  64287. */
  64288. add(otherVector: DeepImmutable<Vector3>): Vector3;
  64289. /**
  64290. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  64291. * @param otherVector defines the second operand
  64292. * @param result defines the Vector3 object where to store the result
  64293. * @returns the current Vector3
  64294. */
  64295. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  64296. /**
  64297. * Subtract the given vector from the current Vector3
  64298. * @param otherVector defines the second operand
  64299. * @returns the current updated Vector3
  64300. */
  64301. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  64302. /**
  64303. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  64304. * @param otherVector defines the second operand
  64305. * @returns the resulting Vector3
  64306. */
  64307. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  64308. /**
  64309. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  64310. * @param otherVector defines the second operand
  64311. * @param result defines the Vector3 object where to store the result
  64312. * @returns the current Vector3
  64313. */
  64314. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  64315. /**
  64316. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  64317. * @param x defines the x coordinate of the operand
  64318. * @param y defines the y coordinate of the operand
  64319. * @param z defines the z coordinate of the operand
  64320. * @returns the resulting Vector3
  64321. */
  64322. subtractFromFloats(x: number, y: number, z: number): Vector3;
  64323. /**
  64324. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  64325. * @param x defines the x coordinate of the operand
  64326. * @param y defines the y coordinate of the operand
  64327. * @param z defines the z coordinate of the operand
  64328. * @param result defines the Vector3 object where to store the result
  64329. * @returns the current Vector3
  64330. */
  64331. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  64332. /**
  64333. * Gets a new Vector3 set with the current Vector3 negated coordinates
  64334. * @returns a new Vector3
  64335. */
  64336. negate(): Vector3;
  64337. /**
  64338. * Multiplies the Vector3 coordinates by the float "scale"
  64339. * @param scale defines the multiplier factor
  64340. * @returns the current updated Vector3
  64341. */
  64342. scaleInPlace(scale: number): Vector3;
  64343. /**
  64344. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  64345. * @param scale defines the multiplier factor
  64346. * @returns a new Vector3
  64347. */
  64348. scale(scale: number): Vector3;
  64349. /**
  64350. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  64351. * @param scale defines the multiplier factor
  64352. * @param result defines the Vector3 object where to store the result
  64353. * @returns the current Vector3
  64354. */
  64355. scaleToRef(scale: number, result: Vector3): Vector3;
  64356. /**
  64357. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  64358. * @param scale defines the scale factor
  64359. * @param result defines the Vector3 object where to store the result
  64360. * @returns the unmodified current Vector3
  64361. */
  64362. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  64363. /**
  64364. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  64365. * @param otherVector defines the second operand
  64366. * @returns true if both vectors are equals
  64367. */
  64368. equals(otherVector: DeepImmutable<Vector3>): boolean;
  64369. /**
  64370. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  64371. * @param otherVector defines the second operand
  64372. * @param epsilon defines the minimal distance to define values as equals
  64373. * @returns true if both vectors are distant less than epsilon
  64374. */
  64375. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  64376. /**
  64377. * Returns true if the current Vector3 coordinates equals the given floats
  64378. * @param x defines the x coordinate of the operand
  64379. * @param y defines the y coordinate of the operand
  64380. * @param z defines the z coordinate of the operand
  64381. * @returns true if both vectors are equals
  64382. */
  64383. equalsToFloats(x: number, y: number, z: number): boolean;
  64384. /**
  64385. * Multiplies the current Vector3 coordinates by the given ones
  64386. * @param otherVector defines the second operand
  64387. * @returns the current updated Vector3
  64388. */
  64389. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  64390. /**
  64391. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  64392. * @param otherVector defines the second operand
  64393. * @returns the new Vector3
  64394. */
  64395. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  64396. /**
  64397. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  64398. * @param otherVector defines the second operand
  64399. * @param result defines the Vector3 object where to store the result
  64400. * @returns the current Vector3
  64401. */
  64402. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  64403. /**
  64404. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  64405. * @param x defines the x coordinate of the operand
  64406. * @param y defines the y coordinate of the operand
  64407. * @param z defines the z coordinate of the operand
  64408. * @returns the new Vector3
  64409. */
  64410. multiplyByFloats(x: number, y: number, z: number): Vector3;
  64411. /**
  64412. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  64413. * @param otherVector defines the second operand
  64414. * @returns the new Vector3
  64415. */
  64416. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  64417. /**
  64418. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  64419. * @param otherVector defines the second operand
  64420. * @param result defines the Vector3 object where to store the result
  64421. * @returns the current Vector3
  64422. */
  64423. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  64424. /**
  64425. * Divides the current Vector3 coordinates by the given ones.
  64426. * @param otherVector defines the second operand
  64427. * @returns the current updated Vector3
  64428. */
  64429. divideInPlace(otherVector: Vector3): Vector3;
  64430. /**
  64431. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  64432. * @param other defines the second operand
  64433. * @returns the current updated Vector3
  64434. */
  64435. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  64436. /**
  64437. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  64438. * @param other defines the second operand
  64439. * @returns the current updated Vector3
  64440. */
  64441. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  64442. /**
  64443. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  64444. * @param x defines the x coordinate of the operand
  64445. * @param y defines the y coordinate of the operand
  64446. * @param z defines the z coordinate of the operand
  64447. * @returns the current updated Vector3
  64448. */
  64449. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  64450. /**
  64451. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  64452. * @param x defines the x coordinate of the operand
  64453. * @param y defines the y coordinate of the operand
  64454. * @param z defines the z coordinate of the operand
  64455. * @returns the current updated Vector3
  64456. */
  64457. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  64458. /**
  64459. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  64460. * Check if is non uniform within a certain amount of decimal places to account for this
  64461. * @param epsilon the amount the values can differ
  64462. * @returns if the the vector is non uniform to a certain number of decimal places
  64463. */
  64464. isNonUniformWithinEpsilon(epsilon: number): boolean;
  64465. /**
  64466. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  64467. */
  64468. readonly isNonUniform: boolean;
  64469. /**
  64470. * Gets a new Vector3 from current Vector3 floored values
  64471. * @returns a new Vector3
  64472. */
  64473. floor(): Vector3;
  64474. /**
  64475. * Gets a new Vector3 from current Vector3 floored values
  64476. * @returns a new Vector3
  64477. */
  64478. fract(): Vector3;
  64479. /**
  64480. * Gets the length of the Vector3
  64481. * @returns the length of the Vector3
  64482. */
  64483. length(): number;
  64484. /**
  64485. * Gets the squared length of the Vector3
  64486. * @returns squared length of the Vector3
  64487. */
  64488. lengthSquared(): number;
  64489. /**
  64490. * Normalize the current Vector3.
  64491. * Please note that this is an in place operation.
  64492. * @returns the current updated Vector3
  64493. */
  64494. normalize(): Vector3;
  64495. /**
  64496. * Reorders the x y z properties of the vector in place
  64497. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  64498. * @returns the current updated vector
  64499. */
  64500. reorderInPlace(order: string): this;
  64501. /**
  64502. * Rotates the vector around 0,0,0 by a quaternion
  64503. * @param quaternion the rotation quaternion
  64504. * @param result vector to store the result
  64505. * @returns the resulting vector
  64506. */
  64507. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  64508. /**
  64509. * Rotates a vector around a given point
  64510. * @param quaternion the rotation quaternion
  64511. * @param point the point to rotate around
  64512. * @param result vector to store the result
  64513. * @returns the resulting vector
  64514. */
  64515. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  64516. /**
  64517. * Normalize the current Vector3 with the given input length.
  64518. * Please note that this is an in place operation.
  64519. * @param len the length of the vector
  64520. * @returns the current updated Vector3
  64521. */
  64522. normalizeFromLength(len: number): Vector3;
  64523. /**
  64524. * Normalize the current Vector3 to a new vector
  64525. * @returns the new Vector3
  64526. */
  64527. normalizeToNew(): Vector3;
  64528. /**
  64529. * Normalize the current Vector3 to the reference
  64530. * @param reference define the Vector3 to update
  64531. * @returns the updated Vector3
  64532. */
  64533. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  64534. /**
  64535. * Creates a new Vector3 copied from the current Vector3
  64536. * @returns the new Vector3
  64537. */
  64538. clone(): Vector3;
  64539. /**
  64540. * Copies the given vector coordinates to the current Vector3 ones
  64541. * @param source defines the source Vector3
  64542. * @returns the current updated Vector3
  64543. */
  64544. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  64545. /**
  64546. * Copies the given floats to the current Vector3 coordinates
  64547. * @param x defines the x coordinate of the operand
  64548. * @param y defines the y coordinate of the operand
  64549. * @param z defines the z coordinate of the operand
  64550. * @returns the current updated Vector3
  64551. */
  64552. copyFromFloats(x: number, y: number, z: number): Vector3;
  64553. /**
  64554. * Copies the given floats to the current Vector3 coordinates
  64555. * @param x defines the x coordinate of the operand
  64556. * @param y defines the y coordinate of the operand
  64557. * @param z defines the z coordinate of the operand
  64558. * @returns the current updated Vector3
  64559. */
  64560. set(x: number, y: number, z: number): Vector3;
  64561. /**
  64562. * Copies the given float to the current Vector3 coordinates
  64563. * @param v defines the x, y and z coordinates of the operand
  64564. * @returns the current updated Vector3
  64565. */
  64566. setAll(v: number): Vector3;
  64567. /**
  64568. * Get the clip factor between two vectors
  64569. * @param vector0 defines the first operand
  64570. * @param vector1 defines the second operand
  64571. * @param axis defines the axis to use
  64572. * @param size defines the size along the axis
  64573. * @returns the clip factor
  64574. */
  64575. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  64576. /**
  64577. * Get angle between two vectors
  64578. * @param vector0 angle between vector0 and vector1
  64579. * @param vector1 angle between vector0 and vector1
  64580. * @param normal direction of the normal
  64581. * @return the angle between vector0 and vector1
  64582. */
  64583. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  64584. /**
  64585. * Returns a new Vector3 set from the index "offset" of the given array
  64586. * @param array defines the source array
  64587. * @param offset defines the offset in the source array
  64588. * @returns the new Vector3
  64589. */
  64590. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  64591. /**
  64592. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  64593. * This function is deprecated. Use FromArray instead
  64594. * @param array defines the source array
  64595. * @param offset defines the offset in the source array
  64596. * @returns the new Vector3
  64597. */
  64598. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  64599. /**
  64600. * Sets the given vector "result" with the element values from the index "offset" of the given array
  64601. * @param array defines the source array
  64602. * @param offset defines the offset in the source array
  64603. * @param result defines the Vector3 where to store the result
  64604. */
  64605. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  64606. /**
  64607. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  64608. * This function is deprecated. Use FromArrayToRef instead.
  64609. * @param array defines the source array
  64610. * @param offset defines the offset in the source array
  64611. * @param result defines the Vector3 where to store the result
  64612. */
  64613. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  64614. /**
  64615. * Sets the given vector "result" with the given floats.
  64616. * @param x defines the x coordinate of the source
  64617. * @param y defines the y coordinate of the source
  64618. * @param z defines the z coordinate of the source
  64619. * @param result defines the Vector3 where to store the result
  64620. */
  64621. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  64622. /**
  64623. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  64624. * @returns a new empty Vector3
  64625. */
  64626. static Zero(): Vector3;
  64627. /**
  64628. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  64629. * @returns a new unit Vector3
  64630. */
  64631. static One(): Vector3;
  64632. /**
  64633. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  64634. * @returns a new up Vector3
  64635. */
  64636. static Up(): Vector3;
  64637. /**
  64638. * Gets a up Vector3 that must not be updated
  64639. */
  64640. static readonly UpReadOnly: DeepImmutable<Vector3>;
  64641. /**
  64642. * Gets a zero Vector3 that must not be updated
  64643. */
  64644. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  64645. /**
  64646. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  64647. * @returns a new down Vector3
  64648. */
  64649. static Down(): Vector3;
  64650. /**
  64651. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  64652. * @returns a new forward Vector3
  64653. */
  64654. static Forward(): Vector3;
  64655. /**
  64656. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  64657. * @returns a new forward Vector3
  64658. */
  64659. static Backward(): Vector3;
  64660. /**
  64661. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  64662. * @returns a new right Vector3
  64663. */
  64664. static Right(): Vector3;
  64665. /**
  64666. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  64667. * @returns a new left Vector3
  64668. */
  64669. static Left(): Vector3;
  64670. /**
  64671. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  64672. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  64673. * @param vector defines the Vector3 to transform
  64674. * @param transformation defines the transformation matrix
  64675. * @returns the transformed Vector3
  64676. */
  64677. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  64678. /**
  64679. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  64680. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  64681. * @param vector defines the Vector3 to transform
  64682. * @param transformation defines the transformation matrix
  64683. * @param result defines the Vector3 where to store the result
  64684. */
  64685. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64686. /**
  64687. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  64688. * This method computes tranformed coordinates only, not transformed direction vectors
  64689. * @param x define the x coordinate of the source vector
  64690. * @param y define the y coordinate of the source vector
  64691. * @param z define the z coordinate of the source vector
  64692. * @param transformation defines the transformation matrix
  64693. * @param result defines the Vector3 where to store the result
  64694. */
  64695. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64696. /**
  64697. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  64698. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64699. * @param vector defines the Vector3 to transform
  64700. * @param transformation defines the transformation matrix
  64701. * @returns the new Vector3
  64702. */
  64703. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  64704. /**
  64705. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  64706. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64707. * @param vector defines the Vector3 to transform
  64708. * @param transformation defines the transformation matrix
  64709. * @param result defines the Vector3 where to store the result
  64710. */
  64711. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64712. /**
  64713. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  64714. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64715. * @param x define the x coordinate of the source vector
  64716. * @param y define the y coordinate of the source vector
  64717. * @param z define the z coordinate of the source vector
  64718. * @param transformation defines the transformation matrix
  64719. * @param result defines the Vector3 where to store the result
  64720. */
  64721. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64722. /**
  64723. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  64724. * @param value1 defines the first control point
  64725. * @param value2 defines the second control point
  64726. * @param value3 defines the third control point
  64727. * @param value4 defines the fourth control point
  64728. * @param amount defines the amount on the spline to use
  64729. * @returns the new Vector3
  64730. */
  64731. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  64732. /**
  64733. * 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"
  64734. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  64735. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  64736. * @param value defines the current value
  64737. * @param min defines the lower range value
  64738. * @param max defines the upper range value
  64739. * @returns the new Vector3
  64740. */
  64741. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  64742. /**
  64743. * 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"
  64744. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  64745. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  64746. * @param value defines the current value
  64747. * @param min defines the lower range value
  64748. * @param max defines the upper range value
  64749. * @param result defines the Vector3 where to store the result
  64750. */
  64751. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  64752. /**
  64753. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  64754. * @param value1 defines the first control point
  64755. * @param tangent1 defines the first tangent vector
  64756. * @param value2 defines the second control point
  64757. * @param tangent2 defines the second tangent vector
  64758. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  64759. * @returns the new Vector3
  64760. */
  64761. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  64762. /**
  64763. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  64764. * @param start defines the start value
  64765. * @param end defines the end value
  64766. * @param amount max defines amount between both (between 0 and 1)
  64767. * @returns the new Vector3
  64768. */
  64769. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  64770. /**
  64771. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  64772. * @param start defines the start value
  64773. * @param end defines the end value
  64774. * @param amount max defines amount between both (between 0 and 1)
  64775. * @param result defines the Vector3 where to store the result
  64776. */
  64777. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  64778. /**
  64779. * Returns the dot product (float) between the vectors "left" and "right"
  64780. * @param left defines the left operand
  64781. * @param right defines the right operand
  64782. * @returns the dot product
  64783. */
  64784. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  64785. /**
  64786. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  64787. * The cross product is then orthogonal to both "left" and "right"
  64788. * @param left defines the left operand
  64789. * @param right defines the right operand
  64790. * @returns the cross product
  64791. */
  64792. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64793. /**
  64794. * Sets the given vector "result" with the cross product of "left" and "right"
  64795. * The cross product is then orthogonal to both "left" and "right"
  64796. * @param left defines the left operand
  64797. * @param right defines the right operand
  64798. * @param result defines the Vector3 where to store the result
  64799. */
  64800. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  64801. /**
  64802. * Returns a new Vector3 as the normalization of the given vector
  64803. * @param vector defines the Vector3 to normalize
  64804. * @returns the new Vector3
  64805. */
  64806. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  64807. /**
  64808. * Sets the given vector "result" with the normalization of the given first vector
  64809. * @param vector defines the Vector3 to normalize
  64810. * @param result defines the Vector3 where to store the result
  64811. */
  64812. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  64813. /**
  64814. * Project a Vector3 onto screen space
  64815. * @param vector defines the Vector3 to project
  64816. * @param world defines the world matrix to use
  64817. * @param transform defines the transform (view x projection) matrix to use
  64818. * @param viewport defines the screen viewport to use
  64819. * @returns the new Vector3
  64820. */
  64821. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  64822. /** @hidden */
  64823. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  64824. /**
  64825. * Unproject from screen space to object space
  64826. * @param source defines the screen space Vector3 to use
  64827. * @param viewportWidth defines the current width of the viewport
  64828. * @param viewportHeight defines the current height of the viewport
  64829. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64830. * @param transform defines the transform (view x projection) matrix to use
  64831. * @returns the new Vector3
  64832. */
  64833. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  64834. /**
  64835. * Unproject from screen space to object space
  64836. * @param source defines the screen space Vector3 to use
  64837. * @param viewportWidth defines the current width of the viewport
  64838. * @param viewportHeight defines the current height of the viewport
  64839. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64840. * @param view defines the view matrix to use
  64841. * @param projection defines the projection matrix to use
  64842. * @returns the new Vector3
  64843. */
  64844. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  64845. /**
  64846. * Unproject from screen space to object space
  64847. * @param source defines the screen space Vector3 to use
  64848. * @param viewportWidth defines the current width of the viewport
  64849. * @param viewportHeight defines the current height of the viewport
  64850. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64851. * @param view defines the view matrix to use
  64852. * @param projection defines the projection matrix to use
  64853. * @param result defines the Vector3 where to store the result
  64854. */
  64855. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  64856. /**
  64857. * Unproject from screen space to object space
  64858. * @param sourceX defines the screen space x coordinate to use
  64859. * @param sourceY defines the screen space y coordinate to use
  64860. * @param sourceZ defines the screen space z coordinate to use
  64861. * @param viewportWidth defines the current width of the viewport
  64862. * @param viewportHeight defines the current height of the viewport
  64863. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64864. * @param view defines the view matrix to use
  64865. * @param projection defines the projection matrix to use
  64866. * @param result defines the Vector3 where to store the result
  64867. */
  64868. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  64869. /**
  64870. * Gets the minimal coordinate values between two Vector3
  64871. * @param left defines the first operand
  64872. * @param right defines the second operand
  64873. * @returns the new Vector3
  64874. */
  64875. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64876. /**
  64877. * Gets the maximal coordinate values between two Vector3
  64878. * @param left defines the first operand
  64879. * @param right defines the second operand
  64880. * @returns the new Vector3
  64881. */
  64882. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64883. /**
  64884. * Returns the distance between the vectors "value1" and "value2"
  64885. * @param value1 defines the first operand
  64886. * @param value2 defines the second operand
  64887. * @returns the distance
  64888. */
  64889. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  64890. /**
  64891. * Returns the squared distance between the vectors "value1" and "value2"
  64892. * @param value1 defines the first operand
  64893. * @param value2 defines the second operand
  64894. * @returns the squared distance
  64895. */
  64896. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  64897. /**
  64898. * Returns a new Vector3 located at the center between "value1" and "value2"
  64899. * @param value1 defines the first operand
  64900. * @param value2 defines the second operand
  64901. * @returns the new Vector3
  64902. */
  64903. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  64904. /**
  64905. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  64906. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  64907. * to something in order to rotate it from its local system to the given target system
  64908. * Note: axis1, axis2 and axis3 are normalized during this operation
  64909. * @param axis1 defines the first axis
  64910. * @param axis2 defines the second axis
  64911. * @param axis3 defines the third axis
  64912. * @returns a new Vector3
  64913. */
  64914. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  64915. /**
  64916. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  64917. * @param axis1 defines the first axis
  64918. * @param axis2 defines the second axis
  64919. * @param axis3 defines the third axis
  64920. * @param ref defines the Vector3 where to store the result
  64921. */
  64922. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  64923. }
  64924. /**
  64925. * Vector4 class created for EulerAngle class conversion to Quaternion
  64926. */
  64927. export class Vector4 {
  64928. /** x value of the vector */
  64929. x: number;
  64930. /** y value of the vector */
  64931. y: number;
  64932. /** z value of the vector */
  64933. z: number;
  64934. /** w value of the vector */
  64935. w: number;
  64936. /**
  64937. * Creates a Vector4 object from the given floats.
  64938. * @param x x value of the vector
  64939. * @param y y value of the vector
  64940. * @param z z value of the vector
  64941. * @param w w value of the vector
  64942. */
  64943. constructor(
  64944. /** x value of the vector */
  64945. x: number,
  64946. /** y value of the vector */
  64947. y: number,
  64948. /** z value of the vector */
  64949. z: number,
  64950. /** w value of the vector */
  64951. w: number);
  64952. /**
  64953. * Returns the string with the Vector4 coordinates.
  64954. * @returns a string containing all the vector values
  64955. */
  64956. toString(): string;
  64957. /**
  64958. * Returns the string "Vector4".
  64959. * @returns "Vector4"
  64960. */
  64961. getClassName(): string;
  64962. /**
  64963. * Returns the Vector4 hash code.
  64964. * @returns a unique hash code
  64965. */
  64966. getHashCode(): number;
  64967. /**
  64968. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  64969. * @returns the resulting array
  64970. */
  64971. asArray(): number[];
  64972. /**
  64973. * Populates the given array from the given index with the Vector4 coordinates.
  64974. * @param array array to populate
  64975. * @param index index of the array to start at (default: 0)
  64976. * @returns the Vector4.
  64977. */
  64978. toArray(array: FloatArray, index?: number): Vector4;
  64979. /**
  64980. * Adds the given vector to the current Vector4.
  64981. * @param otherVector the vector to add
  64982. * @returns the updated Vector4.
  64983. */
  64984. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64985. /**
  64986. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  64987. * @param otherVector the vector to add
  64988. * @returns the resulting vector
  64989. */
  64990. add(otherVector: DeepImmutable<Vector4>): Vector4;
  64991. /**
  64992. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  64993. * @param otherVector the vector to add
  64994. * @param result the vector to store the result
  64995. * @returns the current Vector4.
  64996. */
  64997. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64998. /**
  64999. * Subtract in place the given vector from the current Vector4.
  65000. * @param otherVector the vector to subtract
  65001. * @returns the updated Vector4.
  65002. */
  65003. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  65004. /**
  65005. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  65006. * @param otherVector the vector to add
  65007. * @returns the new vector with the result
  65008. */
  65009. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  65010. /**
  65011. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  65012. * @param otherVector the vector to subtract
  65013. * @param result the vector to store the result
  65014. * @returns the current Vector4.
  65015. */
  65016. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  65017. /**
  65018. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  65019. */
  65020. /**
  65021. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  65022. * @param x value to subtract
  65023. * @param y value to subtract
  65024. * @param z value to subtract
  65025. * @param w value to subtract
  65026. * @returns new vector containing the result
  65027. */
  65028. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  65029. /**
  65030. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  65031. * @param x value to subtract
  65032. * @param y value to subtract
  65033. * @param z value to subtract
  65034. * @param w value to subtract
  65035. * @param result the vector to store the result in
  65036. * @returns the current Vector4.
  65037. */
  65038. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  65039. /**
  65040. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  65041. * @returns a new vector with the negated values
  65042. */
  65043. negate(): Vector4;
  65044. /**
  65045. * Multiplies the current Vector4 coordinates by scale (float).
  65046. * @param scale the number to scale with
  65047. * @returns the updated Vector4.
  65048. */
  65049. scaleInPlace(scale: number): Vector4;
  65050. /**
  65051. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  65052. * @param scale the number to scale with
  65053. * @returns a new vector with the result
  65054. */
  65055. scale(scale: number): Vector4;
  65056. /**
  65057. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  65058. * @param scale the number to scale with
  65059. * @param result a vector to store the result in
  65060. * @returns the current Vector4.
  65061. */
  65062. scaleToRef(scale: number, result: Vector4): Vector4;
  65063. /**
  65064. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  65065. * @param scale defines the scale factor
  65066. * @param result defines the Vector4 object where to store the result
  65067. * @returns the unmodified current Vector4
  65068. */
  65069. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  65070. /**
  65071. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  65072. * @param otherVector the vector to compare against
  65073. * @returns true if they are equal
  65074. */
  65075. equals(otherVector: DeepImmutable<Vector4>): boolean;
  65076. /**
  65077. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  65078. * @param otherVector vector to compare against
  65079. * @param epsilon (Default: very small number)
  65080. * @returns true if they are equal
  65081. */
  65082. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  65083. /**
  65084. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  65085. * @param x x value to compare against
  65086. * @param y y value to compare against
  65087. * @param z z value to compare against
  65088. * @param w w value to compare against
  65089. * @returns true if equal
  65090. */
  65091. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  65092. /**
  65093. * Multiplies in place the current Vector4 by the given one.
  65094. * @param otherVector vector to multiple with
  65095. * @returns the updated Vector4.
  65096. */
  65097. multiplyInPlace(otherVector: Vector4): Vector4;
  65098. /**
  65099. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  65100. * @param otherVector vector to multiple with
  65101. * @returns resulting new vector
  65102. */
  65103. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  65104. /**
  65105. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  65106. * @param otherVector vector to multiple with
  65107. * @param result vector to store the result
  65108. * @returns the current Vector4.
  65109. */
  65110. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  65111. /**
  65112. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  65113. * @param x x value multiply with
  65114. * @param y y value multiply with
  65115. * @param z z value multiply with
  65116. * @param w w value multiply with
  65117. * @returns resulting new vector
  65118. */
  65119. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  65120. /**
  65121. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  65122. * @param otherVector vector to devide with
  65123. * @returns resulting new vector
  65124. */
  65125. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  65126. /**
  65127. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  65128. * @param otherVector vector to devide with
  65129. * @param result vector to store the result
  65130. * @returns the current Vector4.
  65131. */
  65132. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  65133. /**
  65134. * Divides the current Vector3 coordinates by the given ones.
  65135. * @param otherVector vector to devide with
  65136. * @returns the updated Vector3.
  65137. */
  65138. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  65139. /**
  65140. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  65141. * @param other defines the second operand
  65142. * @returns the current updated Vector4
  65143. */
  65144. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  65145. /**
  65146. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  65147. * @param other defines the second operand
  65148. * @returns the current updated Vector4
  65149. */
  65150. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  65151. /**
  65152. * Gets a new Vector4 from current Vector4 floored values
  65153. * @returns a new Vector4
  65154. */
  65155. floor(): Vector4;
  65156. /**
  65157. * Gets a new Vector4 from current Vector3 floored values
  65158. * @returns a new Vector4
  65159. */
  65160. fract(): Vector4;
  65161. /**
  65162. * Returns the Vector4 length (float).
  65163. * @returns the length
  65164. */
  65165. length(): number;
  65166. /**
  65167. * Returns the Vector4 squared length (float).
  65168. * @returns the length squared
  65169. */
  65170. lengthSquared(): number;
  65171. /**
  65172. * Normalizes in place the Vector4.
  65173. * @returns the updated Vector4.
  65174. */
  65175. normalize(): Vector4;
  65176. /**
  65177. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  65178. * @returns this converted to a new vector3
  65179. */
  65180. toVector3(): Vector3;
  65181. /**
  65182. * Returns a new Vector4 copied from the current one.
  65183. * @returns the new cloned vector
  65184. */
  65185. clone(): Vector4;
  65186. /**
  65187. * Updates the current Vector4 with the given one coordinates.
  65188. * @param source the source vector to copy from
  65189. * @returns the updated Vector4.
  65190. */
  65191. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  65192. /**
  65193. * Updates the current Vector4 coordinates with the given floats.
  65194. * @param x float to copy from
  65195. * @param y float to copy from
  65196. * @param z float to copy from
  65197. * @param w float to copy from
  65198. * @returns the updated Vector4.
  65199. */
  65200. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  65201. /**
  65202. * Updates the current Vector4 coordinates with the given floats.
  65203. * @param x float to set from
  65204. * @param y float to set from
  65205. * @param z float to set from
  65206. * @param w float to set from
  65207. * @returns the updated Vector4.
  65208. */
  65209. set(x: number, y: number, z: number, w: number): Vector4;
  65210. /**
  65211. * Copies the given float to the current Vector3 coordinates
  65212. * @param v defines the x, y, z and w coordinates of the operand
  65213. * @returns the current updated Vector3
  65214. */
  65215. setAll(v: number): Vector4;
  65216. /**
  65217. * Returns a new Vector4 set from the starting index of the given array.
  65218. * @param array the array to pull values from
  65219. * @param offset the offset into the array to start at
  65220. * @returns the new vector
  65221. */
  65222. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  65223. /**
  65224. * Updates the given vector "result" from the starting index of the given array.
  65225. * @param array the array to pull values from
  65226. * @param offset the offset into the array to start at
  65227. * @param result the vector to store the result in
  65228. */
  65229. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  65230. /**
  65231. * Updates the given vector "result" from the starting index of the given Float32Array.
  65232. * @param array the array to pull values from
  65233. * @param offset the offset into the array to start at
  65234. * @param result the vector to store the result in
  65235. */
  65236. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  65237. /**
  65238. * Updates the given vector "result" coordinates from the given floats.
  65239. * @param x float to set from
  65240. * @param y float to set from
  65241. * @param z float to set from
  65242. * @param w float to set from
  65243. * @param result the vector to the floats in
  65244. */
  65245. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  65246. /**
  65247. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  65248. * @returns the new vector
  65249. */
  65250. static Zero(): Vector4;
  65251. /**
  65252. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  65253. * @returns the new vector
  65254. */
  65255. static One(): Vector4;
  65256. /**
  65257. * Returns a new normalized Vector4 from the given one.
  65258. * @param vector the vector to normalize
  65259. * @returns the vector
  65260. */
  65261. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  65262. /**
  65263. * Updates the given vector "result" from the normalization of the given one.
  65264. * @param vector the vector to normalize
  65265. * @param result the vector to store the result in
  65266. */
  65267. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  65268. /**
  65269. * Returns a vector with the minimum values from the left and right vectors
  65270. * @param left left vector to minimize
  65271. * @param right right vector to minimize
  65272. * @returns a new vector with the minimum of the left and right vector values
  65273. */
  65274. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  65275. /**
  65276. * Returns a vector with the maximum values from the left and right vectors
  65277. * @param left left vector to maximize
  65278. * @param right right vector to maximize
  65279. * @returns a new vector with the maximum of the left and right vector values
  65280. */
  65281. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  65282. /**
  65283. * Returns the distance (float) between the vectors "value1" and "value2".
  65284. * @param value1 value to calulate the distance between
  65285. * @param value2 value to calulate the distance between
  65286. * @return the distance between the two vectors
  65287. */
  65288. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  65289. /**
  65290. * Returns the squared distance (float) between the vectors "value1" and "value2".
  65291. * @param value1 value to calulate the distance between
  65292. * @param value2 value to calulate the distance between
  65293. * @return the distance between the two vectors squared
  65294. */
  65295. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  65296. /**
  65297. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  65298. * @param value1 value to calulate the center between
  65299. * @param value2 value to calulate the center between
  65300. * @return the center between the two vectors
  65301. */
  65302. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  65303. /**
  65304. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  65305. * This methods computes transformed normalized direction vectors only.
  65306. * @param vector the vector to transform
  65307. * @param transformation the transformation matrix to apply
  65308. * @returns the new vector
  65309. */
  65310. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  65311. /**
  65312. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  65313. * This methods computes transformed normalized direction vectors only.
  65314. * @param vector the vector to transform
  65315. * @param transformation the transformation matrix to apply
  65316. * @param result the vector to store the result in
  65317. */
  65318. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  65319. /**
  65320. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  65321. * This methods computes transformed normalized direction vectors only.
  65322. * @param x value to transform
  65323. * @param y value to transform
  65324. * @param z value to transform
  65325. * @param w value to transform
  65326. * @param transformation the transformation matrix to apply
  65327. * @param result the vector to store the results in
  65328. */
  65329. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  65330. /**
  65331. * Creates a new Vector4 from a Vector3
  65332. * @param source defines the source data
  65333. * @param w defines the 4th component (default is 0)
  65334. * @returns a new Vector4
  65335. */
  65336. static FromVector3(source: Vector3, w?: number): Vector4;
  65337. }
  65338. /**
  65339. * Interface for the size containing width and height
  65340. */
  65341. export interface ISize {
  65342. /**
  65343. * Width
  65344. */
  65345. width: number;
  65346. /**
  65347. * Heighht
  65348. */
  65349. height: number;
  65350. }
  65351. /**
  65352. * Size containing widht and height
  65353. */
  65354. export class Size implements ISize {
  65355. /**
  65356. * Width
  65357. */
  65358. width: number;
  65359. /**
  65360. * Height
  65361. */
  65362. height: number;
  65363. /**
  65364. * Creates a Size object from the given width and height (floats).
  65365. * @param width width of the new size
  65366. * @param height height of the new size
  65367. */
  65368. constructor(width: number, height: number);
  65369. /**
  65370. * Returns a string with the Size width and height
  65371. * @returns a string with the Size width and height
  65372. */
  65373. toString(): string;
  65374. /**
  65375. * "Size"
  65376. * @returns the string "Size"
  65377. */
  65378. getClassName(): string;
  65379. /**
  65380. * Returns the Size hash code.
  65381. * @returns a hash code for a unique width and height
  65382. */
  65383. getHashCode(): number;
  65384. /**
  65385. * Updates the current size from the given one.
  65386. * @param src the given size
  65387. */
  65388. copyFrom(src: Size): void;
  65389. /**
  65390. * Updates in place the current Size from the given floats.
  65391. * @param width width of the new size
  65392. * @param height height of the new size
  65393. * @returns the updated Size.
  65394. */
  65395. copyFromFloats(width: number, height: number): Size;
  65396. /**
  65397. * Updates in place the current Size from the given floats.
  65398. * @param width width to set
  65399. * @param height height to set
  65400. * @returns the updated Size.
  65401. */
  65402. set(width: number, height: number): Size;
  65403. /**
  65404. * Multiplies the width and height by numbers
  65405. * @param w factor to multiple the width by
  65406. * @param h factor to multiple the height by
  65407. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  65408. */
  65409. multiplyByFloats(w: number, h: number): Size;
  65410. /**
  65411. * Clones the size
  65412. * @returns a new Size copied from the given one.
  65413. */
  65414. clone(): Size;
  65415. /**
  65416. * True if the current Size and the given one width and height are strictly equal.
  65417. * @param other the other size to compare against
  65418. * @returns True if the current Size and the given one width and height are strictly equal.
  65419. */
  65420. equals(other: Size): boolean;
  65421. /**
  65422. * The surface of the Size : width * height (float).
  65423. */
  65424. readonly surface: number;
  65425. /**
  65426. * Create a new size of zero
  65427. * @returns a new Size set to (0.0, 0.0)
  65428. */
  65429. static Zero(): Size;
  65430. /**
  65431. * Sums the width and height of two sizes
  65432. * @param otherSize size to add to this size
  65433. * @returns a new Size set as the addition result of the current Size and the given one.
  65434. */
  65435. add(otherSize: Size): Size;
  65436. /**
  65437. * Subtracts the width and height of two
  65438. * @param otherSize size to subtract to this size
  65439. * @returns a new Size set as the subtraction result of the given one from the current Size.
  65440. */
  65441. subtract(otherSize: Size): Size;
  65442. /**
  65443. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  65444. * @param start starting size to lerp between
  65445. * @param end end size to lerp between
  65446. * @param amount amount to lerp between the start and end values
  65447. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  65448. */
  65449. static Lerp(start: Size, end: Size, amount: number): Size;
  65450. }
  65451. /**
  65452. * Class used to store quaternion data
  65453. * @see https://en.wikipedia.org/wiki/Quaternion
  65454. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  65455. */
  65456. export class Quaternion {
  65457. /** defines the first component (0 by default) */
  65458. x: number;
  65459. /** defines the second component (0 by default) */
  65460. y: number;
  65461. /** defines the third component (0 by default) */
  65462. z: number;
  65463. /** defines the fourth component (1.0 by default) */
  65464. w: number;
  65465. /**
  65466. * Creates a new Quaternion from the given floats
  65467. * @param x defines the first component (0 by default)
  65468. * @param y defines the second component (0 by default)
  65469. * @param z defines the third component (0 by default)
  65470. * @param w defines the fourth component (1.0 by default)
  65471. */
  65472. constructor(
  65473. /** defines the first component (0 by default) */
  65474. x?: number,
  65475. /** defines the second component (0 by default) */
  65476. y?: number,
  65477. /** defines the third component (0 by default) */
  65478. z?: number,
  65479. /** defines the fourth component (1.0 by default) */
  65480. w?: number);
  65481. /**
  65482. * Gets a string representation for the current quaternion
  65483. * @returns a string with the Quaternion coordinates
  65484. */
  65485. toString(): string;
  65486. /**
  65487. * Gets the class name of the quaternion
  65488. * @returns the string "Quaternion"
  65489. */
  65490. getClassName(): string;
  65491. /**
  65492. * Gets a hash code for this quaternion
  65493. * @returns the quaternion hash code
  65494. */
  65495. getHashCode(): number;
  65496. /**
  65497. * Copy the quaternion to an array
  65498. * @returns a new array populated with 4 elements from the quaternion coordinates
  65499. */
  65500. asArray(): number[];
  65501. /**
  65502. * Check if two quaternions are equals
  65503. * @param otherQuaternion defines the second operand
  65504. * @return true if the current quaternion and the given one coordinates are strictly equals
  65505. */
  65506. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  65507. /**
  65508. * Clone the current quaternion
  65509. * @returns a new quaternion copied from the current one
  65510. */
  65511. clone(): Quaternion;
  65512. /**
  65513. * Copy a quaternion to the current one
  65514. * @param other defines the other quaternion
  65515. * @returns the updated current quaternion
  65516. */
  65517. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  65518. /**
  65519. * Updates the current quaternion with the given float coordinates
  65520. * @param x defines the x coordinate
  65521. * @param y defines the y coordinate
  65522. * @param z defines the z coordinate
  65523. * @param w defines the w coordinate
  65524. * @returns the updated current quaternion
  65525. */
  65526. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  65527. /**
  65528. * Updates the current quaternion from the given float coordinates
  65529. * @param x defines the x coordinate
  65530. * @param y defines the y coordinate
  65531. * @param z defines the z coordinate
  65532. * @param w defines the w coordinate
  65533. * @returns the updated current quaternion
  65534. */
  65535. set(x: number, y: number, z: number, w: number): Quaternion;
  65536. /**
  65537. * Adds two quaternions
  65538. * @param other defines the second operand
  65539. * @returns a new quaternion as the addition result of the given one and the current quaternion
  65540. */
  65541. add(other: DeepImmutable<Quaternion>): Quaternion;
  65542. /**
  65543. * Add a quaternion to the current one
  65544. * @param other defines the quaternion to add
  65545. * @returns the current quaternion
  65546. */
  65547. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  65548. /**
  65549. * Subtract two quaternions
  65550. * @param other defines the second operand
  65551. * @returns a new quaternion as the subtraction result of the given one from the current one
  65552. */
  65553. subtract(other: Quaternion): Quaternion;
  65554. /**
  65555. * Multiplies the current quaternion by a scale factor
  65556. * @param value defines the scale factor
  65557. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  65558. */
  65559. scale(value: number): Quaternion;
  65560. /**
  65561. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  65562. * @param scale defines the scale factor
  65563. * @param result defines the Quaternion object where to store the result
  65564. * @returns the unmodified current quaternion
  65565. */
  65566. scaleToRef(scale: number, result: Quaternion): Quaternion;
  65567. /**
  65568. * Multiplies in place the current quaternion by a scale factor
  65569. * @param value defines the scale factor
  65570. * @returns the current modified quaternion
  65571. */
  65572. scaleInPlace(value: number): Quaternion;
  65573. /**
  65574. * Scale the current quaternion values by a factor and add the result to a given quaternion
  65575. * @param scale defines the scale factor
  65576. * @param result defines the Quaternion object where to store the result
  65577. * @returns the unmodified current quaternion
  65578. */
  65579. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  65580. /**
  65581. * Multiplies two quaternions
  65582. * @param q1 defines the second operand
  65583. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  65584. */
  65585. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  65586. /**
  65587. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  65588. * @param q1 defines the second operand
  65589. * @param result defines the target quaternion
  65590. * @returns the current quaternion
  65591. */
  65592. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  65593. /**
  65594. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  65595. * @param q1 defines the second operand
  65596. * @returns the currentupdated quaternion
  65597. */
  65598. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  65599. /**
  65600. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  65601. * @param ref defines the target quaternion
  65602. * @returns the current quaternion
  65603. */
  65604. conjugateToRef(ref: Quaternion): Quaternion;
  65605. /**
  65606. * Conjugates in place (1-q) the current quaternion
  65607. * @returns the current updated quaternion
  65608. */
  65609. conjugateInPlace(): Quaternion;
  65610. /**
  65611. * Conjugates in place (1-q) the current quaternion
  65612. * @returns a new quaternion
  65613. */
  65614. conjugate(): Quaternion;
  65615. /**
  65616. * Gets length of current quaternion
  65617. * @returns the quaternion length (float)
  65618. */
  65619. length(): number;
  65620. /**
  65621. * Normalize in place the current quaternion
  65622. * @returns the current updated quaternion
  65623. */
  65624. normalize(): Quaternion;
  65625. /**
  65626. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  65627. * @param order is a reserved parameter and is ignore for now
  65628. * @returns a new Vector3 containing the Euler angles
  65629. */
  65630. toEulerAngles(order?: string): Vector3;
  65631. /**
  65632. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  65633. * @param result defines the vector which will be filled with the Euler angles
  65634. * @param order is a reserved parameter and is ignore for now
  65635. * @returns the current unchanged quaternion
  65636. */
  65637. toEulerAnglesToRef(result: Vector3): Quaternion;
  65638. /**
  65639. * Updates the given rotation matrix with the current quaternion values
  65640. * @param result defines the target matrix
  65641. * @returns the current unchanged quaternion
  65642. */
  65643. toRotationMatrix(result: Matrix): Quaternion;
  65644. /**
  65645. * Updates the current quaternion from the given rotation matrix values
  65646. * @param matrix defines the source matrix
  65647. * @returns the current updated quaternion
  65648. */
  65649. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  65650. /**
  65651. * Creates a new quaternion from a rotation matrix
  65652. * @param matrix defines the source matrix
  65653. * @returns a new quaternion created from the given rotation matrix values
  65654. */
  65655. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  65656. /**
  65657. * Updates the given quaternion with the given rotation matrix values
  65658. * @param matrix defines the source matrix
  65659. * @param result defines the target quaternion
  65660. */
  65661. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  65662. /**
  65663. * Returns the dot product (float) between the quaternions "left" and "right"
  65664. * @param left defines the left operand
  65665. * @param right defines the right operand
  65666. * @returns the dot product
  65667. */
  65668. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  65669. /**
  65670. * Checks if the two quaternions are close to each other
  65671. * @param quat0 defines the first quaternion to check
  65672. * @param quat1 defines the second quaternion to check
  65673. * @returns true if the two quaternions are close to each other
  65674. */
  65675. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  65676. /**
  65677. * Creates an empty quaternion
  65678. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  65679. */
  65680. static Zero(): Quaternion;
  65681. /**
  65682. * Inverse a given quaternion
  65683. * @param q defines the source quaternion
  65684. * @returns a new quaternion as the inverted current quaternion
  65685. */
  65686. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  65687. /**
  65688. * Inverse a given quaternion
  65689. * @param q defines the source quaternion
  65690. * @param result the quaternion the result will be stored in
  65691. * @returns the result quaternion
  65692. */
  65693. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  65694. /**
  65695. * Creates an identity quaternion
  65696. * @returns the identity quaternion
  65697. */
  65698. static Identity(): Quaternion;
  65699. /**
  65700. * Gets a boolean indicating if the given quaternion is identity
  65701. * @param quaternion defines the quaternion to check
  65702. * @returns true if the quaternion is identity
  65703. */
  65704. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  65705. /**
  65706. * Creates a quaternion from a rotation around an axis
  65707. * @param axis defines the axis to use
  65708. * @param angle defines the angle to use
  65709. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  65710. */
  65711. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  65712. /**
  65713. * Creates a rotation around an axis and stores it into the given quaternion
  65714. * @param axis defines the axis to use
  65715. * @param angle defines the angle to use
  65716. * @param result defines the target quaternion
  65717. * @returns the target quaternion
  65718. */
  65719. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  65720. /**
  65721. * Creates a new quaternion from data stored into an array
  65722. * @param array defines the data source
  65723. * @param offset defines the offset in the source array where the data starts
  65724. * @returns a new quaternion
  65725. */
  65726. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  65727. /**
  65728. * Create a quaternion from Euler rotation angles
  65729. * @param x Pitch
  65730. * @param y Yaw
  65731. * @param z Roll
  65732. * @returns the new Quaternion
  65733. */
  65734. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  65735. /**
  65736. * Updates a quaternion from Euler rotation angles
  65737. * @param x Pitch
  65738. * @param y Yaw
  65739. * @param z Roll
  65740. * @param result the quaternion to store the result
  65741. * @returns the updated quaternion
  65742. */
  65743. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  65744. /**
  65745. * Create a quaternion from Euler rotation vector
  65746. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  65747. * @returns the new Quaternion
  65748. */
  65749. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  65750. /**
  65751. * Updates a quaternion from Euler rotation vector
  65752. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  65753. * @param result the quaternion to store the result
  65754. * @returns the updated quaternion
  65755. */
  65756. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  65757. /**
  65758. * Creates a new quaternion from the given Euler float angles (y, x, z)
  65759. * @param yaw defines the rotation around Y axis
  65760. * @param pitch defines the rotation around X axis
  65761. * @param roll defines the rotation around Z axis
  65762. * @returns the new quaternion
  65763. */
  65764. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  65765. /**
  65766. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  65767. * @param yaw defines the rotation around Y axis
  65768. * @param pitch defines the rotation around X axis
  65769. * @param roll defines the rotation around Z axis
  65770. * @param result defines the target quaternion
  65771. */
  65772. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  65773. /**
  65774. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  65775. * @param alpha defines the rotation around first axis
  65776. * @param beta defines the rotation around second axis
  65777. * @param gamma defines the rotation around third axis
  65778. * @returns the new quaternion
  65779. */
  65780. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  65781. /**
  65782. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  65783. * @param alpha defines the rotation around first axis
  65784. * @param beta defines the rotation around second axis
  65785. * @param gamma defines the rotation around third axis
  65786. * @param result defines the target quaternion
  65787. */
  65788. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  65789. /**
  65790. * 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)
  65791. * @param axis1 defines the first axis
  65792. * @param axis2 defines the second axis
  65793. * @param axis3 defines the third axis
  65794. * @returns the new quaternion
  65795. */
  65796. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  65797. /**
  65798. * 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
  65799. * @param axis1 defines the first axis
  65800. * @param axis2 defines the second axis
  65801. * @param axis3 defines the third axis
  65802. * @param ref defines the target quaternion
  65803. */
  65804. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  65805. /**
  65806. * Interpolates between two quaternions
  65807. * @param left defines first quaternion
  65808. * @param right defines second quaternion
  65809. * @param amount defines the gradient to use
  65810. * @returns the new interpolated quaternion
  65811. */
  65812. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  65813. /**
  65814. * Interpolates between two quaternions and stores it into a target quaternion
  65815. * @param left defines first quaternion
  65816. * @param right defines second quaternion
  65817. * @param amount defines the gradient to use
  65818. * @param result defines the target quaternion
  65819. */
  65820. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  65821. /**
  65822. * Interpolate between two quaternions using Hermite interpolation
  65823. * @param value1 defines first quaternion
  65824. * @param tangent1 defines the incoming tangent
  65825. * @param value2 defines second quaternion
  65826. * @param tangent2 defines the outgoing tangent
  65827. * @param amount defines the target quaternion
  65828. * @returns the new interpolated quaternion
  65829. */
  65830. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  65831. }
  65832. /**
  65833. * Class used to store matrix data (4x4)
  65834. */
  65835. export class Matrix {
  65836. private static _updateFlagSeed;
  65837. private static _identityReadOnly;
  65838. private _isIdentity;
  65839. private _isIdentityDirty;
  65840. private _isIdentity3x2;
  65841. private _isIdentity3x2Dirty;
  65842. /**
  65843. * Gets the update flag of the matrix which is an unique number for the matrix.
  65844. * It will be incremented every time the matrix data change.
  65845. * You can use it to speed the comparison between two versions of the same matrix.
  65846. */
  65847. updateFlag: number;
  65848. private readonly _m;
  65849. /**
  65850. * Gets the internal data of the matrix
  65851. */
  65852. readonly m: DeepImmutable<Float32Array>;
  65853. /** @hidden */
  65854. _markAsUpdated(): void;
  65855. /** @hidden */
  65856. private _updateIdentityStatus;
  65857. /**
  65858. * Creates an empty matrix (filled with zeros)
  65859. */
  65860. constructor();
  65861. /**
  65862. * Check if the current matrix is identity
  65863. * @returns true is the matrix is the identity matrix
  65864. */
  65865. isIdentity(): boolean;
  65866. /**
  65867. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  65868. * @returns true is the matrix is the identity matrix
  65869. */
  65870. isIdentityAs3x2(): boolean;
  65871. /**
  65872. * Gets the determinant of the matrix
  65873. * @returns the matrix determinant
  65874. */
  65875. determinant(): number;
  65876. /**
  65877. * Returns the matrix as a Float32Array
  65878. * @returns the matrix underlying array
  65879. */
  65880. toArray(): DeepImmutable<Float32Array>;
  65881. /**
  65882. * Returns the matrix as a Float32Array
  65883. * @returns the matrix underlying array.
  65884. */
  65885. asArray(): DeepImmutable<Float32Array>;
  65886. /**
  65887. * Inverts the current matrix in place
  65888. * @returns the current inverted matrix
  65889. */
  65890. invert(): Matrix;
  65891. /**
  65892. * Sets all the matrix elements to zero
  65893. * @returns the current matrix
  65894. */
  65895. reset(): Matrix;
  65896. /**
  65897. * Adds the current matrix with a second one
  65898. * @param other defines the matrix to add
  65899. * @returns a new matrix as the addition of the current matrix and the given one
  65900. */
  65901. add(other: DeepImmutable<Matrix>): Matrix;
  65902. /**
  65903. * Sets the given matrix "result" to the addition of the current matrix and the given one
  65904. * @param other defines the matrix to add
  65905. * @param result defines the target matrix
  65906. * @returns the current matrix
  65907. */
  65908. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  65909. /**
  65910. * Adds in place the given matrix to the current matrix
  65911. * @param other defines the second operand
  65912. * @returns the current updated matrix
  65913. */
  65914. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  65915. /**
  65916. * Sets the given matrix to the current inverted Matrix
  65917. * @param other defines the target matrix
  65918. * @returns the unmodified current matrix
  65919. */
  65920. invertToRef(other: Matrix): Matrix;
  65921. /**
  65922. * add a value at the specified position in the current Matrix
  65923. * @param index the index of the value within the matrix. between 0 and 15.
  65924. * @param value the value to be added
  65925. * @returns the current updated matrix
  65926. */
  65927. addAtIndex(index: number, value: number): Matrix;
  65928. /**
  65929. * mutiply the specified position in the current Matrix by a value
  65930. * @param index the index of the value within the matrix. between 0 and 15.
  65931. * @param value the value to be added
  65932. * @returns the current updated matrix
  65933. */
  65934. multiplyAtIndex(index: number, value: number): Matrix;
  65935. /**
  65936. * Inserts the translation vector (using 3 floats) in the current matrix
  65937. * @param x defines the 1st component of the translation
  65938. * @param y defines the 2nd component of the translation
  65939. * @param z defines the 3rd component of the translation
  65940. * @returns the current updated matrix
  65941. */
  65942. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  65943. /**
  65944. * Adds the translation vector (using 3 floats) in the current matrix
  65945. * @param x defines the 1st component of the translation
  65946. * @param y defines the 2nd component of the translation
  65947. * @param z defines the 3rd component of the translation
  65948. * @returns the current updated matrix
  65949. */
  65950. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  65951. /**
  65952. * Inserts the translation vector in the current matrix
  65953. * @param vector3 defines the translation to insert
  65954. * @returns the current updated matrix
  65955. */
  65956. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  65957. /**
  65958. * Gets the translation value of the current matrix
  65959. * @returns a new Vector3 as the extracted translation from the matrix
  65960. */
  65961. getTranslation(): Vector3;
  65962. /**
  65963. * Fill a Vector3 with the extracted translation from the matrix
  65964. * @param result defines the Vector3 where to store the translation
  65965. * @returns the current matrix
  65966. */
  65967. getTranslationToRef(result: Vector3): Matrix;
  65968. /**
  65969. * Remove rotation and scaling part from the matrix
  65970. * @returns the updated matrix
  65971. */
  65972. removeRotationAndScaling(): Matrix;
  65973. /**
  65974. * Multiply two matrices
  65975. * @param other defines the second operand
  65976. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  65977. */
  65978. multiply(other: DeepImmutable<Matrix>): Matrix;
  65979. /**
  65980. * Copy the current matrix from the given one
  65981. * @param other defines the source matrix
  65982. * @returns the current updated matrix
  65983. */
  65984. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  65985. /**
  65986. * Populates the given array from the starting index with the current matrix values
  65987. * @param array defines the target array
  65988. * @param offset defines the offset in the target array where to start storing values
  65989. * @returns the current matrix
  65990. */
  65991. copyToArray(array: Float32Array, offset?: number): Matrix;
  65992. /**
  65993. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  65994. * @param other defines the second operand
  65995. * @param result defines the matrix where to store the multiplication
  65996. * @returns the current matrix
  65997. */
  65998. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  65999. /**
  66000. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  66001. * @param other defines the second operand
  66002. * @param result defines the array where to store the multiplication
  66003. * @param offset defines the offset in the target array where to start storing values
  66004. * @returns the current matrix
  66005. */
  66006. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  66007. /**
  66008. * Check equality between this matrix and a second one
  66009. * @param value defines the second matrix to compare
  66010. * @returns true is the current matrix and the given one values are strictly equal
  66011. */
  66012. equals(value: DeepImmutable<Matrix>): boolean;
  66013. /**
  66014. * Clone the current matrix
  66015. * @returns a new matrix from the current matrix
  66016. */
  66017. clone(): Matrix;
  66018. /**
  66019. * Returns the name of the current matrix class
  66020. * @returns the string "Matrix"
  66021. */
  66022. getClassName(): string;
  66023. /**
  66024. * Gets the hash code of the current matrix
  66025. * @returns the hash code
  66026. */
  66027. getHashCode(): number;
  66028. /**
  66029. * Decomposes the current Matrix into a translation, rotation and scaling components
  66030. * @param scale defines the scale vector3 given as a reference to update
  66031. * @param rotation defines the rotation quaternion given as a reference to update
  66032. * @param translation defines the translation vector3 given as a reference to update
  66033. * @returns true if operation was successful
  66034. */
  66035. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  66036. /**
  66037. * Gets specific row of the matrix
  66038. * @param index defines the number of the row to get
  66039. * @returns the index-th row of the current matrix as a new Vector4
  66040. */
  66041. getRow(index: number): Nullable<Vector4>;
  66042. /**
  66043. * Sets the index-th row of the current matrix to the vector4 values
  66044. * @param index defines the number of the row to set
  66045. * @param row defines the target vector4
  66046. * @returns the updated current matrix
  66047. */
  66048. setRow(index: number, row: Vector4): Matrix;
  66049. /**
  66050. * Compute the transpose of the matrix
  66051. * @returns the new transposed matrix
  66052. */
  66053. transpose(): Matrix;
  66054. /**
  66055. * Compute the transpose of the matrix and store it in a given matrix
  66056. * @param result defines the target matrix
  66057. * @returns the current matrix
  66058. */
  66059. transposeToRef(result: Matrix): Matrix;
  66060. /**
  66061. * Sets the index-th row of the current matrix with the given 4 x float values
  66062. * @param index defines the row index
  66063. * @param x defines the x component to set
  66064. * @param y defines the y component to set
  66065. * @param z defines the z component to set
  66066. * @param w defines the w component to set
  66067. * @returns the updated current matrix
  66068. */
  66069. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  66070. /**
  66071. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  66072. * @param scale defines the scale factor
  66073. * @returns a new matrix
  66074. */
  66075. scale(scale: number): Matrix;
  66076. /**
  66077. * Scale the current matrix values by a factor to a given result matrix
  66078. * @param scale defines the scale factor
  66079. * @param result defines the matrix to store the result
  66080. * @returns the current matrix
  66081. */
  66082. scaleToRef(scale: number, result: Matrix): Matrix;
  66083. /**
  66084. * Scale the current matrix values by a factor and add the result to a given matrix
  66085. * @param scale defines the scale factor
  66086. * @param result defines the Matrix to store the result
  66087. * @returns the current matrix
  66088. */
  66089. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  66090. /**
  66091. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  66092. * @param ref matrix to store the result
  66093. */
  66094. toNormalMatrix(ref: Matrix): void;
  66095. /**
  66096. * Gets only rotation part of the current matrix
  66097. * @returns a new matrix sets to the extracted rotation matrix from the current one
  66098. */
  66099. getRotationMatrix(): Matrix;
  66100. /**
  66101. * Extracts the rotation matrix from the current one and sets it as the given "result"
  66102. * @param result defines the target matrix to store data to
  66103. * @returns the current matrix
  66104. */
  66105. getRotationMatrixToRef(result: Matrix): Matrix;
  66106. /**
  66107. * Toggles model matrix from being right handed to left handed in place and vice versa
  66108. */
  66109. toggleModelMatrixHandInPlace(): void;
  66110. /**
  66111. * Toggles projection matrix from being right handed to left handed in place and vice versa
  66112. */
  66113. toggleProjectionMatrixHandInPlace(): void;
  66114. /**
  66115. * Creates a matrix from an array
  66116. * @param array defines the source array
  66117. * @param offset defines an offset in the source array
  66118. * @returns a new Matrix set from the starting index of the given array
  66119. */
  66120. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  66121. /**
  66122. * Copy the content of an array into a given matrix
  66123. * @param array defines the source array
  66124. * @param offset defines an offset in the source array
  66125. * @param result defines the target matrix
  66126. */
  66127. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  66128. /**
  66129. * Stores an array into a matrix after having multiplied each component by a given factor
  66130. * @param array defines the source array
  66131. * @param offset defines the offset in the source array
  66132. * @param scale defines the scaling factor
  66133. * @param result defines the target matrix
  66134. */
  66135. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  66136. /**
  66137. * Gets an identity matrix that must not be updated
  66138. */
  66139. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  66140. /**
  66141. * Stores a list of values (16) inside a given matrix
  66142. * @param initialM11 defines 1st value of 1st row
  66143. * @param initialM12 defines 2nd value of 1st row
  66144. * @param initialM13 defines 3rd value of 1st row
  66145. * @param initialM14 defines 4th value of 1st row
  66146. * @param initialM21 defines 1st value of 2nd row
  66147. * @param initialM22 defines 2nd value of 2nd row
  66148. * @param initialM23 defines 3rd value of 2nd row
  66149. * @param initialM24 defines 4th value of 2nd row
  66150. * @param initialM31 defines 1st value of 3rd row
  66151. * @param initialM32 defines 2nd value of 3rd row
  66152. * @param initialM33 defines 3rd value of 3rd row
  66153. * @param initialM34 defines 4th value of 3rd row
  66154. * @param initialM41 defines 1st value of 4th row
  66155. * @param initialM42 defines 2nd value of 4th row
  66156. * @param initialM43 defines 3rd value of 4th row
  66157. * @param initialM44 defines 4th value of 4th row
  66158. * @param result defines the target matrix
  66159. */
  66160. 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;
  66161. /**
  66162. * Creates new matrix from a list of values (16)
  66163. * @param initialM11 defines 1st value of 1st row
  66164. * @param initialM12 defines 2nd value of 1st row
  66165. * @param initialM13 defines 3rd value of 1st row
  66166. * @param initialM14 defines 4th value of 1st row
  66167. * @param initialM21 defines 1st value of 2nd row
  66168. * @param initialM22 defines 2nd value of 2nd row
  66169. * @param initialM23 defines 3rd value of 2nd row
  66170. * @param initialM24 defines 4th value of 2nd row
  66171. * @param initialM31 defines 1st value of 3rd row
  66172. * @param initialM32 defines 2nd value of 3rd row
  66173. * @param initialM33 defines 3rd value of 3rd row
  66174. * @param initialM34 defines 4th value of 3rd row
  66175. * @param initialM41 defines 1st value of 4th row
  66176. * @param initialM42 defines 2nd value of 4th row
  66177. * @param initialM43 defines 3rd value of 4th row
  66178. * @param initialM44 defines 4th value of 4th row
  66179. * @returns the new matrix
  66180. */
  66181. 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;
  66182. /**
  66183. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  66184. * @param scale defines the scale vector3
  66185. * @param rotation defines the rotation quaternion
  66186. * @param translation defines the translation vector3
  66187. * @returns a new matrix
  66188. */
  66189. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  66190. /**
  66191. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  66192. * @param scale defines the scale vector3
  66193. * @param rotation defines the rotation quaternion
  66194. * @param translation defines the translation vector3
  66195. * @param result defines the target matrix
  66196. */
  66197. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  66198. /**
  66199. * Creates a new identity matrix
  66200. * @returns a new identity matrix
  66201. */
  66202. static Identity(): Matrix;
  66203. /**
  66204. * Creates a new identity matrix and stores the result in a given matrix
  66205. * @param result defines the target matrix
  66206. */
  66207. static IdentityToRef(result: Matrix): void;
  66208. /**
  66209. * Creates a new zero matrix
  66210. * @returns a new zero matrix
  66211. */
  66212. static Zero(): Matrix;
  66213. /**
  66214. * Creates a new rotation matrix for "angle" radians around the X axis
  66215. * @param angle defines the angle (in radians) to use
  66216. * @return the new matrix
  66217. */
  66218. static RotationX(angle: number): Matrix;
  66219. /**
  66220. * Creates a new matrix as the invert of a given matrix
  66221. * @param source defines the source matrix
  66222. * @returns the new matrix
  66223. */
  66224. static Invert(source: DeepImmutable<Matrix>): Matrix;
  66225. /**
  66226. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  66227. * @param angle defines the angle (in radians) to use
  66228. * @param result defines the target matrix
  66229. */
  66230. static RotationXToRef(angle: number, result: Matrix): void;
  66231. /**
  66232. * Creates a new rotation matrix for "angle" radians around the Y axis
  66233. * @param angle defines the angle (in radians) to use
  66234. * @return the new matrix
  66235. */
  66236. static RotationY(angle: number): Matrix;
  66237. /**
  66238. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  66239. * @param angle defines the angle (in radians) to use
  66240. * @param result defines the target matrix
  66241. */
  66242. static RotationYToRef(angle: number, result: Matrix): void;
  66243. /**
  66244. * Creates a new rotation matrix for "angle" radians around the Z axis
  66245. * @param angle defines the angle (in radians) to use
  66246. * @return the new matrix
  66247. */
  66248. static RotationZ(angle: number): Matrix;
  66249. /**
  66250. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  66251. * @param angle defines the angle (in radians) to use
  66252. * @param result defines the target matrix
  66253. */
  66254. static RotationZToRef(angle: number, result: Matrix): void;
  66255. /**
  66256. * Creates a new rotation matrix for "angle" radians around the given axis
  66257. * @param axis defines the axis to use
  66258. * @param angle defines the angle (in radians) to use
  66259. * @return the new matrix
  66260. */
  66261. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  66262. /**
  66263. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  66264. * @param axis defines the axis to use
  66265. * @param angle defines the angle (in radians) to use
  66266. * @param result defines the target matrix
  66267. */
  66268. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  66269. /**
  66270. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  66271. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  66272. * @param from defines the vector to align
  66273. * @param to defines the vector to align to
  66274. * @param result defines the target matrix
  66275. */
  66276. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  66277. /**
  66278. * Creates a rotation matrix
  66279. * @param yaw defines the yaw angle in radians (Y axis)
  66280. * @param pitch defines the pitch angle in radians (X axis)
  66281. * @param roll defines the roll angle in radians (X axis)
  66282. * @returns the new rotation matrix
  66283. */
  66284. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  66285. /**
  66286. * Creates a rotation matrix and stores it in a given matrix
  66287. * @param yaw defines the yaw angle in radians (Y axis)
  66288. * @param pitch defines the pitch angle in radians (X axis)
  66289. * @param roll defines the roll angle in radians (X axis)
  66290. * @param result defines the target matrix
  66291. */
  66292. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  66293. /**
  66294. * Creates a scaling matrix
  66295. * @param x defines the scale factor on X axis
  66296. * @param y defines the scale factor on Y axis
  66297. * @param z defines the scale factor on Z axis
  66298. * @returns the new matrix
  66299. */
  66300. static Scaling(x: number, y: number, z: number): Matrix;
  66301. /**
  66302. * Creates a scaling matrix and stores it in a given matrix
  66303. * @param x defines the scale factor on X axis
  66304. * @param y defines the scale factor on Y axis
  66305. * @param z defines the scale factor on Z axis
  66306. * @param result defines the target matrix
  66307. */
  66308. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  66309. /**
  66310. * Creates a translation matrix
  66311. * @param x defines the translation on X axis
  66312. * @param y defines the translation on Y axis
  66313. * @param z defines the translationon Z axis
  66314. * @returns the new matrix
  66315. */
  66316. static Translation(x: number, y: number, z: number): Matrix;
  66317. /**
  66318. * Creates a translation matrix and stores it in a given matrix
  66319. * @param x defines the translation on X axis
  66320. * @param y defines the translation on Y axis
  66321. * @param z defines the translationon Z axis
  66322. * @param result defines the target matrix
  66323. */
  66324. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  66325. /**
  66326. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  66327. * @param startValue defines the start value
  66328. * @param endValue defines the end value
  66329. * @param gradient defines the gradient factor
  66330. * @returns the new matrix
  66331. */
  66332. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  66333. /**
  66334. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  66335. * @param startValue defines the start value
  66336. * @param endValue defines the end value
  66337. * @param gradient defines the gradient factor
  66338. * @param result defines the Matrix object where to store data
  66339. */
  66340. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  66341. /**
  66342. * Builds a new matrix whose values are computed by:
  66343. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  66344. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  66345. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  66346. * @param startValue defines the first matrix
  66347. * @param endValue defines the second matrix
  66348. * @param gradient defines the gradient between the two matrices
  66349. * @returns the new matrix
  66350. */
  66351. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  66352. /**
  66353. * Update a matrix to values which are computed by:
  66354. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  66355. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  66356. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  66357. * @param startValue defines the first matrix
  66358. * @param endValue defines the second matrix
  66359. * @param gradient defines the gradient between the two matrices
  66360. * @param result defines the target matrix
  66361. */
  66362. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  66363. /**
  66364. * 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"
  66365. * This function works in left handed mode
  66366. * @param eye defines the final position of the entity
  66367. * @param target defines where the entity should look at
  66368. * @param up defines the up vector for the entity
  66369. * @returns the new matrix
  66370. */
  66371. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  66372. /**
  66373. * 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".
  66374. * This function works in left handed mode
  66375. * @param eye defines the final position of the entity
  66376. * @param target defines where the entity should look at
  66377. * @param up defines the up vector for the entity
  66378. * @param result defines the target matrix
  66379. */
  66380. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  66381. /**
  66382. * 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"
  66383. * This function works in right handed mode
  66384. * @param eye defines the final position of the entity
  66385. * @param target defines where the entity should look at
  66386. * @param up defines the up vector for the entity
  66387. * @returns the new matrix
  66388. */
  66389. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  66390. /**
  66391. * 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".
  66392. * This function works in right handed mode
  66393. * @param eye defines the final position of the entity
  66394. * @param target defines where the entity should look at
  66395. * @param up defines the up vector for the entity
  66396. * @param result defines the target matrix
  66397. */
  66398. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  66399. /**
  66400. * Create a left-handed orthographic projection matrix
  66401. * @param width defines the viewport width
  66402. * @param height defines the viewport height
  66403. * @param znear defines the near clip plane
  66404. * @param zfar defines the far clip plane
  66405. * @returns a new matrix as a left-handed orthographic projection matrix
  66406. */
  66407. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  66408. /**
  66409. * Store a left-handed orthographic projection to a given matrix
  66410. * @param width defines the viewport width
  66411. * @param height defines the viewport height
  66412. * @param znear defines the near clip plane
  66413. * @param zfar defines the far clip plane
  66414. * @param result defines the target matrix
  66415. */
  66416. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  66417. /**
  66418. * Create a left-handed orthographic projection matrix
  66419. * @param left defines the viewport left coordinate
  66420. * @param right defines the viewport right coordinate
  66421. * @param bottom defines the viewport bottom coordinate
  66422. * @param top defines the viewport top coordinate
  66423. * @param znear defines the near clip plane
  66424. * @param zfar defines the far clip plane
  66425. * @returns a new matrix as a left-handed orthographic projection matrix
  66426. */
  66427. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  66428. /**
  66429. * Stores a left-handed orthographic projection into a given matrix
  66430. * @param left defines the viewport left coordinate
  66431. * @param right defines the viewport right coordinate
  66432. * @param bottom defines the viewport bottom coordinate
  66433. * @param top defines the viewport top coordinate
  66434. * @param znear defines the near clip plane
  66435. * @param zfar defines the far clip plane
  66436. * @param result defines the target matrix
  66437. */
  66438. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  66439. /**
  66440. * Creates a right-handed orthographic projection matrix
  66441. * @param left defines the viewport left coordinate
  66442. * @param right defines the viewport right coordinate
  66443. * @param bottom defines the viewport bottom coordinate
  66444. * @param top defines the viewport top coordinate
  66445. * @param znear defines the near clip plane
  66446. * @param zfar defines the far clip plane
  66447. * @returns a new matrix as a right-handed orthographic projection matrix
  66448. */
  66449. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  66450. /**
  66451. * Stores a right-handed orthographic projection into a given matrix
  66452. * @param left defines the viewport left coordinate
  66453. * @param right defines the viewport right coordinate
  66454. * @param bottom defines the viewport bottom coordinate
  66455. * @param top defines the viewport top coordinate
  66456. * @param znear defines the near clip plane
  66457. * @param zfar defines the far clip plane
  66458. * @param result defines the target matrix
  66459. */
  66460. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  66461. /**
  66462. * Creates a left-handed perspective projection matrix
  66463. * @param width defines the viewport width
  66464. * @param height defines the viewport height
  66465. * @param znear defines the near clip plane
  66466. * @param zfar defines the far clip plane
  66467. * @returns a new matrix as a left-handed perspective projection matrix
  66468. */
  66469. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  66470. /**
  66471. * Creates a left-handed perspective projection matrix
  66472. * @param fov defines the horizontal field of view
  66473. * @param aspect defines the aspect ratio
  66474. * @param znear defines the near clip plane
  66475. * @param zfar defines the far clip plane
  66476. * @returns a new matrix as a left-handed perspective projection matrix
  66477. */
  66478. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  66479. /**
  66480. * Stores a left-handed perspective projection into a given matrix
  66481. * @param fov defines the horizontal field of view
  66482. * @param aspect defines the aspect ratio
  66483. * @param znear defines the near clip plane
  66484. * @param zfar defines the far clip plane
  66485. * @param result defines the target matrix
  66486. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  66487. */
  66488. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  66489. /**
  66490. * Creates a right-handed perspective projection matrix
  66491. * @param fov defines the horizontal field of view
  66492. * @param aspect defines the aspect ratio
  66493. * @param znear defines the near clip plane
  66494. * @param zfar defines the far clip plane
  66495. * @returns a new matrix as a right-handed perspective projection matrix
  66496. */
  66497. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  66498. /**
  66499. * Stores a right-handed perspective projection into a given matrix
  66500. * @param fov defines the horizontal field of view
  66501. * @param aspect defines the aspect ratio
  66502. * @param znear defines the near clip plane
  66503. * @param zfar defines the far clip plane
  66504. * @param result defines the target matrix
  66505. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  66506. */
  66507. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  66508. /**
  66509. * Stores a perspective projection for WebVR info a given matrix
  66510. * @param fov defines the field of view
  66511. * @param znear defines the near clip plane
  66512. * @param zfar defines the far clip plane
  66513. * @param result defines the target matrix
  66514. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  66515. */
  66516. static PerspectiveFovWebVRToRef(fov: {
  66517. upDegrees: number;
  66518. downDegrees: number;
  66519. leftDegrees: number;
  66520. rightDegrees: number;
  66521. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  66522. /**
  66523. * Computes a complete transformation matrix
  66524. * @param viewport defines the viewport to use
  66525. * @param world defines the world matrix
  66526. * @param view defines the view matrix
  66527. * @param projection defines the projection matrix
  66528. * @param zmin defines the near clip plane
  66529. * @param zmax defines the far clip plane
  66530. * @returns the transformation matrix
  66531. */
  66532. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  66533. /**
  66534. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  66535. * @param matrix defines the matrix to use
  66536. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  66537. */
  66538. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  66539. /**
  66540. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  66541. * @param matrix defines the matrix to use
  66542. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  66543. */
  66544. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  66545. /**
  66546. * Compute the transpose of a given matrix
  66547. * @param matrix defines the matrix to transpose
  66548. * @returns the new matrix
  66549. */
  66550. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  66551. /**
  66552. * Compute the transpose of a matrix and store it in a target matrix
  66553. * @param matrix defines the matrix to transpose
  66554. * @param result defines the target matrix
  66555. */
  66556. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  66557. /**
  66558. * Computes a reflection matrix from a plane
  66559. * @param plane defines the reflection plane
  66560. * @returns a new matrix
  66561. */
  66562. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  66563. /**
  66564. * Computes a reflection matrix from a plane
  66565. * @param plane defines the reflection plane
  66566. * @param result defines the target matrix
  66567. */
  66568. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  66569. /**
  66570. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  66571. * @param xaxis defines the value of the 1st axis
  66572. * @param yaxis defines the value of the 2nd axis
  66573. * @param zaxis defines the value of the 3rd axis
  66574. * @param result defines the target matrix
  66575. */
  66576. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  66577. /**
  66578. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  66579. * @param quat defines the quaternion to use
  66580. * @param result defines the target matrix
  66581. */
  66582. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  66583. }
  66584. /**
  66585. * Represens a plane by the equation ax + by + cz + d = 0
  66586. */
  66587. export class Plane {
  66588. /**
  66589. * Normal of the plane (a,b,c)
  66590. */
  66591. normal: Vector3;
  66592. /**
  66593. * d component of the plane
  66594. */
  66595. d: number;
  66596. /**
  66597. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  66598. * @param a a component of the plane
  66599. * @param b b component of the plane
  66600. * @param c c component of the plane
  66601. * @param d d component of the plane
  66602. */
  66603. constructor(a: number, b: number, c: number, d: number);
  66604. /**
  66605. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  66606. */
  66607. asArray(): number[];
  66608. /**
  66609. * @returns a new plane copied from the current Plane.
  66610. */
  66611. clone(): Plane;
  66612. /**
  66613. * @returns the string "Plane".
  66614. */
  66615. getClassName(): string;
  66616. /**
  66617. * @returns the Plane hash code.
  66618. */
  66619. getHashCode(): number;
  66620. /**
  66621. * Normalize the current Plane in place.
  66622. * @returns the updated Plane.
  66623. */
  66624. normalize(): Plane;
  66625. /**
  66626. * Applies a transformation the plane and returns the result
  66627. * @param transformation the transformation matrix to be applied to the plane
  66628. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  66629. */
  66630. transform(transformation: DeepImmutable<Matrix>): Plane;
  66631. /**
  66632. * Calcualtte the dot product between the point and the plane normal
  66633. * @param point point to calculate the dot product with
  66634. * @returns the dot product (float) of the point coordinates and the plane normal.
  66635. */
  66636. dotCoordinate(point: DeepImmutable<Vector3>): number;
  66637. /**
  66638. * Updates the current Plane from the plane defined by the three given points.
  66639. * @param point1 one of the points used to contruct the plane
  66640. * @param point2 one of the points used to contruct the plane
  66641. * @param point3 one of the points used to contruct the plane
  66642. * @returns the updated Plane.
  66643. */
  66644. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  66645. /**
  66646. * Checks if the plane is facing a given direction
  66647. * @param direction the direction to check if the plane is facing
  66648. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  66649. * @returns True is the vector "direction" is the same side than the plane normal.
  66650. */
  66651. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  66652. /**
  66653. * Calculates the distance to a point
  66654. * @param point point to calculate distance to
  66655. * @returns the signed distance (float) from the given point to the Plane.
  66656. */
  66657. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  66658. /**
  66659. * Creates a plane from an array
  66660. * @param array the array to create a plane from
  66661. * @returns a new Plane from the given array.
  66662. */
  66663. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  66664. /**
  66665. * Creates a plane from three points
  66666. * @param point1 point used to create the plane
  66667. * @param point2 point used to create the plane
  66668. * @param point3 point used to create the plane
  66669. * @returns a new Plane defined by the three given points.
  66670. */
  66671. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  66672. /**
  66673. * Creates a plane from an origin point and a normal
  66674. * @param origin origin of the plane to be constructed
  66675. * @param normal normal of the plane to be constructed
  66676. * @returns a new Plane the normal vector to this plane at the given origin point.
  66677. * Note : the vector "normal" is updated because normalized.
  66678. */
  66679. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  66680. /**
  66681. * Calculates the distance from a plane and a point
  66682. * @param origin origin of the plane to be constructed
  66683. * @param normal normal of the plane to be constructed
  66684. * @param point point to calculate distance to
  66685. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  66686. */
  66687. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  66688. }
  66689. /**
  66690. * Class used to represent a viewport on screen
  66691. */
  66692. export class Viewport {
  66693. /** viewport left coordinate */
  66694. x: number;
  66695. /** viewport top coordinate */
  66696. y: number;
  66697. /**viewport width */
  66698. width: number;
  66699. /** viewport height */
  66700. height: number;
  66701. /**
  66702. * Creates a Viewport object located at (x, y) and sized (width, height)
  66703. * @param x defines viewport left coordinate
  66704. * @param y defines viewport top coordinate
  66705. * @param width defines the viewport width
  66706. * @param height defines the viewport height
  66707. */
  66708. constructor(
  66709. /** viewport left coordinate */
  66710. x: number,
  66711. /** viewport top coordinate */
  66712. y: number,
  66713. /**viewport width */
  66714. width: number,
  66715. /** viewport height */
  66716. height: number);
  66717. /**
  66718. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  66719. * @param renderWidth defines the rendering width
  66720. * @param renderHeight defines the rendering height
  66721. * @returns a new Viewport
  66722. */
  66723. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  66724. /**
  66725. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  66726. * @param renderWidth defines the rendering width
  66727. * @param renderHeight defines the rendering height
  66728. * @param ref defines the target viewport
  66729. * @returns the current viewport
  66730. */
  66731. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  66732. /**
  66733. * Returns a new Viewport copied from the current one
  66734. * @returns a new Viewport
  66735. */
  66736. clone(): Viewport;
  66737. }
  66738. /**
  66739. * Reprasents a camera frustum
  66740. */
  66741. export class Frustum {
  66742. /**
  66743. * Gets the planes representing the frustum
  66744. * @param transform matrix to be applied to the returned planes
  66745. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  66746. */
  66747. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  66748. /**
  66749. * Gets the near frustum plane transformed by the transform matrix
  66750. * @param transform transformation matrix to be applied to the resulting frustum plane
  66751. * @param frustumPlane the resuling frustum plane
  66752. */
  66753. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66754. /**
  66755. * Gets the far frustum plane transformed by the transform matrix
  66756. * @param transform transformation matrix to be applied to the resulting frustum plane
  66757. * @param frustumPlane the resuling frustum plane
  66758. */
  66759. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66760. /**
  66761. * Gets the left frustum plane transformed by the transform matrix
  66762. * @param transform transformation matrix to be applied to the resulting frustum plane
  66763. * @param frustumPlane the resuling frustum plane
  66764. */
  66765. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66766. /**
  66767. * Gets the right frustum plane transformed by the transform matrix
  66768. * @param transform transformation matrix to be applied to the resulting frustum plane
  66769. * @param frustumPlane the resuling frustum plane
  66770. */
  66771. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66772. /**
  66773. * Gets the top frustum plane transformed by the transform matrix
  66774. * @param transform transformation matrix to be applied to the resulting frustum plane
  66775. * @param frustumPlane the resuling frustum plane
  66776. */
  66777. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66778. /**
  66779. * Gets the bottom frustum plane transformed by the transform matrix
  66780. * @param transform transformation matrix to be applied to the resulting frustum plane
  66781. * @param frustumPlane the resuling frustum plane
  66782. */
  66783. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66784. /**
  66785. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  66786. * @param transform transformation matrix to be applied to the resulting frustum planes
  66787. * @param frustumPlanes the resuling frustum planes
  66788. */
  66789. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  66790. }
  66791. /** Defines supported spaces */
  66792. export enum Space {
  66793. /** Local (object) space */
  66794. LOCAL = 0,
  66795. /** World space */
  66796. WORLD = 1,
  66797. /** Bone space */
  66798. BONE = 2
  66799. }
  66800. /** Defines the 3 main axes */
  66801. export class Axis {
  66802. /** X axis */
  66803. static X: Vector3;
  66804. /** Y axis */
  66805. static Y: Vector3;
  66806. /** Z axis */
  66807. static Z: Vector3;
  66808. }
  66809. /** Class used to represent a Bezier curve */
  66810. export class BezierCurve {
  66811. /**
  66812. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  66813. * @param t defines the time
  66814. * @param x1 defines the left coordinate on X axis
  66815. * @param y1 defines the left coordinate on Y axis
  66816. * @param x2 defines the right coordinate on X axis
  66817. * @param y2 defines the right coordinate on Y axis
  66818. * @returns the interpolated value
  66819. */
  66820. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  66821. }
  66822. /**
  66823. * Defines potential orientation for back face culling
  66824. */
  66825. export enum Orientation {
  66826. /**
  66827. * Clockwise
  66828. */
  66829. CW = 0,
  66830. /** Counter clockwise */
  66831. CCW = 1
  66832. }
  66833. /**
  66834. * Defines angle representation
  66835. */
  66836. export class Angle {
  66837. private _radians;
  66838. /**
  66839. * Creates an Angle object of "radians" radians (float).
  66840. * @param radians the angle in radians
  66841. */
  66842. constructor(radians: number);
  66843. /**
  66844. * Get value in degrees
  66845. * @returns the Angle value in degrees (float)
  66846. */
  66847. degrees(): number;
  66848. /**
  66849. * Get value in radians
  66850. * @returns the Angle value in radians (float)
  66851. */
  66852. radians(): number;
  66853. /**
  66854. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  66855. * @param a defines first vector
  66856. * @param b defines second vector
  66857. * @returns a new Angle
  66858. */
  66859. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  66860. /**
  66861. * Gets a new Angle object from the given float in radians
  66862. * @param radians defines the angle value in radians
  66863. * @returns a new Angle
  66864. */
  66865. static FromRadians(radians: number): Angle;
  66866. /**
  66867. * Gets a new Angle object from the given float in degrees
  66868. * @param degrees defines the angle value in degrees
  66869. * @returns a new Angle
  66870. */
  66871. static FromDegrees(degrees: number): Angle;
  66872. }
  66873. /**
  66874. * This represents an arc in a 2d space.
  66875. */
  66876. export class Arc2 {
  66877. /** Defines the start point of the arc */
  66878. startPoint: Vector2;
  66879. /** Defines the mid point of the arc */
  66880. midPoint: Vector2;
  66881. /** Defines the end point of the arc */
  66882. endPoint: Vector2;
  66883. /**
  66884. * Defines the center point of the arc.
  66885. */
  66886. centerPoint: Vector2;
  66887. /**
  66888. * Defines the radius of the arc.
  66889. */
  66890. radius: number;
  66891. /**
  66892. * Defines the angle of the arc (from mid point to end point).
  66893. */
  66894. angle: Angle;
  66895. /**
  66896. * Defines the start angle of the arc (from start point to middle point).
  66897. */
  66898. startAngle: Angle;
  66899. /**
  66900. * Defines the orientation of the arc (clock wise/counter clock wise).
  66901. */
  66902. orientation: Orientation;
  66903. /**
  66904. * Creates an Arc object from the three given points : start, middle and end.
  66905. * @param startPoint Defines the start point of the arc
  66906. * @param midPoint Defines the midlle point of the arc
  66907. * @param endPoint Defines the end point of the arc
  66908. */
  66909. constructor(
  66910. /** Defines the start point of the arc */
  66911. startPoint: Vector2,
  66912. /** Defines the mid point of the arc */
  66913. midPoint: Vector2,
  66914. /** Defines the end point of the arc */
  66915. endPoint: Vector2);
  66916. }
  66917. /**
  66918. * Represents a 2D path made up of multiple 2D points
  66919. */
  66920. export class Path2 {
  66921. private _points;
  66922. private _length;
  66923. /**
  66924. * If the path start and end point are the same
  66925. */
  66926. closed: boolean;
  66927. /**
  66928. * Creates a Path2 object from the starting 2D coordinates x and y.
  66929. * @param x the starting points x value
  66930. * @param y the starting points y value
  66931. */
  66932. constructor(x: number, y: number);
  66933. /**
  66934. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  66935. * @param x the added points x value
  66936. * @param y the added points y value
  66937. * @returns the updated Path2.
  66938. */
  66939. addLineTo(x: number, y: number): Path2;
  66940. /**
  66941. * 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.
  66942. * @param midX middle point x value
  66943. * @param midY middle point y value
  66944. * @param endX end point x value
  66945. * @param endY end point y value
  66946. * @param numberOfSegments (default: 36)
  66947. * @returns the updated Path2.
  66948. */
  66949. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  66950. /**
  66951. * Closes the Path2.
  66952. * @returns the Path2.
  66953. */
  66954. close(): Path2;
  66955. /**
  66956. * Gets the sum of the distance between each sequential point in the path
  66957. * @returns the Path2 total length (float).
  66958. */
  66959. length(): number;
  66960. /**
  66961. * Gets the points which construct the path
  66962. * @returns the Path2 internal array of points.
  66963. */
  66964. getPoints(): Vector2[];
  66965. /**
  66966. * Retreives the point at the distance aways from the starting point
  66967. * @param normalizedLengthPosition the length along the path to retreive the point from
  66968. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  66969. */
  66970. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  66971. /**
  66972. * Creates a new path starting from an x and y position
  66973. * @param x starting x value
  66974. * @param y starting y value
  66975. * @returns a new Path2 starting at the coordinates (x, y).
  66976. */
  66977. static StartingAt(x: number, y: number): Path2;
  66978. }
  66979. /**
  66980. * Represents a 3D path made up of multiple 3D points
  66981. */
  66982. export class Path3D {
  66983. /**
  66984. * an array of Vector3, the curve axis of the Path3D
  66985. */
  66986. path: Vector3[];
  66987. private _curve;
  66988. private _distances;
  66989. private _tangents;
  66990. private _normals;
  66991. private _binormals;
  66992. private _raw;
  66993. /**
  66994. * new Path3D(path, normal, raw)
  66995. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  66996. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  66997. * @param path an array of Vector3, the curve axis of the Path3D
  66998. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  66999. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  67000. */
  67001. constructor(
  67002. /**
  67003. * an array of Vector3, the curve axis of the Path3D
  67004. */
  67005. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  67006. /**
  67007. * Returns the Path3D array of successive Vector3 designing its curve.
  67008. * @returns the Path3D array of successive Vector3 designing its curve.
  67009. */
  67010. getCurve(): Vector3[];
  67011. /**
  67012. * Returns an array populated with tangent vectors on each Path3D curve point.
  67013. * @returns an array populated with tangent vectors on each Path3D curve point.
  67014. */
  67015. getTangents(): Vector3[];
  67016. /**
  67017. * Returns an array populated with normal vectors on each Path3D curve point.
  67018. * @returns an array populated with normal vectors on each Path3D curve point.
  67019. */
  67020. getNormals(): Vector3[];
  67021. /**
  67022. * Returns an array populated with binormal vectors on each Path3D curve point.
  67023. * @returns an array populated with binormal vectors on each Path3D curve point.
  67024. */
  67025. getBinormals(): Vector3[];
  67026. /**
  67027. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  67028. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  67029. */
  67030. getDistances(): number[];
  67031. /**
  67032. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  67033. * @param path path which all values are copied into the curves points
  67034. * @param firstNormal which should be projected onto the curve
  67035. * @returns the same object updated.
  67036. */
  67037. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  67038. private _compute;
  67039. private _getFirstNonNullVector;
  67040. private _getLastNonNullVector;
  67041. private _normalVector;
  67042. }
  67043. /**
  67044. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  67045. * A Curve3 is designed from a series of successive Vector3.
  67046. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  67047. */
  67048. export class Curve3 {
  67049. private _points;
  67050. private _length;
  67051. /**
  67052. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  67053. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  67054. * @param v1 (Vector3) the control point
  67055. * @param v2 (Vector3) the end point of the Quadratic Bezier
  67056. * @param nbPoints (integer) the wanted number of points in the curve
  67057. * @returns the created Curve3
  67058. */
  67059. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  67060. /**
  67061. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  67062. * @param v0 (Vector3) the origin point of the Cubic Bezier
  67063. * @param v1 (Vector3) the first control point
  67064. * @param v2 (Vector3) the second control point
  67065. * @param v3 (Vector3) the end point of the Cubic Bezier
  67066. * @param nbPoints (integer) the wanted number of points in the curve
  67067. * @returns the created Curve3
  67068. */
  67069. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  67070. /**
  67071. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  67072. * @param p1 (Vector3) the origin point of the Hermite Spline
  67073. * @param t1 (Vector3) the tangent vector at the origin point
  67074. * @param p2 (Vector3) the end point of the Hermite Spline
  67075. * @param t2 (Vector3) the tangent vector at the end point
  67076. * @param nbPoints (integer) the wanted number of points in the curve
  67077. * @returns the created Curve3
  67078. */
  67079. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  67080. /**
  67081. * Returns a Curve3 object along a CatmullRom Spline curve :
  67082. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  67083. * @param nbPoints (integer) the wanted number of points between each curve control points
  67084. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  67085. * @returns the created Curve3
  67086. */
  67087. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  67088. /**
  67089. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  67090. * A Curve3 is designed from a series of successive Vector3.
  67091. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  67092. * @param points points which make up the curve
  67093. */
  67094. constructor(points: Vector3[]);
  67095. /**
  67096. * @returns the Curve3 stored array of successive Vector3
  67097. */
  67098. getPoints(): Vector3[];
  67099. /**
  67100. * @returns the computed length (float) of the curve.
  67101. */
  67102. length(): number;
  67103. /**
  67104. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  67105. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  67106. * curveA and curveB keep unchanged.
  67107. * @param curve the curve to continue from this curve
  67108. * @returns the newly constructed curve
  67109. */
  67110. continue(curve: DeepImmutable<Curve3>): Curve3;
  67111. private _computeLength;
  67112. }
  67113. /**
  67114. * Contains position and normal vectors for a vertex
  67115. */
  67116. export class PositionNormalVertex {
  67117. /** the position of the vertex (defaut: 0,0,0) */
  67118. position: Vector3;
  67119. /** the normal of the vertex (defaut: 0,1,0) */
  67120. normal: Vector3;
  67121. /**
  67122. * Creates a PositionNormalVertex
  67123. * @param position the position of the vertex (defaut: 0,0,0)
  67124. * @param normal the normal of the vertex (defaut: 0,1,0)
  67125. */
  67126. constructor(
  67127. /** the position of the vertex (defaut: 0,0,0) */
  67128. position?: Vector3,
  67129. /** the normal of the vertex (defaut: 0,1,0) */
  67130. normal?: Vector3);
  67131. /**
  67132. * Clones the PositionNormalVertex
  67133. * @returns the cloned PositionNormalVertex
  67134. */
  67135. clone(): PositionNormalVertex;
  67136. }
  67137. /**
  67138. * Contains position, normal and uv vectors for a vertex
  67139. */
  67140. export class PositionNormalTextureVertex {
  67141. /** the position of the vertex (defaut: 0,0,0) */
  67142. position: Vector3;
  67143. /** the normal of the vertex (defaut: 0,1,0) */
  67144. normal: Vector3;
  67145. /** the uv of the vertex (default: 0,0) */
  67146. uv: Vector2;
  67147. /**
  67148. * Creates a PositionNormalTextureVertex
  67149. * @param position the position of the vertex (defaut: 0,0,0)
  67150. * @param normal the normal of the vertex (defaut: 0,1,0)
  67151. * @param uv the uv of the vertex (default: 0,0)
  67152. */
  67153. constructor(
  67154. /** the position of the vertex (defaut: 0,0,0) */
  67155. position?: Vector3,
  67156. /** the normal of the vertex (defaut: 0,1,0) */
  67157. normal?: Vector3,
  67158. /** the uv of the vertex (default: 0,0) */
  67159. uv?: Vector2);
  67160. /**
  67161. * Clones the PositionNormalTextureVertex
  67162. * @returns the cloned PositionNormalTextureVertex
  67163. */
  67164. clone(): PositionNormalTextureVertex;
  67165. }
  67166. /**
  67167. * @hidden
  67168. */
  67169. export class Tmp {
  67170. static Color3: Color3[];
  67171. static Color4: Color4[];
  67172. static Vector2: Vector2[];
  67173. static Vector3: Vector3[];
  67174. static Vector4: Vector4[];
  67175. static Quaternion: Quaternion[];
  67176. static Matrix: Matrix[];
  67177. }
  67178. }
  67179. declare module BABYLON {
  67180. /**
  67181. * Class used to enable access to offline support
  67182. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  67183. */
  67184. export interface IOfflineProvider {
  67185. /**
  67186. * Gets a boolean indicating if scene must be saved in the database
  67187. */
  67188. enableSceneOffline: boolean;
  67189. /**
  67190. * Gets a boolean indicating if textures must be saved in the database
  67191. */
  67192. enableTexturesOffline: boolean;
  67193. /**
  67194. * Open the offline support and make it available
  67195. * @param successCallback defines the callback to call on success
  67196. * @param errorCallback defines the callback to call on error
  67197. */
  67198. open(successCallback: () => void, errorCallback: () => void): void;
  67199. /**
  67200. * Loads an image from the offline support
  67201. * @param url defines the url to load from
  67202. * @param image defines the target DOM image
  67203. */
  67204. loadImage(url: string, image: HTMLImageElement): void;
  67205. /**
  67206. * Loads a file from offline support
  67207. * @param url defines the URL to load from
  67208. * @param sceneLoaded defines a callback to call on success
  67209. * @param progressCallBack defines a callback to call when progress changed
  67210. * @param errorCallback defines a callback to call on error
  67211. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  67212. */
  67213. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  67214. }
  67215. }
  67216. declare module BABYLON {
  67217. /**
  67218. * A class serves as a medium between the observable and its observers
  67219. */
  67220. export class EventState {
  67221. /**
  67222. * Create a new EventState
  67223. * @param mask defines the mask associated with this state
  67224. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67225. * @param target defines the original target of the state
  67226. * @param currentTarget defines the current target of the state
  67227. */
  67228. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  67229. /**
  67230. * Initialize the current event state
  67231. * @param mask defines the mask associated with this state
  67232. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67233. * @param target defines the original target of the state
  67234. * @param currentTarget defines the current target of the state
  67235. * @returns the current event state
  67236. */
  67237. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  67238. /**
  67239. * An Observer can set this property to true to prevent subsequent observers of being notified
  67240. */
  67241. skipNextObservers: boolean;
  67242. /**
  67243. * Get the mask value that were used to trigger the event corresponding to this EventState object
  67244. */
  67245. mask: number;
  67246. /**
  67247. * The object that originally notified the event
  67248. */
  67249. target?: any;
  67250. /**
  67251. * The current object in the bubbling phase
  67252. */
  67253. currentTarget?: any;
  67254. /**
  67255. * This will be populated with the return value of the last function that was executed.
  67256. * If it is the first function in the callback chain it will be the event data.
  67257. */
  67258. lastReturnValue?: any;
  67259. }
  67260. /**
  67261. * Represent an Observer registered to a given Observable object.
  67262. */
  67263. export class Observer<T> {
  67264. /**
  67265. * Defines the callback to call when the observer is notified
  67266. */
  67267. callback: (eventData: T, eventState: EventState) => void;
  67268. /**
  67269. * Defines the mask of the observer (used to filter notifications)
  67270. */
  67271. mask: number;
  67272. /**
  67273. * Defines the current scope used to restore the JS context
  67274. */
  67275. scope: any;
  67276. /** @hidden */
  67277. _willBeUnregistered: boolean;
  67278. /**
  67279. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  67280. */
  67281. unregisterOnNextCall: boolean;
  67282. /**
  67283. * Creates a new observer
  67284. * @param callback defines the callback to call when the observer is notified
  67285. * @param mask defines the mask of the observer (used to filter notifications)
  67286. * @param scope defines the current scope used to restore the JS context
  67287. */
  67288. constructor(
  67289. /**
  67290. * Defines the callback to call when the observer is notified
  67291. */
  67292. callback: (eventData: T, eventState: EventState) => void,
  67293. /**
  67294. * Defines the mask of the observer (used to filter notifications)
  67295. */
  67296. mask: number,
  67297. /**
  67298. * Defines the current scope used to restore the JS context
  67299. */
  67300. scope?: any);
  67301. }
  67302. /**
  67303. * Represent a list of observers registered to multiple Observables object.
  67304. */
  67305. export class MultiObserver<T> {
  67306. private _observers;
  67307. private _observables;
  67308. /**
  67309. * Release associated resources
  67310. */
  67311. dispose(): void;
  67312. /**
  67313. * Raise a callback when one of the observable will notify
  67314. * @param observables defines a list of observables to watch
  67315. * @param callback defines the callback to call on notification
  67316. * @param mask defines the mask used to filter notifications
  67317. * @param scope defines the current scope used to restore the JS context
  67318. * @returns the new MultiObserver
  67319. */
  67320. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  67321. }
  67322. /**
  67323. * The Observable class is a simple implementation of the Observable pattern.
  67324. *
  67325. * 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.
  67326. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  67327. * 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).
  67328. * 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.
  67329. */
  67330. export class Observable<T> {
  67331. private _observers;
  67332. private _eventState;
  67333. private _onObserverAdded;
  67334. /**
  67335. * Gets the list of observers
  67336. */
  67337. readonly observers: Array<Observer<T>>;
  67338. /**
  67339. * Creates a new observable
  67340. * @param onObserverAdded defines a callback to call when a new observer is added
  67341. */
  67342. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  67343. /**
  67344. * Create a new Observer with the specified callback
  67345. * @param callback the callback that will be executed for that Observer
  67346. * @param mask the mask used to filter observers
  67347. * @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.
  67348. * @param scope optional scope for the callback to be called from
  67349. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  67350. * @returns the new observer created for the callback
  67351. */
  67352. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  67353. /**
  67354. * Create a new Observer with the specified callback and unregisters after the next notification
  67355. * @param callback the callback that will be executed for that Observer
  67356. * @returns the new observer created for the callback
  67357. */
  67358. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  67359. /**
  67360. * Remove an Observer from the Observable object
  67361. * @param observer the instance of the Observer to remove
  67362. * @returns false if it doesn't belong to this Observable
  67363. */
  67364. remove(observer: Nullable<Observer<T>>): boolean;
  67365. /**
  67366. * Remove a callback from the Observable object
  67367. * @param callback the callback to remove
  67368. * @param scope optional scope. If used only the callbacks with this scope will be removed
  67369. * @returns false if it doesn't belong to this Observable
  67370. */
  67371. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  67372. private _deferUnregister;
  67373. private _remove;
  67374. /**
  67375. * Moves the observable to the top of the observer list making it get called first when notified
  67376. * @param observer the observer to move
  67377. */
  67378. makeObserverTopPriority(observer: Observer<T>): void;
  67379. /**
  67380. * Moves the observable to the bottom of the observer list making it get called last when notified
  67381. * @param observer the observer to move
  67382. */
  67383. makeObserverBottomPriority(observer: Observer<T>): void;
  67384. /**
  67385. * Notify all Observers by calling their respective callback with the given data
  67386. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  67387. * @param eventData defines the data to send to all observers
  67388. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  67389. * @param target defines the original target of the state
  67390. * @param currentTarget defines the current target of the state
  67391. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  67392. */
  67393. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  67394. /**
  67395. * Calling this will execute each callback, expecting it to be a promise or return a value.
  67396. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  67397. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  67398. * and it is crucial that all callbacks will be executed.
  67399. * The order of the callbacks is kept, callbacks are not executed parallel.
  67400. *
  67401. * @param eventData The data to be sent to each callback
  67402. * @param mask is used to filter observers defaults to -1
  67403. * @param target defines the callback target (see EventState)
  67404. * @param currentTarget defines he current object in the bubbling phase
  67405. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  67406. */
  67407. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  67408. /**
  67409. * Notify a specific observer
  67410. * @param observer defines the observer to notify
  67411. * @param eventData defines the data to be sent to each callback
  67412. * @param mask is used to filter observers defaults to -1
  67413. */
  67414. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  67415. /**
  67416. * Gets a boolean indicating if the observable has at least one observer
  67417. * @returns true is the Observable has at least one Observer registered
  67418. */
  67419. hasObservers(): boolean;
  67420. /**
  67421. * Clear the list of observers
  67422. */
  67423. clear(): void;
  67424. /**
  67425. * Clone the current observable
  67426. * @returns a new observable
  67427. */
  67428. clone(): Observable<T>;
  67429. /**
  67430. * Does this observable handles observer registered with a given mask
  67431. * @param mask defines the mask to be tested
  67432. * @return whether or not one observer registered with the given mask is handeled
  67433. **/
  67434. hasSpecificMask(mask?: number): boolean;
  67435. }
  67436. }
  67437. declare module BABYLON {
  67438. /**
  67439. * Class used to help managing file picking and drag'n'drop
  67440. * File Storage
  67441. */
  67442. export class FilesInputStore {
  67443. /**
  67444. * List of files ready to be loaded
  67445. */
  67446. static FilesToLoad: {
  67447. [key: string]: File;
  67448. };
  67449. }
  67450. }
  67451. declare module BABYLON {
  67452. /** Defines the cross module used constants to avoid circular dependncies */
  67453. export class Constants {
  67454. /** Defines that alpha blending is disabled */
  67455. static readonly ALPHA_DISABLE: number;
  67456. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  67457. static readonly ALPHA_ADD: number;
  67458. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  67459. static readonly ALPHA_COMBINE: number;
  67460. /** Defines that alpha blending to DEST - SRC * DEST */
  67461. static readonly ALPHA_SUBTRACT: number;
  67462. /** Defines that alpha blending to SRC * DEST */
  67463. static readonly ALPHA_MULTIPLY: number;
  67464. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  67465. static readonly ALPHA_MAXIMIZED: number;
  67466. /** Defines that alpha blending to SRC + DEST */
  67467. static readonly ALPHA_ONEONE: number;
  67468. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  67469. static readonly ALPHA_PREMULTIPLIED: number;
  67470. /**
  67471. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  67472. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  67473. */
  67474. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  67475. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  67476. static readonly ALPHA_INTERPOLATE: number;
  67477. /**
  67478. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  67479. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  67480. */
  67481. static readonly ALPHA_SCREENMODE: number;
  67482. /** Defines that the ressource is not delayed*/
  67483. static readonly DELAYLOADSTATE_NONE: number;
  67484. /** Defines that the ressource was successfully delay loaded */
  67485. static readonly DELAYLOADSTATE_LOADED: number;
  67486. /** Defines that the ressource is currently delay loading */
  67487. static readonly DELAYLOADSTATE_LOADING: number;
  67488. /** Defines that the ressource is delayed and has not started loading */
  67489. static readonly DELAYLOADSTATE_NOTLOADED: number;
  67490. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  67491. static readonly NEVER: number;
  67492. /** 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 */
  67493. static readonly ALWAYS: number;
  67494. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  67495. static readonly LESS: number;
  67496. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  67497. static readonly EQUAL: number;
  67498. /** 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 */
  67499. static readonly LEQUAL: number;
  67500. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  67501. static readonly GREATER: number;
  67502. /** 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 */
  67503. static readonly GEQUAL: number;
  67504. /** 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 */
  67505. static readonly NOTEQUAL: number;
  67506. /** Passed to stencilOperation to specify that stencil value must be kept */
  67507. static readonly KEEP: number;
  67508. /** Passed to stencilOperation to specify that stencil value must be replaced */
  67509. static readonly REPLACE: number;
  67510. /** Passed to stencilOperation to specify that stencil value must be incremented */
  67511. static readonly INCR: number;
  67512. /** Passed to stencilOperation to specify that stencil value must be decremented */
  67513. static readonly DECR: number;
  67514. /** Passed to stencilOperation to specify that stencil value must be inverted */
  67515. static readonly INVERT: number;
  67516. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  67517. static readonly INCR_WRAP: number;
  67518. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  67519. static readonly DECR_WRAP: number;
  67520. /** Texture is not repeating outside of 0..1 UVs */
  67521. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  67522. /** Texture is repeating outside of 0..1 UVs */
  67523. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  67524. /** Texture is repeating and mirrored */
  67525. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  67526. /** ALPHA */
  67527. static readonly TEXTUREFORMAT_ALPHA: number;
  67528. /** LUMINANCE */
  67529. static readonly TEXTUREFORMAT_LUMINANCE: number;
  67530. /** LUMINANCE_ALPHA */
  67531. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  67532. /** RGB */
  67533. static readonly TEXTUREFORMAT_RGB: number;
  67534. /** RGBA */
  67535. static readonly TEXTUREFORMAT_RGBA: number;
  67536. /** RED */
  67537. static readonly TEXTUREFORMAT_RED: number;
  67538. /** RED (2nd reference) */
  67539. static readonly TEXTUREFORMAT_R: number;
  67540. /** RG */
  67541. static readonly TEXTUREFORMAT_RG: number;
  67542. /** RED_INTEGER */
  67543. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  67544. /** RED_INTEGER (2nd reference) */
  67545. static readonly TEXTUREFORMAT_R_INTEGER: number;
  67546. /** RG_INTEGER */
  67547. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  67548. /** RGB_INTEGER */
  67549. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  67550. /** RGBA_INTEGER */
  67551. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  67552. /** UNSIGNED_BYTE */
  67553. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  67554. /** UNSIGNED_BYTE (2nd reference) */
  67555. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  67556. /** FLOAT */
  67557. static readonly TEXTURETYPE_FLOAT: number;
  67558. /** HALF_FLOAT */
  67559. static readonly TEXTURETYPE_HALF_FLOAT: number;
  67560. /** BYTE */
  67561. static readonly TEXTURETYPE_BYTE: number;
  67562. /** SHORT */
  67563. static readonly TEXTURETYPE_SHORT: number;
  67564. /** UNSIGNED_SHORT */
  67565. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  67566. /** INT */
  67567. static readonly TEXTURETYPE_INT: number;
  67568. /** UNSIGNED_INT */
  67569. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  67570. /** UNSIGNED_SHORT_4_4_4_4 */
  67571. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  67572. /** UNSIGNED_SHORT_5_5_5_1 */
  67573. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  67574. /** UNSIGNED_SHORT_5_6_5 */
  67575. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  67576. /** UNSIGNED_INT_2_10_10_10_REV */
  67577. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  67578. /** UNSIGNED_INT_24_8 */
  67579. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  67580. /** UNSIGNED_INT_10F_11F_11F_REV */
  67581. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  67582. /** UNSIGNED_INT_5_9_9_9_REV */
  67583. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  67584. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  67585. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  67586. /** nearest is mag = nearest and min = nearest and mip = linear */
  67587. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  67588. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67589. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  67590. /** Trilinear is mag = linear and min = linear and mip = linear */
  67591. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  67592. /** nearest is mag = nearest and min = nearest and mip = linear */
  67593. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  67594. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67595. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  67596. /** Trilinear is mag = linear and min = linear and mip = linear */
  67597. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  67598. /** mag = nearest and min = nearest and mip = nearest */
  67599. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  67600. /** mag = nearest and min = linear and mip = nearest */
  67601. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  67602. /** mag = nearest and min = linear and mip = linear */
  67603. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  67604. /** mag = nearest and min = linear and mip = none */
  67605. static readonly TEXTURE_NEAREST_LINEAR: number;
  67606. /** mag = nearest and min = nearest and mip = none */
  67607. static readonly TEXTURE_NEAREST_NEAREST: number;
  67608. /** mag = linear and min = nearest and mip = nearest */
  67609. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  67610. /** mag = linear and min = nearest and mip = linear */
  67611. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  67612. /** mag = linear and min = linear and mip = none */
  67613. static readonly TEXTURE_LINEAR_LINEAR: number;
  67614. /** mag = linear and min = nearest and mip = none */
  67615. static readonly TEXTURE_LINEAR_NEAREST: number;
  67616. /** Explicit coordinates mode */
  67617. static readonly TEXTURE_EXPLICIT_MODE: number;
  67618. /** Spherical coordinates mode */
  67619. static readonly TEXTURE_SPHERICAL_MODE: number;
  67620. /** Planar coordinates mode */
  67621. static readonly TEXTURE_PLANAR_MODE: number;
  67622. /** Cubic coordinates mode */
  67623. static readonly TEXTURE_CUBIC_MODE: number;
  67624. /** Projection coordinates mode */
  67625. static readonly TEXTURE_PROJECTION_MODE: number;
  67626. /** Skybox coordinates mode */
  67627. static readonly TEXTURE_SKYBOX_MODE: number;
  67628. /** Inverse Cubic coordinates mode */
  67629. static readonly TEXTURE_INVCUBIC_MODE: number;
  67630. /** Equirectangular coordinates mode */
  67631. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  67632. /** Equirectangular Fixed coordinates mode */
  67633. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  67634. /** Equirectangular Fixed Mirrored coordinates mode */
  67635. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  67636. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  67637. static readonly SCALEMODE_FLOOR: number;
  67638. /** Defines that texture rescaling will look for the nearest power of 2 size */
  67639. static readonly SCALEMODE_NEAREST: number;
  67640. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  67641. static readonly SCALEMODE_CEILING: number;
  67642. /**
  67643. * The dirty texture flag value
  67644. */
  67645. static readonly MATERIAL_TextureDirtyFlag: number;
  67646. /**
  67647. * The dirty light flag value
  67648. */
  67649. static readonly MATERIAL_LightDirtyFlag: number;
  67650. /**
  67651. * The dirty fresnel flag value
  67652. */
  67653. static readonly MATERIAL_FresnelDirtyFlag: number;
  67654. /**
  67655. * The dirty attribute flag value
  67656. */
  67657. static readonly MATERIAL_AttributesDirtyFlag: number;
  67658. /**
  67659. * The dirty misc flag value
  67660. */
  67661. static readonly MATERIAL_MiscDirtyFlag: number;
  67662. /**
  67663. * The all dirty flag value
  67664. */
  67665. static readonly MATERIAL_AllDirtyFlag: number;
  67666. /**
  67667. * Returns the triangle fill mode
  67668. */
  67669. static readonly MATERIAL_TriangleFillMode: number;
  67670. /**
  67671. * Returns the wireframe mode
  67672. */
  67673. static readonly MATERIAL_WireFrameFillMode: number;
  67674. /**
  67675. * Returns the point fill mode
  67676. */
  67677. static readonly MATERIAL_PointFillMode: number;
  67678. /**
  67679. * Returns the point list draw mode
  67680. */
  67681. static readonly MATERIAL_PointListDrawMode: number;
  67682. /**
  67683. * Returns the line list draw mode
  67684. */
  67685. static readonly MATERIAL_LineListDrawMode: number;
  67686. /**
  67687. * Returns the line loop draw mode
  67688. */
  67689. static readonly MATERIAL_LineLoopDrawMode: number;
  67690. /**
  67691. * Returns the line strip draw mode
  67692. */
  67693. static readonly MATERIAL_LineStripDrawMode: number;
  67694. /**
  67695. * Returns the triangle strip draw mode
  67696. */
  67697. static readonly MATERIAL_TriangleStripDrawMode: number;
  67698. /**
  67699. * Returns the triangle fan draw mode
  67700. */
  67701. static readonly MATERIAL_TriangleFanDrawMode: number;
  67702. /**
  67703. * Stores the clock-wise side orientation
  67704. */
  67705. static readonly MATERIAL_ClockWiseSideOrientation: number;
  67706. /**
  67707. * Stores the counter clock-wise side orientation
  67708. */
  67709. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  67710. /**
  67711. * Nothing
  67712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67713. */
  67714. static readonly ACTION_NothingTrigger: number;
  67715. /**
  67716. * On pick
  67717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67718. */
  67719. static readonly ACTION_OnPickTrigger: number;
  67720. /**
  67721. * On left pick
  67722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67723. */
  67724. static readonly ACTION_OnLeftPickTrigger: number;
  67725. /**
  67726. * On right pick
  67727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67728. */
  67729. static readonly ACTION_OnRightPickTrigger: number;
  67730. /**
  67731. * On center pick
  67732. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67733. */
  67734. static readonly ACTION_OnCenterPickTrigger: number;
  67735. /**
  67736. * On pick down
  67737. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67738. */
  67739. static readonly ACTION_OnPickDownTrigger: number;
  67740. /**
  67741. * On double pick
  67742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67743. */
  67744. static readonly ACTION_OnDoublePickTrigger: number;
  67745. /**
  67746. * On pick up
  67747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67748. */
  67749. static readonly ACTION_OnPickUpTrigger: number;
  67750. /**
  67751. * On pick out.
  67752. * This trigger will only be raised if you also declared a OnPickDown
  67753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67754. */
  67755. static readonly ACTION_OnPickOutTrigger: number;
  67756. /**
  67757. * On long press
  67758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67759. */
  67760. static readonly ACTION_OnLongPressTrigger: number;
  67761. /**
  67762. * On pointer over
  67763. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67764. */
  67765. static readonly ACTION_OnPointerOverTrigger: number;
  67766. /**
  67767. * On pointer out
  67768. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67769. */
  67770. static readonly ACTION_OnPointerOutTrigger: number;
  67771. /**
  67772. * On every frame
  67773. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67774. */
  67775. static readonly ACTION_OnEveryFrameTrigger: number;
  67776. /**
  67777. * On intersection enter
  67778. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67779. */
  67780. static readonly ACTION_OnIntersectionEnterTrigger: number;
  67781. /**
  67782. * On intersection exit
  67783. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67784. */
  67785. static readonly ACTION_OnIntersectionExitTrigger: number;
  67786. /**
  67787. * On key down
  67788. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67789. */
  67790. static readonly ACTION_OnKeyDownTrigger: number;
  67791. /**
  67792. * On key up
  67793. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67794. */
  67795. static readonly ACTION_OnKeyUpTrigger: number;
  67796. /**
  67797. * Billboard mode will only apply to Y axis
  67798. */
  67799. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  67800. /**
  67801. * Billboard mode will apply to all axes
  67802. */
  67803. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  67804. /**
  67805. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  67806. */
  67807. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  67808. /**
  67809. * Gets or sets base Assets URL
  67810. */
  67811. static PARTICLES_BaseAssetsUrl: string;
  67812. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  67813. * Test order :
  67814. * Is the bounding sphere outside the frustum ?
  67815. * If not, are the bounding box vertices outside the frustum ?
  67816. * It not, then the cullable object is in the frustum.
  67817. */
  67818. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  67819. /** Culling strategy : Bounding Sphere Only.
  67820. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  67821. * It's also less accurate than the standard because some not visible objects can still be selected.
  67822. * Test : is the bounding sphere outside the frustum ?
  67823. * If not, then the cullable object is in the frustum.
  67824. */
  67825. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  67826. /** Culling strategy : Optimistic Inclusion.
  67827. * This in an inclusion test first, then the standard exclusion test.
  67828. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  67829. * 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.
  67830. * Anyway, it's as accurate as the standard strategy.
  67831. * Test :
  67832. * Is the cullable object bounding sphere center in the frustum ?
  67833. * If not, apply the default culling strategy.
  67834. */
  67835. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  67836. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  67837. * This in an inclusion test first, then the bounding sphere only exclusion test.
  67838. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  67839. * 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.
  67840. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  67841. * Test :
  67842. * Is the cullable object bounding sphere center in the frustum ?
  67843. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  67844. */
  67845. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  67846. /**
  67847. * No logging while loading
  67848. */
  67849. static readonly SCENELOADER_NO_LOGGING: number;
  67850. /**
  67851. * Minimal logging while loading
  67852. */
  67853. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  67854. /**
  67855. * Summary logging while loading
  67856. */
  67857. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  67858. /**
  67859. * Detailled logging while loading
  67860. */
  67861. static readonly SCENELOADER_DETAILED_LOGGING: number;
  67862. }
  67863. }
  67864. declare module BABYLON {
  67865. /**
  67866. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  67867. * Babylon.js
  67868. */
  67869. export class DomManagement {
  67870. /**
  67871. * Checks if the window object exists
  67872. * @returns true if the window object exists
  67873. */
  67874. static IsWindowObjectExist(): boolean;
  67875. /**
  67876. * Extracts text content from a DOM element hierarchy
  67877. * @param element defines the root element
  67878. * @returns a string
  67879. */
  67880. static GetDOMTextContent(element: HTMLElement): string;
  67881. }
  67882. }
  67883. declare module BABYLON {
  67884. /**
  67885. * Logger used througouht the application to allow configuration of
  67886. * the log level required for the messages.
  67887. */
  67888. export class Logger {
  67889. /**
  67890. * No log
  67891. */
  67892. static readonly NoneLogLevel: number;
  67893. /**
  67894. * Only message logs
  67895. */
  67896. static readonly MessageLogLevel: number;
  67897. /**
  67898. * Only warning logs
  67899. */
  67900. static readonly WarningLogLevel: number;
  67901. /**
  67902. * Only error logs
  67903. */
  67904. static readonly ErrorLogLevel: number;
  67905. /**
  67906. * All logs
  67907. */
  67908. static readonly AllLogLevel: number;
  67909. private static _LogCache;
  67910. /**
  67911. * Gets a value indicating the number of loading errors
  67912. * @ignorenaming
  67913. */
  67914. static errorsCount: number;
  67915. /**
  67916. * Callback called when a new log is added
  67917. */
  67918. static OnNewCacheEntry: (entry: string) => void;
  67919. private static _AddLogEntry;
  67920. private static _FormatMessage;
  67921. private static _LogDisabled;
  67922. private static _LogEnabled;
  67923. private static _WarnDisabled;
  67924. private static _WarnEnabled;
  67925. private static _ErrorDisabled;
  67926. private static _ErrorEnabled;
  67927. /**
  67928. * Log a message to the console
  67929. */
  67930. static Log: (message: string) => void;
  67931. /**
  67932. * Write a warning message to the console
  67933. */
  67934. static Warn: (message: string) => void;
  67935. /**
  67936. * Write an error message to the console
  67937. */
  67938. static Error: (message: string) => void;
  67939. /**
  67940. * Gets current log cache (list of logs)
  67941. */
  67942. static readonly LogCache: string;
  67943. /**
  67944. * Clears the log cache
  67945. */
  67946. static ClearLogCache(): void;
  67947. /**
  67948. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  67949. */
  67950. static LogLevels: number;
  67951. }
  67952. }
  67953. declare module BABYLON {
  67954. /** @hidden */
  67955. export class _TypeStore {
  67956. /** @hidden */
  67957. static RegisteredTypes: {
  67958. [key: string]: Object;
  67959. };
  67960. /** @hidden */
  67961. static GetClass(fqdn: string): any;
  67962. }
  67963. }
  67964. declare module BABYLON {
  67965. /**
  67966. * Class containing a set of static utilities functions for deep copy.
  67967. */
  67968. export class DeepCopier {
  67969. /**
  67970. * Tries to copy an object by duplicating every property
  67971. * @param source defines the source object
  67972. * @param destination defines the target object
  67973. * @param doNotCopyList defines a list of properties to avoid
  67974. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  67975. */
  67976. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  67977. }
  67978. }
  67979. declare module BABYLON {
  67980. /**
  67981. * Class containing a set of static utilities functions for precision date
  67982. */
  67983. export class PrecisionDate {
  67984. /**
  67985. * Gets either window.performance.now() if supported or Date.now() else
  67986. */
  67987. static readonly Now: number;
  67988. }
  67989. }
  67990. declare module BABYLON {
  67991. /** @hidden */
  67992. export class _DevTools {
  67993. static WarnImport(name: string): string;
  67994. }
  67995. }
  67996. declare module BABYLON {
  67997. /**
  67998. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  67999. */
  68000. export class WebRequest {
  68001. private _xhr;
  68002. /**
  68003. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  68004. * i.e. when loading files, where the server/service expects an Authorization header
  68005. */
  68006. static CustomRequestHeaders: {
  68007. [key: string]: string;
  68008. };
  68009. /**
  68010. * Add callback functions in this array to update all the requests before they get sent to the network
  68011. */
  68012. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  68013. private _injectCustomRequestHeaders;
  68014. /**
  68015. * Gets or sets a function to be called when loading progress changes
  68016. */
  68017. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  68018. /**
  68019. * Returns client's state
  68020. */
  68021. readonly readyState: number;
  68022. /**
  68023. * Returns client's status
  68024. */
  68025. readonly status: number;
  68026. /**
  68027. * Returns client's status as a text
  68028. */
  68029. readonly statusText: string;
  68030. /**
  68031. * Returns client's response
  68032. */
  68033. readonly response: any;
  68034. /**
  68035. * Returns client's response url
  68036. */
  68037. readonly responseURL: string;
  68038. /**
  68039. * Returns client's response as text
  68040. */
  68041. readonly responseText: string;
  68042. /**
  68043. * Gets or sets the expected response type
  68044. */
  68045. responseType: XMLHttpRequestResponseType;
  68046. /** @hidden */
  68047. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  68048. /** @hidden */
  68049. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  68050. /**
  68051. * Cancels any network activity
  68052. */
  68053. abort(): void;
  68054. /**
  68055. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  68056. * @param body defines an optional request body
  68057. */
  68058. send(body?: Document | BodyInit | null): void;
  68059. /**
  68060. * Sets the request method, request URL
  68061. * @param method defines the method to use (GET, POST, etc..)
  68062. * @param url defines the url to connect with
  68063. */
  68064. open(method: string, url: string): void;
  68065. }
  68066. }
  68067. declare module BABYLON {
  68068. /**
  68069. * Class used to evalaute queries containing `and` and `or` operators
  68070. */
  68071. export class AndOrNotEvaluator {
  68072. /**
  68073. * Evaluate a query
  68074. * @param query defines the query to evaluate
  68075. * @param evaluateCallback defines the callback used to filter result
  68076. * @returns true if the query matches
  68077. */
  68078. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  68079. private static _HandleParenthesisContent;
  68080. private static _SimplifyNegation;
  68081. }
  68082. }
  68083. declare module BABYLON {
  68084. /**
  68085. * Class used to store custom tags
  68086. */
  68087. export class Tags {
  68088. /**
  68089. * Adds support for tags on the given object
  68090. * @param obj defines the object to use
  68091. */
  68092. static EnableFor(obj: any): void;
  68093. /**
  68094. * Removes tags support
  68095. * @param obj defines the object to use
  68096. */
  68097. static DisableFor(obj: any): void;
  68098. /**
  68099. * Gets a boolean indicating if the given object has tags
  68100. * @param obj defines the object to use
  68101. * @returns a boolean
  68102. */
  68103. static HasTags(obj: any): boolean;
  68104. /**
  68105. * Gets the tags available on a given object
  68106. * @param obj defines the object to use
  68107. * @param asString defines if the tags must be returned as a string instead of an array of strings
  68108. * @returns the tags
  68109. */
  68110. static GetTags(obj: any, asString?: boolean): any;
  68111. /**
  68112. * Adds tags to an object
  68113. * @param obj defines the object to use
  68114. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  68115. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  68116. */
  68117. static AddTagsTo(obj: any, tagsString: string): void;
  68118. /**
  68119. * @hidden
  68120. */
  68121. static _AddTagTo(obj: any, tag: string): void;
  68122. /**
  68123. * Removes specific tags from a specific object
  68124. * @param obj defines the object to use
  68125. * @param tagsString defines the tags to remove
  68126. */
  68127. static RemoveTagsFrom(obj: any, tagsString: string): void;
  68128. /**
  68129. * @hidden
  68130. */
  68131. static _RemoveTagFrom(obj: any, tag: string): void;
  68132. /**
  68133. * Defines if tags hosted on an object match a given query
  68134. * @param obj defines the object to use
  68135. * @param tagsQuery defines the tag query
  68136. * @returns a boolean
  68137. */
  68138. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  68139. }
  68140. }
  68141. declare module BABYLON {
  68142. /**
  68143. * Manages the defines for the Material
  68144. */
  68145. export class MaterialDefines {
  68146. /** @hidden */
  68147. protected _keys: string[];
  68148. private _isDirty;
  68149. /** @hidden */
  68150. _renderId: number;
  68151. /** @hidden */
  68152. _areLightsDirty: boolean;
  68153. /** @hidden */
  68154. _areAttributesDirty: boolean;
  68155. /** @hidden */
  68156. _areTexturesDirty: boolean;
  68157. /** @hidden */
  68158. _areFresnelDirty: boolean;
  68159. /** @hidden */
  68160. _areMiscDirty: boolean;
  68161. /** @hidden */
  68162. _areImageProcessingDirty: boolean;
  68163. /** @hidden */
  68164. _normals: boolean;
  68165. /** @hidden */
  68166. _uvs: boolean;
  68167. /** @hidden */
  68168. _needNormals: boolean;
  68169. /** @hidden */
  68170. _needUVs: boolean;
  68171. [id: string]: any;
  68172. /**
  68173. * Specifies if the material needs to be re-calculated
  68174. */
  68175. readonly isDirty: boolean;
  68176. /**
  68177. * Marks the material to indicate that it has been re-calculated
  68178. */
  68179. markAsProcessed(): void;
  68180. /**
  68181. * Marks the material to indicate that it needs to be re-calculated
  68182. */
  68183. markAsUnprocessed(): void;
  68184. /**
  68185. * Marks the material to indicate all of its defines need to be re-calculated
  68186. */
  68187. markAllAsDirty(): void;
  68188. /**
  68189. * Marks the material to indicate that image processing needs to be re-calculated
  68190. */
  68191. markAsImageProcessingDirty(): void;
  68192. /**
  68193. * Marks the material to indicate the lights need to be re-calculated
  68194. */
  68195. markAsLightDirty(): void;
  68196. /**
  68197. * Marks the attribute state as changed
  68198. */
  68199. markAsAttributesDirty(): void;
  68200. /**
  68201. * Marks the texture state as changed
  68202. */
  68203. markAsTexturesDirty(): void;
  68204. /**
  68205. * Marks the fresnel state as changed
  68206. */
  68207. markAsFresnelDirty(): void;
  68208. /**
  68209. * Marks the misc state as changed
  68210. */
  68211. markAsMiscDirty(): void;
  68212. /**
  68213. * Rebuilds the material defines
  68214. */
  68215. rebuild(): void;
  68216. /**
  68217. * Specifies if two material defines are equal
  68218. * @param other - A material define instance to compare to
  68219. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  68220. */
  68221. isEqual(other: MaterialDefines): boolean;
  68222. /**
  68223. * Clones this instance's defines to another instance
  68224. * @param other - material defines to clone values to
  68225. */
  68226. cloneTo(other: MaterialDefines): void;
  68227. /**
  68228. * Resets the material define values
  68229. */
  68230. reset(): void;
  68231. /**
  68232. * Converts the material define values to a string
  68233. * @returns - String of material define information
  68234. */
  68235. toString(): string;
  68236. }
  68237. }
  68238. declare module BABYLON {
  68239. /**
  68240. * Class used to store and describe the pipeline context associated with an effect
  68241. */
  68242. export interface IPipelineContext {
  68243. /**
  68244. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  68245. */
  68246. isAsync: boolean;
  68247. /**
  68248. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  68249. */
  68250. isReady: boolean;
  68251. /** @hidden */
  68252. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  68253. }
  68254. }
  68255. declare module BABYLON {
  68256. /**
  68257. * Class used to store gfx data (like WebGLBuffer)
  68258. */
  68259. export class DataBuffer {
  68260. /**
  68261. * Gets or sets the number of objects referencing this buffer
  68262. */
  68263. references: number;
  68264. /** Gets or sets the size of the underlying buffer */
  68265. capacity: number;
  68266. /**
  68267. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  68268. */
  68269. is32Bits: boolean;
  68270. /**
  68271. * Gets the underlying buffer
  68272. */
  68273. readonly underlyingResource: any;
  68274. }
  68275. }
  68276. declare module BABYLON {
  68277. /** @hidden */
  68278. export interface IShaderProcessor {
  68279. attributeProcessor?: (attribute: string) => string;
  68280. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  68281. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  68282. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  68283. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  68284. lineProcessor?: (line: string, isFragment: boolean) => string;
  68285. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68286. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68287. }
  68288. }
  68289. declare module BABYLON {
  68290. /** @hidden */
  68291. export interface ProcessingOptions {
  68292. defines: string[];
  68293. indexParameters: any;
  68294. isFragment: boolean;
  68295. shouldUseHighPrecisionShader: boolean;
  68296. supportsUniformBuffers: boolean;
  68297. shadersRepository: string;
  68298. includesShadersStore: {
  68299. [key: string]: string;
  68300. };
  68301. processor?: IShaderProcessor;
  68302. version: string;
  68303. platformName: string;
  68304. lookForClosingBracketForUniformBuffer?: boolean;
  68305. }
  68306. }
  68307. declare module BABYLON {
  68308. /** @hidden */
  68309. export class ShaderCodeNode {
  68310. line: string;
  68311. children: ShaderCodeNode[];
  68312. additionalDefineKey?: string;
  68313. additionalDefineValue?: string;
  68314. isValid(preprocessors: {
  68315. [key: string]: string;
  68316. }): boolean;
  68317. process(preprocessors: {
  68318. [key: string]: string;
  68319. }, options: ProcessingOptions): string;
  68320. }
  68321. }
  68322. declare module BABYLON {
  68323. /** @hidden */
  68324. export class ShaderCodeCursor {
  68325. private _lines;
  68326. lineIndex: number;
  68327. readonly currentLine: string;
  68328. readonly canRead: boolean;
  68329. lines: string[];
  68330. }
  68331. }
  68332. declare module BABYLON {
  68333. /** @hidden */
  68334. export class ShaderCodeConditionNode extends ShaderCodeNode {
  68335. process(preprocessors: {
  68336. [key: string]: string;
  68337. }, options: ProcessingOptions): string;
  68338. }
  68339. }
  68340. declare module BABYLON {
  68341. /** @hidden */
  68342. export class ShaderDefineExpression {
  68343. isTrue(preprocessors: {
  68344. [key: string]: string;
  68345. }): boolean;
  68346. }
  68347. }
  68348. declare module BABYLON {
  68349. /** @hidden */
  68350. export class ShaderCodeTestNode extends ShaderCodeNode {
  68351. testExpression: ShaderDefineExpression;
  68352. isValid(preprocessors: {
  68353. [key: string]: string;
  68354. }): boolean;
  68355. }
  68356. }
  68357. declare module BABYLON {
  68358. /** @hidden */
  68359. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  68360. define: string;
  68361. not: boolean;
  68362. constructor(define: string, not?: boolean);
  68363. isTrue(preprocessors: {
  68364. [key: string]: string;
  68365. }): boolean;
  68366. }
  68367. }
  68368. declare module BABYLON {
  68369. /** @hidden */
  68370. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  68371. leftOperand: ShaderDefineExpression;
  68372. rightOperand: ShaderDefineExpression;
  68373. isTrue(preprocessors: {
  68374. [key: string]: string;
  68375. }): boolean;
  68376. }
  68377. }
  68378. declare module BABYLON {
  68379. /** @hidden */
  68380. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  68381. leftOperand: ShaderDefineExpression;
  68382. rightOperand: ShaderDefineExpression;
  68383. isTrue(preprocessors: {
  68384. [key: string]: string;
  68385. }): boolean;
  68386. }
  68387. }
  68388. declare module BABYLON {
  68389. /** @hidden */
  68390. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  68391. define: string;
  68392. operand: string;
  68393. testValue: string;
  68394. constructor(define: string, operand: string, testValue: string);
  68395. isTrue(preprocessors: {
  68396. [key: string]: string;
  68397. }): boolean;
  68398. }
  68399. }
  68400. declare module BABYLON {
  68401. /** @hidden */
  68402. export class ShaderProcessor {
  68403. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  68404. private static _ProcessPrecision;
  68405. private static _ExtractOperation;
  68406. private static _BuildSubExpression;
  68407. private static _BuildExpression;
  68408. private static _MoveCursorWithinIf;
  68409. private static _MoveCursor;
  68410. private static _EvaluatePreProcessors;
  68411. private static _PreparePreProcessors;
  68412. private static _ProcessShaderConversion;
  68413. private static _ProcessIncludes;
  68414. }
  68415. }
  68416. declare module BABYLON {
  68417. /**
  68418. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  68419. */
  68420. export class PerformanceMonitor {
  68421. private _enabled;
  68422. private _rollingFrameTime;
  68423. private _lastFrameTimeMs;
  68424. /**
  68425. * constructor
  68426. * @param frameSampleSize The number of samples required to saturate the sliding window
  68427. */
  68428. constructor(frameSampleSize?: number);
  68429. /**
  68430. * Samples current frame
  68431. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  68432. */
  68433. sampleFrame(timeMs?: number): void;
  68434. /**
  68435. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  68436. */
  68437. readonly averageFrameTime: number;
  68438. /**
  68439. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  68440. */
  68441. readonly averageFrameTimeVariance: number;
  68442. /**
  68443. * Returns the frame time of the most recent frame
  68444. */
  68445. readonly instantaneousFrameTime: number;
  68446. /**
  68447. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  68448. */
  68449. readonly averageFPS: number;
  68450. /**
  68451. * Returns the average framerate in frames per second using the most recent frame time
  68452. */
  68453. readonly instantaneousFPS: number;
  68454. /**
  68455. * Returns true if enough samples have been taken to completely fill the sliding window
  68456. */
  68457. readonly isSaturated: boolean;
  68458. /**
  68459. * Enables contributions to the sliding window sample set
  68460. */
  68461. enable(): void;
  68462. /**
  68463. * Disables contributions to the sliding window sample set
  68464. * Samples will not be interpolated over the disabled period
  68465. */
  68466. disable(): void;
  68467. /**
  68468. * Returns true if sampling is enabled
  68469. */
  68470. readonly isEnabled: boolean;
  68471. /**
  68472. * Resets performance monitor
  68473. */
  68474. reset(): void;
  68475. }
  68476. /**
  68477. * RollingAverage
  68478. *
  68479. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  68480. */
  68481. export class RollingAverage {
  68482. /**
  68483. * Current average
  68484. */
  68485. average: number;
  68486. /**
  68487. * Current variance
  68488. */
  68489. variance: number;
  68490. protected _samples: Array<number>;
  68491. protected _sampleCount: number;
  68492. protected _pos: number;
  68493. protected _m2: number;
  68494. /**
  68495. * constructor
  68496. * @param length The number of samples required to saturate the sliding window
  68497. */
  68498. constructor(length: number);
  68499. /**
  68500. * Adds a sample to the sample set
  68501. * @param v The sample value
  68502. */
  68503. add(v: number): void;
  68504. /**
  68505. * Returns previously added values or null if outside of history or outside the sliding window domain
  68506. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  68507. * @return Value previously recorded with add() or null if outside of range
  68508. */
  68509. history(i: number): number;
  68510. /**
  68511. * Returns true if enough samples have been taken to completely fill the sliding window
  68512. * @return true if sample-set saturated
  68513. */
  68514. isSaturated(): boolean;
  68515. /**
  68516. * Resets the rolling average (equivalent to 0 samples taken so far)
  68517. */
  68518. reset(): void;
  68519. /**
  68520. * Wraps a value around the sample range boundaries
  68521. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  68522. * @return Wrapped position in sample range
  68523. */
  68524. protected _wrapPosition(i: number): number;
  68525. }
  68526. }
  68527. declare module BABYLON {
  68528. /**
  68529. * This class implement a typical dictionary using a string as key and the generic type T as value.
  68530. * The underlying implementation relies on an associative array to ensure the best performances.
  68531. * The value can be anything including 'null' but except 'undefined'
  68532. */
  68533. export class StringDictionary<T> {
  68534. /**
  68535. * This will clear this dictionary and copy the content from the 'source' one.
  68536. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  68537. * @param source the dictionary to take the content from and copy to this dictionary
  68538. */
  68539. copyFrom(source: StringDictionary<T>): void;
  68540. /**
  68541. * Get a value based from its key
  68542. * @param key the given key to get the matching value from
  68543. * @return the value if found, otherwise undefined is returned
  68544. */
  68545. get(key: string): T | undefined;
  68546. /**
  68547. * Get a value from its key or add it if it doesn't exist.
  68548. * This method will ensure you that a given key/data will be present in the dictionary.
  68549. * @param key the given key to get the matching value from
  68550. * @param factory the factory that will create the value if the key is not present in the dictionary.
  68551. * The factory will only be invoked if there's no data for the given key.
  68552. * @return the value corresponding to the key.
  68553. */
  68554. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  68555. /**
  68556. * Get a value from its key if present in the dictionary otherwise add it
  68557. * @param key the key to get the value from
  68558. * @param val if there's no such key/value pair in the dictionary add it with this value
  68559. * @return the value corresponding to the key
  68560. */
  68561. getOrAdd(key: string, val: T): T;
  68562. /**
  68563. * Check if there's a given key in the dictionary
  68564. * @param key the key to check for
  68565. * @return true if the key is present, false otherwise
  68566. */
  68567. contains(key: string): boolean;
  68568. /**
  68569. * Add a new key and its corresponding value
  68570. * @param key the key to add
  68571. * @param value the value corresponding to the key
  68572. * @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
  68573. */
  68574. add(key: string, value: T): boolean;
  68575. /**
  68576. * Update a specific value associated to a key
  68577. * @param key defines the key to use
  68578. * @param value defines the value to store
  68579. * @returns true if the value was updated (or false if the key was not found)
  68580. */
  68581. set(key: string, value: T): boolean;
  68582. /**
  68583. * Get the element of the given key and remove it from the dictionary
  68584. * @param key defines the key to search
  68585. * @returns the value associated with the key or null if not found
  68586. */
  68587. getAndRemove(key: string): Nullable<T>;
  68588. /**
  68589. * Remove a key/value from the dictionary.
  68590. * @param key the key to remove
  68591. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  68592. */
  68593. remove(key: string): boolean;
  68594. /**
  68595. * Clear the whole content of the dictionary
  68596. */
  68597. clear(): void;
  68598. /**
  68599. * Gets the current count
  68600. */
  68601. readonly count: number;
  68602. /**
  68603. * Execute a callback on each key/val of the dictionary.
  68604. * Note that you can remove any element in this dictionary in the callback implementation
  68605. * @param callback the callback to execute on a given key/value pair
  68606. */
  68607. forEach(callback: (key: string, val: T) => void): void;
  68608. /**
  68609. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  68610. * If the callback returns null or undefined the method will iterate to the next key/value pair
  68611. * Note that you can remove any element in this dictionary in the callback implementation
  68612. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  68613. * @returns the first item
  68614. */
  68615. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  68616. private _count;
  68617. private _data;
  68618. }
  68619. }
  68620. declare module BABYLON {
  68621. /**
  68622. * Helper class that provides a small promise polyfill
  68623. */
  68624. export class PromisePolyfill {
  68625. /**
  68626. * Static function used to check if the polyfill is required
  68627. * If this is the case then the function will inject the polyfill to window.Promise
  68628. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  68629. */
  68630. static Apply(force?: boolean): void;
  68631. }
  68632. }
  68633. declare module BABYLON {
  68634. /**
  68635. * Class used to store data that will be store in GPU memory
  68636. */
  68637. export class Buffer {
  68638. private _engine;
  68639. private _buffer;
  68640. /** @hidden */
  68641. _data: Nullable<DataArray>;
  68642. private _updatable;
  68643. private _instanced;
  68644. /**
  68645. * Gets the byte stride.
  68646. */
  68647. readonly byteStride: number;
  68648. /**
  68649. * Constructor
  68650. * @param engine the engine
  68651. * @param data the data to use for this buffer
  68652. * @param updatable whether the data is updatable
  68653. * @param stride the stride (optional)
  68654. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  68655. * @param instanced whether the buffer is instanced (optional)
  68656. * @param useBytes set to true if the stride in in bytes (optional)
  68657. */
  68658. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  68659. /**
  68660. * Create a new VertexBuffer based on the current buffer
  68661. * @param kind defines the vertex buffer kind (position, normal, etc.)
  68662. * @param offset defines offset in the buffer (0 by default)
  68663. * @param size defines the size in floats of attributes (position is 3 for instance)
  68664. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  68665. * @param instanced defines if the vertex buffer contains indexed data
  68666. * @param useBytes defines if the offset and stride are in bytes
  68667. * @returns the new vertex buffer
  68668. */
  68669. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  68670. /**
  68671. * Gets a boolean indicating if the Buffer is updatable?
  68672. * @returns true if the buffer is updatable
  68673. */
  68674. isUpdatable(): boolean;
  68675. /**
  68676. * Gets current buffer's data
  68677. * @returns a DataArray or null
  68678. */
  68679. getData(): Nullable<DataArray>;
  68680. /**
  68681. * Gets underlying native buffer
  68682. * @returns underlying native buffer
  68683. */
  68684. getBuffer(): Nullable<DataBuffer>;
  68685. /**
  68686. * Gets the stride in float32 units (i.e. byte stride / 4).
  68687. * May not be an integer if the byte stride is not divisible by 4.
  68688. * DEPRECATED. Use byteStride instead.
  68689. * @returns the stride in float32 units
  68690. */
  68691. getStrideSize(): number;
  68692. /**
  68693. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  68694. * @param data defines the data to store
  68695. */
  68696. create(data?: Nullable<DataArray>): void;
  68697. /** @hidden */
  68698. _rebuild(): void;
  68699. /**
  68700. * Update current buffer data
  68701. * @param data defines the data to store
  68702. */
  68703. update(data: DataArray): void;
  68704. /**
  68705. * Updates the data directly.
  68706. * @param data the new data
  68707. * @param offset the new offset
  68708. * @param vertexCount the vertex count (optional)
  68709. * @param useBytes set to true if the offset is in bytes
  68710. */
  68711. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  68712. /**
  68713. * Release all resources
  68714. */
  68715. dispose(): void;
  68716. }
  68717. /**
  68718. * Specialized buffer used to store vertex data
  68719. */
  68720. export class VertexBuffer {
  68721. /** @hidden */
  68722. _buffer: Buffer;
  68723. private _kind;
  68724. private _size;
  68725. private _ownsBuffer;
  68726. private _instanced;
  68727. private _instanceDivisor;
  68728. /**
  68729. * The byte type.
  68730. */
  68731. static readonly BYTE: number;
  68732. /**
  68733. * The unsigned byte type.
  68734. */
  68735. static readonly UNSIGNED_BYTE: number;
  68736. /**
  68737. * The short type.
  68738. */
  68739. static readonly SHORT: number;
  68740. /**
  68741. * The unsigned short type.
  68742. */
  68743. static readonly UNSIGNED_SHORT: number;
  68744. /**
  68745. * The integer type.
  68746. */
  68747. static readonly INT: number;
  68748. /**
  68749. * The unsigned integer type.
  68750. */
  68751. static readonly UNSIGNED_INT: number;
  68752. /**
  68753. * The float type.
  68754. */
  68755. static readonly FLOAT: number;
  68756. /**
  68757. * Gets or sets the instance divisor when in instanced mode
  68758. */
  68759. instanceDivisor: number;
  68760. /**
  68761. * Gets the byte stride.
  68762. */
  68763. readonly byteStride: number;
  68764. /**
  68765. * Gets the byte offset.
  68766. */
  68767. readonly byteOffset: number;
  68768. /**
  68769. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  68770. */
  68771. readonly normalized: boolean;
  68772. /**
  68773. * Gets the data type of each component in the array.
  68774. */
  68775. readonly type: number;
  68776. /**
  68777. * Constructor
  68778. * @param engine the engine
  68779. * @param data the data to use for this vertex buffer
  68780. * @param kind the vertex buffer kind
  68781. * @param updatable whether the data is updatable
  68782. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  68783. * @param stride the stride (optional)
  68784. * @param instanced whether the buffer is instanced (optional)
  68785. * @param offset the offset of the data (optional)
  68786. * @param size the number of components (optional)
  68787. * @param type the type of the component (optional)
  68788. * @param normalized whether the data contains normalized data (optional)
  68789. * @param useBytes set to true if stride and offset are in bytes (optional)
  68790. */
  68791. 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);
  68792. /** @hidden */
  68793. _rebuild(): void;
  68794. /**
  68795. * Returns the kind of the VertexBuffer (string)
  68796. * @returns a string
  68797. */
  68798. getKind(): string;
  68799. /**
  68800. * Gets a boolean indicating if the VertexBuffer is updatable?
  68801. * @returns true if the buffer is updatable
  68802. */
  68803. isUpdatable(): boolean;
  68804. /**
  68805. * Gets current buffer's data
  68806. * @returns a DataArray or null
  68807. */
  68808. getData(): Nullable<DataArray>;
  68809. /**
  68810. * Gets underlying native buffer
  68811. * @returns underlying native buffer
  68812. */
  68813. getBuffer(): Nullable<DataBuffer>;
  68814. /**
  68815. * Gets the stride in float32 units (i.e. byte stride / 4).
  68816. * May not be an integer if the byte stride is not divisible by 4.
  68817. * DEPRECATED. Use byteStride instead.
  68818. * @returns the stride in float32 units
  68819. */
  68820. getStrideSize(): number;
  68821. /**
  68822. * Returns the offset as a multiple of the type byte length.
  68823. * DEPRECATED. Use byteOffset instead.
  68824. * @returns the offset in bytes
  68825. */
  68826. getOffset(): number;
  68827. /**
  68828. * Returns the number of components per vertex attribute (integer)
  68829. * @returns the size in float
  68830. */
  68831. getSize(): number;
  68832. /**
  68833. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  68834. * @returns true if this buffer is instanced
  68835. */
  68836. getIsInstanced(): boolean;
  68837. /**
  68838. * Returns the instancing divisor, zero for non-instanced (integer).
  68839. * @returns a number
  68840. */
  68841. getInstanceDivisor(): number;
  68842. /**
  68843. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  68844. * @param data defines the data to store
  68845. */
  68846. create(data?: DataArray): void;
  68847. /**
  68848. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  68849. * This function will create a new buffer if the current one is not updatable
  68850. * @param data defines the data to store
  68851. */
  68852. update(data: DataArray): void;
  68853. /**
  68854. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  68855. * Returns the directly updated WebGLBuffer.
  68856. * @param data the new data
  68857. * @param offset the new offset
  68858. * @param useBytes set to true if the offset is in bytes
  68859. */
  68860. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  68861. /**
  68862. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  68863. */
  68864. dispose(): void;
  68865. /**
  68866. * Enumerates each value of this vertex buffer as numbers.
  68867. * @param count the number of values to enumerate
  68868. * @param callback the callback function called for each value
  68869. */
  68870. forEach(count: number, callback: (value: number, index: number) => void): void;
  68871. /**
  68872. * Positions
  68873. */
  68874. static readonly PositionKind: string;
  68875. /**
  68876. * Normals
  68877. */
  68878. static readonly NormalKind: string;
  68879. /**
  68880. * Tangents
  68881. */
  68882. static readonly TangentKind: string;
  68883. /**
  68884. * Texture coordinates
  68885. */
  68886. static readonly UVKind: string;
  68887. /**
  68888. * Texture coordinates 2
  68889. */
  68890. static readonly UV2Kind: string;
  68891. /**
  68892. * Texture coordinates 3
  68893. */
  68894. static readonly UV3Kind: string;
  68895. /**
  68896. * Texture coordinates 4
  68897. */
  68898. static readonly UV4Kind: string;
  68899. /**
  68900. * Texture coordinates 5
  68901. */
  68902. static readonly UV5Kind: string;
  68903. /**
  68904. * Texture coordinates 6
  68905. */
  68906. static readonly UV6Kind: string;
  68907. /**
  68908. * Colors
  68909. */
  68910. static readonly ColorKind: string;
  68911. /**
  68912. * Matrix indices (for bones)
  68913. */
  68914. static readonly MatricesIndicesKind: string;
  68915. /**
  68916. * Matrix weights (for bones)
  68917. */
  68918. static readonly MatricesWeightsKind: string;
  68919. /**
  68920. * Additional matrix indices (for bones)
  68921. */
  68922. static readonly MatricesIndicesExtraKind: string;
  68923. /**
  68924. * Additional matrix weights (for bones)
  68925. */
  68926. static readonly MatricesWeightsExtraKind: string;
  68927. /**
  68928. * Deduces the stride given a kind.
  68929. * @param kind The kind string to deduce
  68930. * @returns The deduced stride
  68931. */
  68932. static DeduceStride(kind: string): number;
  68933. /**
  68934. * Gets the byte length of the given type.
  68935. * @param type the type
  68936. * @returns the number of bytes
  68937. */
  68938. static GetTypeByteLength(type: number): number;
  68939. /**
  68940. * Enumerates each value of the given parameters as numbers.
  68941. * @param data the data to enumerate
  68942. * @param byteOffset the byte offset of the data
  68943. * @param byteStride the byte stride of the data
  68944. * @param componentCount the number of components per element
  68945. * @param componentType the type of the component
  68946. * @param count the number of values to enumerate
  68947. * @param normalized whether the data is normalized
  68948. * @param callback the callback function called for each value
  68949. */
  68950. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  68951. private static _GetFloatValue;
  68952. }
  68953. }
  68954. declare module BABYLON {
  68955. /**
  68956. * Class representing spherical harmonics coefficients to the 3rd degree
  68957. */
  68958. export class SphericalHarmonics {
  68959. /**
  68960. * Defines whether or not the harmonics have been prescaled for rendering.
  68961. */
  68962. preScaled: boolean;
  68963. /**
  68964. * The l0,0 coefficients of the spherical harmonics
  68965. */
  68966. l00: Vector3;
  68967. /**
  68968. * The l1,-1 coefficients of the spherical harmonics
  68969. */
  68970. l1_1: Vector3;
  68971. /**
  68972. * The l1,0 coefficients of the spherical harmonics
  68973. */
  68974. l10: Vector3;
  68975. /**
  68976. * The l1,1 coefficients of the spherical harmonics
  68977. */
  68978. l11: Vector3;
  68979. /**
  68980. * The l2,-2 coefficients of the spherical harmonics
  68981. */
  68982. l2_2: Vector3;
  68983. /**
  68984. * The l2,-1 coefficients of the spherical harmonics
  68985. */
  68986. l2_1: Vector3;
  68987. /**
  68988. * The l2,0 coefficients of the spherical harmonics
  68989. */
  68990. l20: Vector3;
  68991. /**
  68992. * The l2,1 coefficients of the spherical harmonics
  68993. */
  68994. l21: Vector3;
  68995. /**
  68996. * The l2,2 coefficients of the spherical harmonics
  68997. */
  68998. l22: Vector3;
  68999. /**
  69000. * Adds a light to the spherical harmonics
  69001. * @param direction the direction of the light
  69002. * @param color the color of the light
  69003. * @param deltaSolidAngle the delta solid angle of the light
  69004. */
  69005. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  69006. /**
  69007. * Scales the spherical harmonics by the given amount
  69008. * @param scale the amount to scale
  69009. */
  69010. scaleInPlace(scale: number): void;
  69011. /**
  69012. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  69013. *
  69014. * ```
  69015. * E_lm = A_l * L_lm
  69016. * ```
  69017. *
  69018. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  69019. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  69020. * the scaling factors are given in equation 9.
  69021. */
  69022. convertIncidentRadianceToIrradiance(): void;
  69023. /**
  69024. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  69025. *
  69026. * ```
  69027. * L = (1/pi) * E * rho
  69028. * ```
  69029. *
  69030. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  69031. */
  69032. convertIrradianceToLambertianRadiance(): void;
  69033. /**
  69034. * Integrates the reconstruction coefficients directly in to the SH preventing further
  69035. * required operations at run time.
  69036. *
  69037. * This is simply done by scaling back the SH with Ylm constants parameter.
  69038. * The trigonometric part being applied by the shader at run time.
  69039. */
  69040. preScaleForRendering(): void;
  69041. /**
  69042. * Constructs a spherical harmonics from an array.
  69043. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  69044. * @returns the spherical harmonics
  69045. */
  69046. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  69047. /**
  69048. * Gets the spherical harmonics from polynomial
  69049. * @param polynomial the spherical polynomial
  69050. * @returns the spherical harmonics
  69051. */
  69052. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  69053. }
  69054. /**
  69055. * Class representing spherical polynomial coefficients to the 3rd degree
  69056. */
  69057. export class SphericalPolynomial {
  69058. private _harmonics;
  69059. /**
  69060. * The spherical harmonics used to create the polynomials.
  69061. */
  69062. readonly preScaledHarmonics: SphericalHarmonics;
  69063. /**
  69064. * The x coefficients of the spherical polynomial
  69065. */
  69066. x: Vector3;
  69067. /**
  69068. * The y coefficients of the spherical polynomial
  69069. */
  69070. y: Vector3;
  69071. /**
  69072. * The z coefficients of the spherical polynomial
  69073. */
  69074. z: Vector3;
  69075. /**
  69076. * The xx coefficients of the spherical polynomial
  69077. */
  69078. xx: Vector3;
  69079. /**
  69080. * The yy coefficients of the spherical polynomial
  69081. */
  69082. yy: Vector3;
  69083. /**
  69084. * The zz coefficients of the spherical polynomial
  69085. */
  69086. zz: Vector3;
  69087. /**
  69088. * The xy coefficients of the spherical polynomial
  69089. */
  69090. xy: Vector3;
  69091. /**
  69092. * The yz coefficients of the spherical polynomial
  69093. */
  69094. yz: Vector3;
  69095. /**
  69096. * The zx coefficients of the spherical polynomial
  69097. */
  69098. zx: Vector3;
  69099. /**
  69100. * Adds an ambient color to the spherical polynomial
  69101. * @param color the color to add
  69102. */
  69103. addAmbient(color: Color3): void;
  69104. /**
  69105. * Scales the spherical polynomial by the given amount
  69106. * @param scale the amount to scale
  69107. */
  69108. scaleInPlace(scale: number): void;
  69109. /**
  69110. * Gets the spherical polynomial from harmonics
  69111. * @param harmonics the spherical harmonics
  69112. * @returns the spherical polynomial
  69113. */
  69114. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  69115. /**
  69116. * Constructs a spherical polynomial from an array.
  69117. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  69118. * @returns the spherical polynomial
  69119. */
  69120. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  69121. }
  69122. }
  69123. declare module BABYLON {
  69124. /**
  69125. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  69126. */
  69127. export interface CubeMapInfo {
  69128. /**
  69129. * The pixel array for the front face.
  69130. * This is stored in format, left to right, up to down format.
  69131. */
  69132. front: Nullable<ArrayBufferView>;
  69133. /**
  69134. * The pixel array for the back face.
  69135. * This is stored in format, left to right, up to down format.
  69136. */
  69137. back: Nullable<ArrayBufferView>;
  69138. /**
  69139. * The pixel array for the left face.
  69140. * This is stored in format, left to right, up to down format.
  69141. */
  69142. left: Nullable<ArrayBufferView>;
  69143. /**
  69144. * The pixel array for the right face.
  69145. * This is stored in format, left to right, up to down format.
  69146. */
  69147. right: Nullable<ArrayBufferView>;
  69148. /**
  69149. * The pixel array for the up face.
  69150. * This is stored in format, left to right, up to down format.
  69151. */
  69152. up: Nullable<ArrayBufferView>;
  69153. /**
  69154. * The pixel array for the down face.
  69155. * This is stored in format, left to right, up to down format.
  69156. */
  69157. down: Nullable<ArrayBufferView>;
  69158. /**
  69159. * The size of the cubemap stored.
  69160. *
  69161. * Each faces will be size * size pixels.
  69162. */
  69163. size: number;
  69164. /**
  69165. * The format of the texture.
  69166. *
  69167. * RGBA, RGB.
  69168. */
  69169. format: number;
  69170. /**
  69171. * The type of the texture data.
  69172. *
  69173. * UNSIGNED_INT, FLOAT.
  69174. */
  69175. type: number;
  69176. /**
  69177. * Specifies whether the texture is in gamma space.
  69178. */
  69179. gammaSpace: boolean;
  69180. }
  69181. /**
  69182. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  69183. */
  69184. export class PanoramaToCubeMapTools {
  69185. private static FACE_FRONT;
  69186. private static FACE_BACK;
  69187. private static FACE_RIGHT;
  69188. private static FACE_LEFT;
  69189. private static FACE_DOWN;
  69190. private static FACE_UP;
  69191. /**
  69192. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  69193. *
  69194. * @param float32Array The source data.
  69195. * @param inputWidth The width of the input panorama.
  69196. * @param inputHeight The height of the input panorama.
  69197. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  69198. * @return The cubemap data
  69199. */
  69200. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  69201. private static CreateCubemapTexture;
  69202. private static CalcProjectionSpherical;
  69203. }
  69204. }
  69205. declare module BABYLON {
  69206. /**
  69207. * Helper class dealing with the extraction of spherical polynomial dataArray
  69208. * from a cube map.
  69209. */
  69210. export class CubeMapToSphericalPolynomialTools {
  69211. private static FileFaces;
  69212. /**
  69213. * Converts a texture to the according Spherical Polynomial data.
  69214. * This extracts the first 3 orders only as they are the only one used in the lighting.
  69215. *
  69216. * @param texture The texture to extract the information from.
  69217. * @return The Spherical Polynomial data.
  69218. */
  69219. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  69220. /**
  69221. * Converts a cubemap to the according Spherical Polynomial data.
  69222. * This extracts the first 3 orders only as they are the only one used in the lighting.
  69223. *
  69224. * @param cubeInfo The Cube map to extract the information from.
  69225. * @return The Spherical Polynomial data.
  69226. */
  69227. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  69228. }
  69229. }
  69230. declare module BABYLON {
  69231. /**
  69232. * The engine store class is responsible to hold all the instances of Engine and Scene created
  69233. * during the life time of the application.
  69234. */
  69235. export class EngineStore {
  69236. /** Gets the list of created engines */
  69237. static Instances: Engine[];
  69238. /** @hidden */
  69239. static _LastCreatedScene: Nullable<Scene>;
  69240. /**
  69241. * Gets the latest created engine
  69242. */
  69243. static readonly LastCreatedEngine: Nullable<Engine>;
  69244. /**
  69245. * Gets the latest created scene
  69246. */
  69247. static readonly LastCreatedScene: Nullable<Scene>;
  69248. }
  69249. }
  69250. declare module BABYLON {
  69251. /**
  69252. * Define options used to create a render target texture
  69253. */
  69254. export class RenderTargetCreationOptions {
  69255. /**
  69256. * Specifies is mipmaps must be generated
  69257. */
  69258. generateMipMaps?: boolean;
  69259. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  69260. generateDepthBuffer?: boolean;
  69261. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  69262. generateStencilBuffer?: boolean;
  69263. /** Defines texture type (int by default) */
  69264. type?: number;
  69265. /** Defines sampling mode (trilinear by default) */
  69266. samplingMode?: number;
  69267. /** Defines format (RGBA by default) */
  69268. format?: number;
  69269. }
  69270. }
  69271. declare module BABYLON {
  69272. /**
  69273. * @hidden
  69274. **/
  69275. export class _AlphaState {
  69276. private _isAlphaBlendDirty;
  69277. private _isBlendFunctionParametersDirty;
  69278. private _isBlendEquationParametersDirty;
  69279. private _isBlendConstantsDirty;
  69280. private _alphaBlend;
  69281. private _blendFunctionParameters;
  69282. private _blendEquationParameters;
  69283. private _blendConstants;
  69284. /**
  69285. * Initializes the state.
  69286. */
  69287. constructor();
  69288. readonly isDirty: boolean;
  69289. alphaBlend: boolean;
  69290. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  69291. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  69292. setAlphaEquationParameters(rgb: number, alpha: number): void;
  69293. reset(): void;
  69294. apply(gl: WebGLRenderingContext): void;
  69295. }
  69296. }
  69297. declare module BABYLON {
  69298. /**
  69299. * @hidden
  69300. **/
  69301. export class _DepthCullingState {
  69302. private _isDepthTestDirty;
  69303. private _isDepthMaskDirty;
  69304. private _isDepthFuncDirty;
  69305. private _isCullFaceDirty;
  69306. private _isCullDirty;
  69307. private _isZOffsetDirty;
  69308. private _isFrontFaceDirty;
  69309. private _depthTest;
  69310. private _depthMask;
  69311. private _depthFunc;
  69312. private _cull;
  69313. private _cullFace;
  69314. private _zOffset;
  69315. private _frontFace;
  69316. /**
  69317. * Initializes the state.
  69318. */
  69319. constructor();
  69320. readonly isDirty: boolean;
  69321. zOffset: number;
  69322. cullFace: Nullable<number>;
  69323. cull: Nullable<boolean>;
  69324. depthFunc: Nullable<number>;
  69325. depthMask: boolean;
  69326. depthTest: boolean;
  69327. frontFace: Nullable<number>;
  69328. reset(): void;
  69329. apply(gl: WebGLRenderingContext): void;
  69330. }
  69331. }
  69332. declare module BABYLON {
  69333. /**
  69334. * @hidden
  69335. **/
  69336. export class _StencilState {
  69337. /** 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 */
  69338. static readonly ALWAYS: number;
  69339. /** Passed to stencilOperation to specify that stencil value must be kept */
  69340. static readonly KEEP: number;
  69341. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69342. static readonly REPLACE: number;
  69343. private _isStencilTestDirty;
  69344. private _isStencilMaskDirty;
  69345. private _isStencilFuncDirty;
  69346. private _isStencilOpDirty;
  69347. private _stencilTest;
  69348. private _stencilMask;
  69349. private _stencilFunc;
  69350. private _stencilFuncRef;
  69351. private _stencilFuncMask;
  69352. private _stencilOpStencilFail;
  69353. private _stencilOpDepthFail;
  69354. private _stencilOpStencilDepthPass;
  69355. readonly isDirty: boolean;
  69356. stencilFunc: number;
  69357. stencilFuncRef: number;
  69358. stencilFuncMask: number;
  69359. stencilOpStencilFail: number;
  69360. stencilOpDepthFail: number;
  69361. stencilOpStencilDepthPass: number;
  69362. stencilMask: number;
  69363. stencilTest: boolean;
  69364. constructor();
  69365. reset(): void;
  69366. apply(gl: WebGLRenderingContext): void;
  69367. }
  69368. }
  69369. declare module BABYLON {
  69370. /**
  69371. * @hidden
  69372. **/
  69373. export class _TimeToken {
  69374. _startTimeQuery: Nullable<WebGLQuery>;
  69375. _endTimeQuery: Nullable<WebGLQuery>;
  69376. _timeElapsedQuery: Nullable<WebGLQuery>;
  69377. _timeElapsedQueryEnded: boolean;
  69378. }
  69379. }
  69380. declare module BABYLON {
  69381. /**
  69382. * Class used to store data associated with WebGL texture data for the engine
  69383. * This class should not be used directly
  69384. */
  69385. export class InternalTexture {
  69386. /** @hidden */
  69387. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  69388. /**
  69389. * The source of the texture data is unknown
  69390. */
  69391. static DATASOURCE_UNKNOWN: number;
  69392. /**
  69393. * Texture data comes from an URL
  69394. */
  69395. static DATASOURCE_URL: number;
  69396. /**
  69397. * Texture data is only used for temporary storage
  69398. */
  69399. static DATASOURCE_TEMP: number;
  69400. /**
  69401. * Texture data comes from raw data (ArrayBuffer)
  69402. */
  69403. static DATASOURCE_RAW: number;
  69404. /**
  69405. * Texture content is dynamic (video or dynamic texture)
  69406. */
  69407. static DATASOURCE_DYNAMIC: number;
  69408. /**
  69409. * Texture content is generated by rendering to it
  69410. */
  69411. static DATASOURCE_RENDERTARGET: number;
  69412. /**
  69413. * Texture content is part of a multi render target process
  69414. */
  69415. static DATASOURCE_MULTIRENDERTARGET: number;
  69416. /**
  69417. * Texture data comes from a cube data file
  69418. */
  69419. static DATASOURCE_CUBE: number;
  69420. /**
  69421. * Texture data comes from a raw cube data
  69422. */
  69423. static DATASOURCE_CUBERAW: number;
  69424. /**
  69425. * Texture data come from a prefiltered cube data file
  69426. */
  69427. static DATASOURCE_CUBEPREFILTERED: number;
  69428. /**
  69429. * Texture content is raw 3D data
  69430. */
  69431. static DATASOURCE_RAW3D: number;
  69432. /**
  69433. * Texture content is a depth texture
  69434. */
  69435. static DATASOURCE_DEPTHTEXTURE: number;
  69436. /**
  69437. * Texture data comes from a raw cube data encoded with RGBD
  69438. */
  69439. static DATASOURCE_CUBERAW_RGBD: number;
  69440. /**
  69441. * Defines if the texture is ready
  69442. */
  69443. isReady: boolean;
  69444. /**
  69445. * Defines if the texture is a cube texture
  69446. */
  69447. isCube: boolean;
  69448. /**
  69449. * Defines if the texture contains 3D data
  69450. */
  69451. is3D: boolean;
  69452. /**
  69453. * Defines if the texture contains multiview data
  69454. */
  69455. isMultiview: boolean;
  69456. /**
  69457. * Gets the URL used to load this texture
  69458. */
  69459. url: string;
  69460. /**
  69461. * Gets the sampling mode of the texture
  69462. */
  69463. samplingMode: number;
  69464. /**
  69465. * Gets a boolean indicating if the texture needs mipmaps generation
  69466. */
  69467. generateMipMaps: boolean;
  69468. /**
  69469. * Gets the number of samples used by the texture (WebGL2+ only)
  69470. */
  69471. samples: number;
  69472. /**
  69473. * Gets the type of the texture (int, float...)
  69474. */
  69475. type: number;
  69476. /**
  69477. * Gets the format of the texture (RGB, RGBA...)
  69478. */
  69479. format: number;
  69480. /**
  69481. * Observable called when the texture is loaded
  69482. */
  69483. onLoadedObservable: Observable<InternalTexture>;
  69484. /**
  69485. * Gets the width of the texture
  69486. */
  69487. width: number;
  69488. /**
  69489. * Gets the height of the texture
  69490. */
  69491. height: number;
  69492. /**
  69493. * Gets the depth of the texture
  69494. */
  69495. depth: number;
  69496. /**
  69497. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  69498. */
  69499. baseWidth: number;
  69500. /**
  69501. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  69502. */
  69503. baseHeight: number;
  69504. /**
  69505. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  69506. */
  69507. baseDepth: number;
  69508. /**
  69509. * Gets a boolean indicating if the texture is inverted on Y axis
  69510. */
  69511. invertY: boolean;
  69512. /** @hidden */
  69513. _invertVScale: boolean;
  69514. /** @hidden */
  69515. _associatedChannel: number;
  69516. /** @hidden */
  69517. _dataSource: number;
  69518. /** @hidden */
  69519. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  69520. /** @hidden */
  69521. _bufferView: Nullable<ArrayBufferView>;
  69522. /** @hidden */
  69523. _bufferViewArray: Nullable<ArrayBufferView[]>;
  69524. /** @hidden */
  69525. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  69526. /** @hidden */
  69527. _size: number;
  69528. /** @hidden */
  69529. _extension: string;
  69530. /** @hidden */
  69531. _files: Nullable<string[]>;
  69532. /** @hidden */
  69533. _workingCanvas: Nullable<HTMLCanvasElement>;
  69534. /** @hidden */
  69535. _workingContext: Nullable<CanvasRenderingContext2D>;
  69536. /** @hidden */
  69537. _framebuffer: Nullable<WebGLFramebuffer>;
  69538. /** @hidden */
  69539. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  69540. /** @hidden */
  69541. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  69542. /** @hidden */
  69543. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  69544. /** @hidden */
  69545. _attachments: Nullable<number[]>;
  69546. /** @hidden */
  69547. _cachedCoordinatesMode: Nullable<number>;
  69548. /** @hidden */
  69549. _cachedWrapU: Nullable<number>;
  69550. /** @hidden */
  69551. _cachedWrapV: Nullable<number>;
  69552. /** @hidden */
  69553. _cachedWrapR: Nullable<number>;
  69554. /** @hidden */
  69555. _cachedAnisotropicFilteringLevel: Nullable<number>;
  69556. /** @hidden */
  69557. _isDisabled: boolean;
  69558. /** @hidden */
  69559. _compression: Nullable<string>;
  69560. /** @hidden */
  69561. _generateStencilBuffer: boolean;
  69562. /** @hidden */
  69563. _generateDepthBuffer: boolean;
  69564. /** @hidden */
  69565. _comparisonFunction: number;
  69566. /** @hidden */
  69567. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  69568. /** @hidden */
  69569. _lodGenerationScale: number;
  69570. /** @hidden */
  69571. _lodGenerationOffset: number;
  69572. /** @hidden */
  69573. _colorTextureArray: Nullable<WebGLTexture>;
  69574. /** @hidden */
  69575. _depthStencilTextureArray: Nullable<WebGLTexture>;
  69576. /** @hidden */
  69577. _lodTextureHigh: Nullable<BaseTexture>;
  69578. /** @hidden */
  69579. _lodTextureMid: Nullable<BaseTexture>;
  69580. /** @hidden */
  69581. _lodTextureLow: Nullable<BaseTexture>;
  69582. /** @hidden */
  69583. _isRGBD: boolean;
  69584. /** @hidden */
  69585. _linearSpecularLOD: boolean;
  69586. /** @hidden */
  69587. _irradianceTexture: Nullable<BaseTexture>;
  69588. /** @hidden */
  69589. _webGLTexture: Nullable<WebGLTexture>;
  69590. /** @hidden */
  69591. _references: number;
  69592. private _engine;
  69593. /**
  69594. * Gets the Engine the texture belongs to.
  69595. * @returns The babylon engine
  69596. */
  69597. getEngine(): Engine;
  69598. /**
  69599. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  69600. */
  69601. readonly dataSource: number;
  69602. /**
  69603. * Creates a new InternalTexture
  69604. * @param engine defines the engine to use
  69605. * @param dataSource defines the type of data that will be used
  69606. * @param delayAllocation if the texture allocation should be delayed (default: false)
  69607. */
  69608. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  69609. /**
  69610. * Increments the number of references (ie. the number of Texture that point to it)
  69611. */
  69612. incrementReferences(): void;
  69613. /**
  69614. * Change the size of the texture (not the size of the content)
  69615. * @param width defines the new width
  69616. * @param height defines the new height
  69617. * @param depth defines the new depth (1 by default)
  69618. */
  69619. updateSize(width: int, height: int, depth?: int): void;
  69620. /** @hidden */
  69621. _rebuild(): void;
  69622. /** @hidden */
  69623. _swapAndDie(target: InternalTexture): void;
  69624. /**
  69625. * Dispose the current allocated resources
  69626. */
  69627. dispose(): void;
  69628. }
  69629. }
  69630. declare module BABYLON {
  69631. /**
  69632. * This represents the main contract an easing function should follow.
  69633. * Easing functions are used throughout the animation system.
  69634. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69635. */
  69636. export interface IEasingFunction {
  69637. /**
  69638. * Given an input gradient between 0 and 1, this returns the corrseponding value
  69639. * of the easing function.
  69640. * The link below provides some of the most common examples of easing functions.
  69641. * @see https://easings.net/
  69642. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69643. * @returns the corresponding value on the curve defined by the easing function
  69644. */
  69645. ease(gradient: number): number;
  69646. }
  69647. /**
  69648. * Base class used for every default easing function.
  69649. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69650. */
  69651. export class EasingFunction implements IEasingFunction {
  69652. /**
  69653. * Interpolation follows the mathematical formula associated with the easing function.
  69654. */
  69655. static readonly EASINGMODE_EASEIN: number;
  69656. /**
  69657. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  69658. */
  69659. static readonly EASINGMODE_EASEOUT: number;
  69660. /**
  69661. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  69662. */
  69663. static readonly EASINGMODE_EASEINOUT: number;
  69664. private _easingMode;
  69665. /**
  69666. * Sets the easing mode of the current function.
  69667. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  69668. */
  69669. setEasingMode(easingMode: number): void;
  69670. /**
  69671. * Gets the current easing mode.
  69672. * @returns the easing mode
  69673. */
  69674. getEasingMode(): number;
  69675. /**
  69676. * @hidden
  69677. */
  69678. easeInCore(gradient: number): number;
  69679. /**
  69680. * Given an input gradient between 0 and 1, this returns the corresponding value
  69681. * of the easing function.
  69682. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69683. * @returns the corresponding value on the curve defined by the easing function
  69684. */
  69685. ease(gradient: number): number;
  69686. }
  69687. /**
  69688. * Easing function with a circle shape (see link below).
  69689. * @see https://easings.net/#easeInCirc
  69690. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69691. */
  69692. export class CircleEase extends EasingFunction implements IEasingFunction {
  69693. /** @hidden */
  69694. easeInCore(gradient: number): number;
  69695. }
  69696. /**
  69697. * Easing function with a ease back shape (see link below).
  69698. * @see https://easings.net/#easeInBack
  69699. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69700. */
  69701. export class BackEase extends EasingFunction implements IEasingFunction {
  69702. /** Defines the amplitude of the function */
  69703. amplitude: number;
  69704. /**
  69705. * Instantiates a back ease easing
  69706. * @see https://easings.net/#easeInBack
  69707. * @param amplitude Defines the amplitude of the function
  69708. */
  69709. constructor(
  69710. /** Defines the amplitude of the function */
  69711. amplitude?: number);
  69712. /** @hidden */
  69713. easeInCore(gradient: number): number;
  69714. }
  69715. /**
  69716. * Easing function with a bouncing shape (see link below).
  69717. * @see https://easings.net/#easeInBounce
  69718. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69719. */
  69720. export class BounceEase extends EasingFunction implements IEasingFunction {
  69721. /** Defines the number of bounces */
  69722. bounces: number;
  69723. /** Defines the amplitude of the bounce */
  69724. bounciness: number;
  69725. /**
  69726. * Instantiates a bounce easing
  69727. * @see https://easings.net/#easeInBounce
  69728. * @param bounces Defines the number of bounces
  69729. * @param bounciness Defines the amplitude of the bounce
  69730. */
  69731. constructor(
  69732. /** Defines the number of bounces */
  69733. bounces?: number,
  69734. /** Defines the amplitude of the bounce */
  69735. bounciness?: number);
  69736. /** @hidden */
  69737. easeInCore(gradient: number): number;
  69738. }
  69739. /**
  69740. * Easing function with a power of 3 shape (see link below).
  69741. * @see https://easings.net/#easeInCubic
  69742. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69743. */
  69744. export class CubicEase extends EasingFunction implements IEasingFunction {
  69745. /** @hidden */
  69746. easeInCore(gradient: number): number;
  69747. }
  69748. /**
  69749. * Easing function with an elastic shape (see link below).
  69750. * @see https://easings.net/#easeInElastic
  69751. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69752. */
  69753. export class ElasticEase extends EasingFunction implements IEasingFunction {
  69754. /** Defines the number of oscillations*/
  69755. oscillations: number;
  69756. /** Defines the amplitude of the oscillations*/
  69757. springiness: number;
  69758. /**
  69759. * Instantiates an elastic easing function
  69760. * @see https://easings.net/#easeInElastic
  69761. * @param oscillations Defines the number of oscillations
  69762. * @param springiness Defines the amplitude of the oscillations
  69763. */
  69764. constructor(
  69765. /** Defines the number of oscillations*/
  69766. oscillations?: number,
  69767. /** Defines the amplitude of the oscillations*/
  69768. springiness?: number);
  69769. /** @hidden */
  69770. easeInCore(gradient: number): number;
  69771. }
  69772. /**
  69773. * Easing function with an exponential shape (see link below).
  69774. * @see https://easings.net/#easeInExpo
  69775. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69776. */
  69777. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  69778. /** Defines the exponent of the function */
  69779. exponent: number;
  69780. /**
  69781. * Instantiates an exponential easing function
  69782. * @see https://easings.net/#easeInExpo
  69783. * @param exponent Defines the exponent of the function
  69784. */
  69785. constructor(
  69786. /** Defines the exponent of the function */
  69787. exponent?: number);
  69788. /** @hidden */
  69789. easeInCore(gradient: number): number;
  69790. }
  69791. /**
  69792. * Easing function with a power shape (see link below).
  69793. * @see https://easings.net/#easeInQuad
  69794. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69795. */
  69796. export class PowerEase extends EasingFunction implements IEasingFunction {
  69797. /** Defines the power of the function */
  69798. power: number;
  69799. /**
  69800. * Instantiates an power base easing function
  69801. * @see https://easings.net/#easeInQuad
  69802. * @param power Defines the power of the function
  69803. */
  69804. constructor(
  69805. /** Defines the power of the function */
  69806. power?: number);
  69807. /** @hidden */
  69808. easeInCore(gradient: number): number;
  69809. }
  69810. /**
  69811. * Easing function with a power of 2 shape (see link below).
  69812. * @see https://easings.net/#easeInQuad
  69813. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69814. */
  69815. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  69816. /** @hidden */
  69817. easeInCore(gradient: number): number;
  69818. }
  69819. /**
  69820. * Easing function with a power of 4 shape (see link below).
  69821. * @see https://easings.net/#easeInQuart
  69822. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69823. */
  69824. export class QuarticEase extends EasingFunction implements IEasingFunction {
  69825. /** @hidden */
  69826. easeInCore(gradient: number): number;
  69827. }
  69828. /**
  69829. * Easing function with a power of 5 shape (see link below).
  69830. * @see https://easings.net/#easeInQuint
  69831. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69832. */
  69833. export class QuinticEase extends EasingFunction implements IEasingFunction {
  69834. /** @hidden */
  69835. easeInCore(gradient: number): number;
  69836. }
  69837. /**
  69838. * Easing function with a sin shape (see link below).
  69839. * @see https://easings.net/#easeInSine
  69840. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69841. */
  69842. export class SineEase extends EasingFunction implements IEasingFunction {
  69843. /** @hidden */
  69844. easeInCore(gradient: number): number;
  69845. }
  69846. /**
  69847. * Easing function with a bezier shape (see link below).
  69848. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69849. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69850. */
  69851. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  69852. /** Defines the x component of the start tangent in the bezier curve */
  69853. x1: number;
  69854. /** Defines the y component of the start tangent in the bezier curve */
  69855. y1: number;
  69856. /** Defines the x component of the end tangent in the bezier curve */
  69857. x2: number;
  69858. /** Defines the y component of the end tangent in the bezier curve */
  69859. y2: number;
  69860. /**
  69861. * Instantiates a bezier function
  69862. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69863. * @param x1 Defines the x component of the start tangent in the bezier curve
  69864. * @param y1 Defines the y component of the start tangent in the bezier curve
  69865. * @param x2 Defines the x component of the end tangent in the bezier curve
  69866. * @param y2 Defines the y component of the end tangent in the bezier curve
  69867. */
  69868. constructor(
  69869. /** Defines the x component of the start tangent in the bezier curve */
  69870. x1?: number,
  69871. /** Defines the y component of the start tangent in the bezier curve */
  69872. y1?: number,
  69873. /** Defines the x component of the end tangent in the bezier curve */
  69874. x2?: number,
  69875. /** Defines the y component of the end tangent in the bezier curve */
  69876. y2?: number);
  69877. /** @hidden */
  69878. easeInCore(gradient: number): number;
  69879. }
  69880. }
  69881. declare module BABYLON {
  69882. /**
  69883. * Defines an interface which represents an animation key frame
  69884. */
  69885. export interface IAnimationKey {
  69886. /**
  69887. * Frame of the key frame
  69888. */
  69889. frame: number;
  69890. /**
  69891. * Value at the specifies key frame
  69892. */
  69893. value: any;
  69894. /**
  69895. * The input tangent for the cubic hermite spline
  69896. */
  69897. inTangent?: any;
  69898. /**
  69899. * The output tangent for the cubic hermite spline
  69900. */
  69901. outTangent?: any;
  69902. /**
  69903. * The animation interpolation type
  69904. */
  69905. interpolation?: AnimationKeyInterpolation;
  69906. }
  69907. /**
  69908. * Enum for the animation key frame interpolation type
  69909. */
  69910. export enum AnimationKeyInterpolation {
  69911. /**
  69912. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  69913. */
  69914. STEP = 1
  69915. }
  69916. }
  69917. declare module BABYLON {
  69918. /**
  69919. * Represents the range of an animation
  69920. */
  69921. export class AnimationRange {
  69922. /**The name of the animation range**/
  69923. name: string;
  69924. /**The starting frame of the animation */
  69925. from: number;
  69926. /**The ending frame of the animation*/
  69927. to: number;
  69928. /**
  69929. * Initializes the range of an animation
  69930. * @param name The name of the animation range
  69931. * @param from The starting frame of the animation
  69932. * @param to The ending frame of the animation
  69933. */
  69934. constructor(
  69935. /**The name of the animation range**/
  69936. name: string,
  69937. /**The starting frame of the animation */
  69938. from: number,
  69939. /**The ending frame of the animation*/
  69940. to: number);
  69941. /**
  69942. * Makes a copy of the animation range
  69943. * @returns A copy of the animation range
  69944. */
  69945. clone(): AnimationRange;
  69946. }
  69947. }
  69948. declare module BABYLON {
  69949. /**
  69950. * Composed of a frame, and an action function
  69951. */
  69952. export class AnimationEvent {
  69953. /** The frame for which the event is triggered **/
  69954. frame: number;
  69955. /** The event to perform when triggered **/
  69956. action: (currentFrame: number) => void;
  69957. /** Specifies if the event should be triggered only once**/
  69958. onlyOnce?: boolean | undefined;
  69959. /**
  69960. * Specifies if the animation event is done
  69961. */
  69962. isDone: boolean;
  69963. /**
  69964. * Initializes the animation event
  69965. * @param frame The frame for which the event is triggered
  69966. * @param action The event to perform when triggered
  69967. * @param onlyOnce Specifies if the event should be triggered only once
  69968. */
  69969. constructor(
  69970. /** The frame for which the event is triggered **/
  69971. frame: number,
  69972. /** The event to perform when triggered **/
  69973. action: (currentFrame: number) => void,
  69974. /** Specifies if the event should be triggered only once**/
  69975. onlyOnce?: boolean | undefined);
  69976. /** @hidden */
  69977. _clone(): AnimationEvent;
  69978. }
  69979. }
  69980. declare module BABYLON {
  69981. /**
  69982. * Interface used to define a behavior
  69983. */
  69984. export interface Behavior<T> {
  69985. /** gets or sets behavior's name */
  69986. name: string;
  69987. /**
  69988. * Function called when the behavior needs to be initialized (after attaching it to a target)
  69989. */
  69990. init(): void;
  69991. /**
  69992. * Called when the behavior is attached to a target
  69993. * @param target defines the target where the behavior is attached to
  69994. */
  69995. attach(target: T): void;
  69996. /**
  69997. * Called when the behavior is detached from its target
  69998. */
  69999. detach(): void;
  70000. }
  70001. /**
  70002. * Interface implemented by classes supporting behaviors
  70003. */
  70004. export interface IBehaviorAware<T> {
  70005. /**
  70006. * Attach a behavior
  70007. * @param behavior defines the behavior to attach
  70008. * @returns the current host
  70009. */
  70010. addBehavior(behavior: Behavior<T>): T;
  70011. /**
  70012. * Remove a behavior from the current object
  70013. * @param behavior defines the behavior to detach
  70014. * @returns the current host
  70015. */
  70016. removeBehavior(behavior: Behavior<T>): T;
  70017. /**
  70018. * Gets a behavior using its name to search
  70019. * @param name defines the name to search
  70020. * @returns the behavior or null if not found
  70021. */
  70022. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  70023. }
  70024. }
  70025. declare module BABYLON {
  70026. /**
  70027. * @hidden
  70028. */
  70029. export class IntersectionInfo {
  70030. bu: Nullable<number>;
  70031. bv: Nullable<number>;
  70032. distance: number;
  70033. faceId: number;
  70034. subMeshId: number;
  70035. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  70036. }
  70037. }
  70038. declare module BABYLON {
  70039. /**
  70040. * Class used to store bounding sphere information
  70041. */
  70042. export class BoundingSphere {
  70043. /**
  70044. * Gets the center of the bounding sphere in local space
  70045. */
  70046. readonly center: Vector3;
  70047. /**
  70048. * Radius of the bounding sphere in local space
  70049. */
  70050. radius: number;
  70051. /**
  70052. * Gets the center of the bounding sphere in world space
  70053. */
  70054. readonly centerWorld: Vector3;
  70055. /**
  70056. * Radius of the bounding sphere in world space
  70057. */
  70058. radiusWorld: number;
  70059. /**
  70060. * Gets the minimum vector in local space
  70061. */
  70062. readonly minimum: Vector3;
  70063. /**
  70064. * Gets the maximum vector in local space
  70065. */
  70066. readonly maximum: Vector3;
  70067. private _worldMatrix;
  70068. private static readonly TmpVector3;
  70069. /**
  70070. * Creates a new bounding sphere
  70071. * @param min defines the minimum vector (in local space)
  70072. * @param max defines the maximum vector (in local space)
  70073. * @param worldMatrix defines the new world matrix
  70074. */
  70075. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70076. /**
  70077. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  70078. * @param min defines the new minimum vector (in local space)
  70079. * @param max defines the new maximum vector (in local space)
  70080. * @param worldMatrix defines the new world matrix
  70081. */
  70082. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70083. /**
  70084. * Scale the current bounding sphere by applying a scale factor
  70085. * @param factor defines the scale factor to apply
  70086. * @returns the current bounding box
  70087. */
  70088. scale(factor: number): BoundingSphere;
  70089. /**
  70090. * Gets the world matrix of the bounding box
  70091. * @returns a matrix
  70092. */
  70093. getWorldMatrix(): DeepImmutable<Matrix>;
  70094. /** @hidden */
  70095. _update(worldMatrix: DeepImmutable<Matrix>): void;
  70096. /**
  70097. * Tests if the bounding sphere is intersecting the frustum planes
  70098. * @param frustumPlanes defines the frustum planes to test
  70099. * @returns true if there is an intersection
  70100. */
  70101. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70102. /**
  70103. * Tests if the bounding sphere center is in between the frustum planes.
  70104. * Used for optimistic fast inclusion.
  70105. * @param frustumPlanes defines the frustum planes to test
  70106. * @returns true if the sphere center is in between the frustum planes
  70107. */
  70108. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70109. /**
  70110. * Tests if a point is inside the bounding sphere
  70111. * @param point defines the point to test
  70112. * @returns true if the point is inside the bounding sphere
  70113. */
  70114. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70115. /**
  70116. * Checks if two sphere intersct
  70117. * @param sphere0 sphere 0
  70118. * @param sphere1 sphere 1
  70119. * @returns true if the speres intersect
  70120. */
  70121. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  70122. }
  70123. }
  70124. declare module BABYLON {
  70125. /**
  70126. * Class used to store bounding box information
  70127. */
  70128. export class BoundingBox implements ICullable {
  70129. /**
  70130. * Gets the 8 vectors representing the bounding box in local space
  70131. */
  70132. readonly vectors: Vector3[];
  70133. /**
  70134. * Gets the center of the bounding box in local space
  70135. */
  70136. readonly center: Vector3;
  70137. /**
  70138. * Gets the center of the bounding box in world space
  70139. */
  70140. readonly centerWorld: Vector3;
  70141. /**
  70142. * Gets the extend size in local space
  70143. */
  70144. readonly extendSize: Vector3;
  70145. /**
  70146. * Gets the extend size in world space
  70147. */
  70148. readonly extendSizeWorld: Vector3;
  70149. /**
  70150. * Gets the OBB (object bounding box) directions
  70151. */
  70152. readonly directions: Vector3[];
  70153. /**
  70154. * Gets the 8 vectors representing the bounding box in world space
  70155. */
  70156. readonly vectorsWorld: Vector3[];
  70157. /**
  70158. * Gets the minimum vector in world space
  70159. */
  70160. readonly minimumWorld: Vector3;
  70161. /**
  70162. * Gets the maximum vector in world space
  70163. */
  70164. readonly maximumWorld: Vector3;
  70165. /**
  70166. * Gets the minimum vector in local space
  70167. */
  70168. readonly minimum: Vector3;
  70169. /**
  70170. * Gets the maximum vector in local space
  70171. */
  70172. readonly maximum: Vector3;
  70173. private _worldMatrix;
  70174. private static readonly TmpVector3;
  70175. /**
  70176. * @hidden
  70177. */
  70178. _tag: number;
  70179. /**
  70180. * Creates a new bounding box
  70181. * @param min defines the minimum vector (in local space)
  70182. * @param max defines the maximum vector (in local space)
  70183. * @param worldMatrix defines the new world matrix
  70184. */
  70185. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70186. /**
  70187. * Recreates the entire bounding box from scratch as if we call the constructor in place
  70188. * @param min defines the new minimum vector (in local space)
  70189. * @param max defines the new maximum vector (in local space)
  70190. * @param worldMatrix defines the new world matrix
  70191. */
  70192. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70193. /**
  70194. * Scale the current bounding box by applying a scale factor
  70195. * @param factor defines the scale factor to apply
  70196. * @returns the current bounding box
  70197. */
  70198. scale(factor: number): BoundingBox;
  70199. /**
  70200. * Gets the world matrix of the bounding box
  70201. * @returns a matrix
  70202. */
  70203. getWorldMatrix(): DeepImmutable<Matrix>;
  70204. /** @hidden */
  70205. _update(world: DeepImmutable<Matrix>): void;
  70206. /**
  70207. * Tests if the bounding box is intersecting the frustum planes
  70208. * @param frustumPlanes defines the frustum planes to test
  70209. * @returns true if there is an intersection
  70210. */
  70211. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70212. /**
  70213. * Tests if the bounding box is entirely inside the frustum planes
  70214. * @param frustumPlanes defines the frustum planes to test
  70215. * @returns true if there is an inclusion
  70216. */
  70217. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70218. /**
  70219. * Tests if a point is inside the bounding box
  70220. * @param point defines the point to test
  70221. * @returns true if the point is inside the bounding box
  70222. */
  70223. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70224. /**
  70225. * Tests if the bounding box intersects with a bounding sphere
  70226. * @param sphere defines the sphere to test
  70227. * @returns true if there is an intersection
  70228. */
  70229. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  70230. /**
  70231. * Tests if the bounding box intersects with a box defined by a min and max vectors
  70232. * @param min defines the min vector to use
  70233. * @param max defines the max vector to use
  70234. * @returns true if there is an intersection
  70235. */
  70236. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  70237. /**
  70238. * Tests if two bounding boxes are intersections
  70239. * @param box0 defines the first box to test
  70240. * @param box1 defines the second box to test
  70241. * @returns true if there is an intersection
  70242. */
  70243. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  70244. /**
  70245. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  70246. * @param minPoint defines the minimum vector of the bounding box
  70247. * @param maxPoint defines the maximum vector of the bounding box
  70248. * @param sphereCenter defines the sphere center
  70249. * @param sphereRadius defines the sphere radius
  70250. * @returns true if there is an intersection
  70251. */
  70252. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  70253. /**
  70254. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  70255. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  70256. * @param frustumPlanes defines the frustum planes to test
  70257. * @return true if there is an inclusion
  70258. */
  70259. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70260. /**
  70261. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  70262. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  70263. * @param frustumPlanes defines the frustum planes to test
  70264. * @return true if there is an intersection
  70265. */
  70266. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70267. }
  70268. }
  70269. declare module BABYLON {
  70270. /** @hidden */
  70271. export class Collider {
  70272. /** Define if a collision was found */
  70273. collisionFound: boolean;
  70274. /**
  70275. * Define last intersection point in local space
  70276. */
  70277. intersectionPoint: Vector3;
  70278. /**
  70279. * Define last collided mesh
  70280. */
  70281. collidedMesh: Nullable<AbstractMesh>;
  70282. private _collisionPoint;
  70283. private _planeIntersectionPoint;
  70284. private _tempVector;
  70285. private _tempVector2;
  70286. private _tempVector3;
  70287. private _tempVector4;
  70288. private _edge;
  70289. private _baseToVertex;
  70290. private _destinationPoint;
  70291. private _slidePlaneNormal;
  70292. private _displacementVector;
  70293. /** @hidden */
  70294. _radius: Vector3;
  70295. /** @hidden */
  70296. _retry: number;
  70297. private _velocity;
  70298. private _basePoint;
  70299. private _epsilon;
  70300. /** @hidden */
  70301. _velocityWorldLength: number;
  70302. /** @hidden */
  70303. _basePointWorld: Vector3;
  70304. private _velocityWorld;
  70305. private _normalizedVelocity;
  70306. /** @hidden */
  70307. _initialVelocity: Vector3;
  70308. /** @hidden */
  70309. _initialPosition: Vector3;
  70310. private _nearestDistance;
  70311. private _collisionMask;
  70312. collisionMask: number;
  70313. /**
  70314. * Gets the plane normal used to compute the sliding response (in local space)
  70315. */
  70316. readonly slidePlaneNormal: Vector3;
  70317. /** @hidden */
  70318. _initialize(source: Vector3, dir: Vector3, e: number): void;
  70319. /** @hidden */
  70320. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  70321. /** @hidden */
  70322. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  70323. /** @hidden */
  70324. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  70325. /** @hidden */
  70326. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  70327. /** @hidden */
  70328. _getResponse(pos: Vector3, vel: Vector3): void;
  70329. }
  70330. }
  70331. declare module BABYLON {
  70332. /**
  70333. * Interface for cullable objects
  70334. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  70335. */
  70336. export interface ICullable {
  70337. /**
  70338. * Checks if the object or part of the object is in the frustum
  70339. * @param frustumPlanes Camera near/planes
  70340. * @returns true if the object is in frustum otherwise false
  70341. */
  70342. isInFrustum(frustumPlanes: Plane[]): boolean;
  70343. /**
  70344. * Checks if a cullable object (mesh...) is in the camera frustum
  70345. * Unlike isInFrustum this cheks the full bounding box
  70346. * @param frustumPlanes Camera near/planes
  70347. * @returns true if the object is in frustum otherwise false
  70348. */
  70349. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  70350. }
  70351. /**
  70352. * Info for a bounding data of a mesh
  70353. */
  70354. export class BoundingInfo implements ICullable {
  70355. /**
  70356. * Bounding box for the mesh
  70357. */
  70358. readonly boundingBox: BoundingBox;
  70359. /**
  70360. * Bounding sphere for the mesh
  70361. */
  70362. readonly boundingSphere: BoundingSphere;
  70363. private _isLocked;
  70364. private static readonly TmpVector3;
  70365. /**
  70366. * Constructs bounding info
  70367. * @param minimum min vector of the bounding box/sphere
  70368. * @param maximum max vector of the bounding box/sphere
  70369. * @param worldMatrix defines the new world matrix
  70370. */
  70371. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70372. /**
  70373. * Recreates the entire bounding info from scratch as if we call the constructor in place
  70374. * @param min defines the new minimum vector (in local space)
  70375. * @param max defines the new maximum vector (in local space)
  70376. * @param worldMatrix defines the new world matrix
  70377. */
  70378. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70379. /**
  70380. * min vector of the bounding box/sphere
  70381. */
  70382. readonly minimum: Vector3;
  70383. /**
  70384. * max vector of the bounding box/sphere
  70385. */
  70386. readonly maximum: Vector3;
  70387. /**
  70388. * If the info is locked and won't be updated to avoid perf overhead
  70389. */
  70390. isLocked: boolean;
  70391. /**
  70392. * Updates the bounding sphere and box
  70393. * @param world world matrix to be used to update
  70394. */
  70395. update(world: DeepImmutable<Matrix>): void;
  70396. /**
  70397. * Recreate the bounding info to be centered around a specific point given a specific extend.
  70398. * @param center New center of the bounding info
  70399. * @param extend New extend of the bounding info
  70400. * @returns the current bounding info
  70401. */
  70402. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  70403. /**
  70404. * Scale the current bounding info by applying a scale factor
  70405. * @param factor defines the scale factor to apply
  70406. * @returns the current bounding info
  70407. */
  70408. scale(factor: number): BoundingInfo;
  70409. /**
  70410. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  70411. * @param frustumPlanes defines the frustum to test
  70412. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  70413. * @returns true if the bounding info is in the frustum planes
  70414. */
  70415. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  70416. /**
  70417. * Gets the world distance between the min and max points of the bounding box
  70418. */
  70419. readonly diagonalLength: number;
  70420. /**
  70421. * Checks if a cullable object (mesh...) is in the camera frustum
  70422. * Unlike isInFrustum this cheks the full bounding box
  70423. * @param frustumPlanes Camera near/planes
  70424. * @returns true if the object is in frustum otherwise false
  70425. */
  70426. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70427. /** @hidden */
  70428. _checkCollision(collider: Collider): boolean;
  70429. /**
  70430. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  70431. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  70432. * @param point the point to check intersection with
  70433. * @returns if the point intersects
  70434. */
  70435. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70436. /**
  70437. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  70438. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  70439. * @param boundingInfo the bounding info to check intersection with
  70440. * @param precise if the intersection should be done using OBB
  70441. * @returns if the bounding info intersects
  70442. */
  70443. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  70444. }
  70445. }
  70446. declare module BABYLON {
  70447. /**
  70448. * Defines an array and its length.
  70449. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  70450. */
  70451. export interface ISmartArrayLike<T> {
  70452. /**
  70453. * The data of the array.
  70454. */
  70455. data: Array<T>;
  70456. /**
  70457. * The active length of the array.
  70458. */
  70459. length: number;
  70460. }
  70461. /**
  70462. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70463. */
  70464. export class SmartArray<T> implements ISmartArrayLike<T> {
  70465. /**
  70466. * The full set of data from the array.
  70467. */
  70468. data: Array<T>;
  70469. /**
  70470. * The active length of the array.
  70471. */
  70472. length: number;
  70473. protected _id: number;
  70474. /**
  70475. * Instantiates a Smart Array.
  70476. * @param capacity defines the default capacity of the array.
  70477. */
  70478. constructor(capacity: number);
  70479. /**
  70480. * Pushes a value at the end of the active data.
  70481. * @param value defines the object to push in the array.
  70482. */
  70483. push(value: T): void;
  70484. /**
  70485. * Iterates over the active data and apply the lambda to them.
  70486. * @param func defines the action to apply on each value.
  70487. */
  70488. forEach(func: (content: T) => void): void;
  70489. /**
  70490. * Sorts the full sets of data.
  70491. * @param compareFn defines the comparison function to apply.
  70492. */
  70493. sort(compareFn: (a: T, b: T) => number): void;
  70494. /**
  70495. * Resets the active data to an empty array.
  70496. */
  70497. reset(): void;
  70498. /**
  70499. * Releases all the data from the array as well as the array.
  70500. */
  70501. dispose(): void;
  70502. /**
  70503. * Concats the active data with a given array.
  70504. * @param array defines the data to concatenate with.
  70505. */
  70506. concat(array: any): void;
  70507. /**
  70508. * Returns the position of a value in the active data.
  70509. * @param value defines the value to find the index for
  70510. * @returns the index if found in the active data otherwise -1
  70511. */
  70512. indexOf(value: T): number;
  70513. /**
  70514. * Returns whether an element is part of the active data.
  70515. * @param value defines the value to look for
  70516. * @returns true if found in the active data otherwise false
  70517. */
  70518. contains(value: T): boolean;
  70519. private static _GlobalId;
  70520. }
  70521. /**
  70522. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70523. * The data in this array can only be present once
  70524. */
  70525. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  70526. private _duplicateId;
  70527. /**
  70528. * Pushes a value at the end of the active data.
  70529. * THIS DOES NOT PREVENT DUPPLICATE DATA
  70530. * @param value defines the object to push in the array.
  70531. */
  70532. push(value: T): void;
  70533. /**
  70534. * Pushes a value at the end of the active data.
  70535. * If the data is already present, it won t be added again
  70536. * @param value defines the object to push in the array.
  70537. * @returns true if added false if it was already present
  70538. */
  70539. pushNoDuplicate(value: T): boolean;
  70540. /**
  70541. * Resets the active data to an empty array.
  70542. */
  70543. reset(): void;
  70544. /**
  70545. * Concats the active data with a given array.
  70546. * This ensures no dupplicate will be present in the result.
  70547. * @param array defines the data to concatenate with.
  70548. */
  70549. concatWithNoDuplicate(array: any): void;
  70550. }
  70551. }
  70552. declare module BABYLON {
  70553. /**
  70554. * Enum that determines the text-wrapping mode to use.
  70555. */
  70556. export enum InspectableType {
  70557. /**
  70558. * Checkbox for booleans
  70559. */
  70560. Checkbox = 0,
  70561. /**
  70562. * Sliders for numbers
  70563. */
  70564. Slider = 1,
  70565. /**
  70566. * Vector3
  70567. */
  70568. Vector3 = 2,
  70569. /**
  70570. * Quaternions
  70571. */
  70572. Quaternion = 3,
  70573. /**
  70574. * Color3
  70575. */
  70576. Color3 = 4
  70577. }
  70578. /**
  70579. * Interface used to define custom inspectable properties.
  70580. * This interface is used by the inspector to display custom property grids
  70581. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70582. */
  70583. export interface IInspectable {
  70584. /**
  70585. * Gets the label to display
  70586. */
  70587. label: string;
  70588. /**
  70589. * Gets the name of the property to edit
  70590. */
  70591. propertyName: string;
  70592. /**
  70593. * Gets the type of the editor to use
  70594. */
  70595. type: InspectableType;
  70596. /**
  70597. * Gets the minimum value of the property when using in "slider" mode
  70598. */
  70599. min?: number;
  70600. /**
  70601. * Gets the maximum value of the property when using in "slider" mode
  70602. */
  70603. max?: number;
  70604. /**
  70605. * Gets the setp to use when using in "slider" mode
  70606. */
  70607. step?: number;
  70608. }
  70609. }
  70610. declare module BABYLON {
  70611. /**
  70612. * This represents the required contract to create a new type of texture loader.
  70613. */
  70614. export interface IInternalTextureLoader {
  70615. /**
  70616. * Defines wether the loader supports cascade loading the different faces.
  70617. */
  70618. supportCascades: boolean;
  70619. /**
  70620. * This returns if the loader support the current file information.
  70621. * @param extension defines the file extension of the file being loaded
  70622. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70623. * @param fallback defines the fallback internal texture if any
  70624. * @param isBase64 defines whether the texture is encoded as a base64
  70625. * @param isBuffer defines whether the texture data are stored as a buffer
  70626. * @returns true if the loader can load the specified file
  70627. */
  70628. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  70629. /**
  70630. * Transform the url before loading if required.
  70631. * @param rootUrl the url of the texture
  70632. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70633. * @returns the transformed texture
  70634. */
  70635. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  70636. /**
  70637. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  70638. * @param rootUrl the url of the texture
  70639. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70640. * @returns the fallback texture
  70641. */
  70642. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  70643. /**
  70644. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  70645. * @param data contains the texture data
  70646. * @param texture defines the BabylonJS internal texture
  70647. * @param createPolynomials will be true if polynomials have been requested
  70648. * @param onLoad defines the callback to trigger once the texture is ready
  70649. * @param onError defines the callback to trigger in case of error
  70650. */
  70651. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  70652. /**
  70653. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  70654. * @param data contains the texture data
  70655. * @param texture defines the BabylonJS internal texture
  70656. * @param callback defines the method to call once ready to upload
  70657. */
  70658. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  70659. }
  70660. }
  70661. declare module BABYLON {
  70662. interface Engine {
  70663. /**
  70664. * Creates a depth stencil cube texture.
  70665. * This is only available in WebGL 2.
  70666. * @param size The size of face edge in the cube texture.
  70667. * @param options The options defining the cube texture.
  70668. * @returns The cube texture
  70669. */
  70670. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  70671. /**
  70672. * Creates a cube texture
  70673. * @param rootUrl defines the url where the files to load is located
  70674. * @param scene defines the current scene
  70675. * @param files defines the list of files to load (1 per face)
  70676. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70677. * @param onLoad defines an optional callback raised when the texture is loaded
  70678. * @param onError defines an optional callback raised if there is an issue to load the texture
  70679. * @param format defines the format of the data
  70680. * @param forcedExtension defines the extension to use to pick the right loader
  70681. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70682. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70683. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70684. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  70685. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  70686. * @returns the cube texture as an InternalTexture
  70687. */
  70688. 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;
  70689. /**
  70690. * Creates a cube texture
  70691. * @param rootUrl defines the url where the files to load is located
  70692. * @param scene defines the current scene
  70693. * @param files defines the list of files to load (1 per face)
  70694. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70695. * @param onLoad defines an optional callback raised when the texture is loaded
  70696. * @param onError defines an optional callback raised if there is an issue to load the texture
  70697. * @param format defines the format of the data
  70698. * @param forcedExtension defines the extension to use to pick the right loader
  70699. * @returns the cube texture as an InternalTexture
  70700. */
  70701. 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;
  70702. /**
  70703. * Creates a cube texture
  70704. * @param rootUrl defines the url where the files to load is located
  70705. * @param scene defines the current scene
  70706. * @param files defines the list of files to load (1 per face)
  70707. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70708. * @param onLoad defines an optional callback raised when the texture is loaded
  70709. * @param onError defines an optional callback raised if there is an issue to load the texture
  70710. * @param format defines the format of the data
  70711. * @param forcedExtension defines the extension to use to pick the right loader
  70712. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70713. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70714. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70715. * @returns the cube texture as an InternalTexture
  70716. */
  70717. 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;
  70718. /** @hidden */
  70719. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  70720. /** @hidden */
  70721. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  70722. /** @hidden */
  70723. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  70724. /** @hidden */
  70725. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  70726. }
  70727. }
  70728. declare module BABYLON {
  70729. /**
  70730. * Class for creating a cube texture
  70731. */
  70732. export class CubeTexture extends BaseTexture {
  70733. private _delayedOnLoad;
  70734. /**
  70735. * The url of the texture
  70736. */
  70737. url: string;
  70738. /**
  70739. * Gets or sets the center of the bounding box associated with the cube texture.
  70740. * It must define where the camera used to render the texture was set
  70741. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  70742. */
  70743. boundingBoxPosition: Vector3;
  70744. private _boundingBoxSize;
  70745. /**
  70746. * Gets or sets the size of the bounding box associated with the cube texture
  70747. * When defined, the cubemap will switch to local mode
  70748. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  70749. * @example https://www.babylonjs-playground.com/#RNASML
  70750. */
  70751. /**
  70752. * Returns the bounding box size
  70753. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  70754. */
  70755. boundingBoxSize: Vector3;
  70756. protected _rotationY: number;
  70757. /**
  70758. * Sets texture matrix rotation angle around Y axis in radians.
  70759. */
  70760. /**
  70761. * Gets texture matrix rotation angle around Y axis radians.
  70762. */
  70763. rotationY: number;
  70764. /**
  70765. * Are mip maps generated for this texture or not.
  70766. */
  70767. readonly noMipmap: boolean;
  70768. private _noMipmap;
  70769. private _files;
  70770. private _extensions;
  70771. private _textureMatrix;
  70772. private _format;
  70773. private _createPolynomials;
  70774. /** @hidden */
  70775. _prefiltered: boolean;
  70776. /**
  70777. * Creates a cube texture from an array of image urls
  70778. * @param files defines an array of image urls
  70779. * @param scene defines the hosting scene
  70780. * @param noMipmap specifies if mip maps are not used
  70781. * @returns a cube texture
  70782. */
  70783. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  70784. /**
  70785. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  70786. * @param url defines the url of the prefiltered texture
  70787. * @param scene defines the scene the texture is attached to
  70788. * @param forcedExtension defines the extension of the file if different from the url
  70789. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  70790. * @return the prefiltered texture
  70791. */
  70792. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  70793. /**
  70794. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  70795. * as prefiltered data.
  70796. * @param rootUrl defines the url of the texture or the root name of the six images
  70797. * @param scene defines the scene the texture is attached to
  70798. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  70799. * @param noMipmap defines if mipmaps should be created or not
  70800. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  70801. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  70802. * @param onError defines a callback triggered in case of error during load
  70803. * @param format defines the internal format to use for the texture once loaded
  70804. * @param prefiltered defines whether or not the texture is created from prefiltered data
  70805. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  70806. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  70807. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70808. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70809. * @return the cube texture
  70810. */
  70811. 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);
  70812. /**
  70813. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  70814. */
  70815. readonly isPrefiltered: boolean;
  70816. /**
  70817. * Get the current class name of the texture useful for serialization or dynamic coding.
  70818. * @returns "CubeTexture"
  70819. */
  70820. getClassName(): string;
  70821. /**
  70822. * Update the url (and optional buffer) of this texture if url was null during construction.
  70823. * @param url the url of the texture
  70824. * @param forcedExtension defines the extension to use
  70825. * @param onLoad callback called when the texture is loaded (defaults to null)
  70826. */
  70827. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  70828. /**
  70829. * Delays loading of the cube texture
  70830. * @param forcedExtension defines the extension to use
  70831. */
  70832. delayLoad(forcedExtension?: string): void;
  70833. /**
  70834. * Returns the reflection texture matrix
  70835. * @returns the reflection texture matrix
  70836. */
  70837. getReflectionTextureMatrix(): Matrix;
  70838. /**
  70839. * Sets the reflection texture matrix
  70840. * @param value Reflection texture matrix
  70841. */
  70842. setReflectionTextureMatrix(value: Matrix): void;
  70843. /**
  70844. * Parses text to create a cube texture
  70845. * @param parsedTexture define the serialized text to read from
  70846. * @param scene defines the hosting scene
  70847. * @param rootUrl defines the root url of the cube texture
  70848. * @returns a cube texture
  70849. */
  70850. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  70851. /**
  70852. * Makes a clone, or deep copy, of the cube texture
  70853. * @returns a new cube texture
  70854. */
  70855. clone(): CubeTexture;
  70856. }
  70857. }
  70858. declare module BABYLON {
  70859. /** @hidden */
  70860. export var postprocessVertexShader: {
  70861. name: string;
  70862. shader: string;
  70863. };
  70864. }
  70865. declare module BABYLON {
  70866. /**
  70867. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  70868. * This is the base of the follow, arc rotate cameras and Free camera
  70869. * @see http://doc.babylonjs.com/features/cameras
  70870. */
  70871. export class TargetCamera extends Camera {
  70872. private static _RigCamTransformMatrix;
  70873. private static _TargetTransformMatrix;
  70874. private static _TargetFocalPoint;
  70875. /**
  70876. * Define the current direction the camera is moving to
  70877. */
  70878. cameraDirection: Vector3;
  70879. /**
  70880. * Define the current rotation the camera is rotating to
  70881. */
  70882. cameraRotation: Vector2;
  70883. /**
  70884. * When set, the up vector of the camera will be updated by the rotation of the camera
  70885. */
  70886. updateUpVectorFromRotation: boolean;
  70887. private _tmpQuaternion;
  70888. /**
  70889. * Define the current rotation of the camera
  70890. */
  70891. rotation: Vector3;
  70892. /**
  70893. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  70894. */
  70895. rotationQuaternion: Quaternion;
  70896. /**
  70897. * Define the current speed of the camera
  70898. */
  70899. speed: number;
  70900. /**
  70901. * Add cconstraint to the camera to prevent it to move freely in all directions and
  70902. * around all axis.
  70903. */
  70904. noRotationConstraint: boolean;
  70905. /**
  70906. * Define the current target of the camera as an object or a position.
  70907. */
  70908. lockedTarget: any;
  70909. /** @hidden */
  70910. _currentTarget: Vector3;
  70911. /** @hidden */
  70912. _initialFocalDistance: number;
  70913. /** @hidden */
  70914. _viewMatrix: Matrix;
  70915. /** @hidden */
  70916. _camMatrix: Matrix;
  70917. /** @hidden */
  70918. _cameraTransformMatrix: Matrix;
  70919. /** @hidden */
  70920. _cameraRotationMatrix: Matrix;
  70921. /** @hidden */
  70922. _referencePoint: Vector3;
  70923. /** @hidden */
  70924. _transformedReferencePoint: Vector3;
  70925. protected _globalCurrentTarget: Vector3;
  70926. protected _globalCurrentUpVector: Vector3;
  70927. /** @hidden */
  70928. _reset: () => void;
  70929. private _defaultUp;
  70930. /**
  70931. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  70932. * This is the base of the follow, arc rotate cameras and Free camera
  70933. * @see http://doc.babylonjs.com/features/cameras
  70934. * @param name Defines the name of the camera in the scene
  70935. * @param position Defines the start position of the camera in the scene
  70936. * @param scene Defines the scene the camera belongs to
  70937. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  70938. */
  70939. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  70940. /**
  70941. * Gets the position in front of the camera at a given distance.
  70942. * @param distance The distance from the camera we want the position to be
  70943. * @returns the position
  70944. */
  70945. getFrontPosition(distance: number): Vector3;
  70946. /** @hidden */
  70947. _getLockedTargetPosition(): Nullable<Vector3>;
  70948. private _storedPosition;
  70949. private _storedRotation;
  70950. private _storedRotationQuaternion;
  70951. /**
  70952. * Store current camera state of the camera (fov, position, rotation, etc..)
  70953. * @returns the camera
  70954. */
  70955. storeState(): Camera;
  70956. /**
  70957. * Restored camera state. You must call storeState() first
  70958. * @returns whether it was successful or not
  70959. * @hidden
  70960. */
  70961. _restoreStateValues(): boolean;
  70962. /** @hidden */
  70963. _initCache(): void;
  70964. /** @hidden */
  70965. _updateCache(ignoreParentClass?: boolean): void;
  70966. /** @hidden */
  70967. _isSynchronizedViewMatrix(): boolean;
  70968. /** @hidden */
  70969. _computeLocalCameraSpeed(): number;
  70970. /**
  70971. * Defines the target the camera should look at.
  70972. * @param target Defines the new target as a Vector or a mesh
  70973. */
  70974. setTarget(target: Vector3): void;
  70975. /**
  70976. * Return the current target position of the camera. This value is expressed in local space.
  70977. * @returns the target position
  70978. */
  70979. getTarget(): Vector3;
  70980. /** @hidden */
  70981. _decideIfNeedsToMove(): boolean;
  70982. /** @hidden */
  70983. _updatePosition(): void;
  70984. /** @hidden */
  70985. _checkInputs(): void;
  70986. protected _updateCameraRotationMatrix(): void;
  70987. /**
  70988. * 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)
  70989. * @returns the current camera
  70990. */
  70991. private _rotateUpVectorWithCameraRotationMatrix;
  70992. private _cachedRotationZ;
  70993. private _cachedQuaternionRotationZ;
  70994. /** @hidden */
  70995. _getViewMatrix(): Matrix;
  70996. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  70997. /**
  70998. * @hidden
  70999. */
  71000. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  71001. /**
  71002. * @hidden
  71003. */
  71004. _updateRigCameras(): void;
  71005. private _getRigCamPositionAndTarget;
  71006. /**
  71007. * Gets the current object class name.
  71008. * @return the class name
  71009. */
  71010. getClassName(): string;
  71011. }
  71012. }
  71013. declare module BABYLON {
  71014. /**
  71015. * @ignore
  71016. * This is a list of all the different input types that are available in the application.
  71017. * Fo instance: ArcRotateCameraGamepadInput...
  71018. */
  71019. export var CameraInputTypes: {};
  71020. /**
  71021. * This is the contract to implement in order to create a new input class.
  71022. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  71023. */
  71024. export interface ICameraInput<TCamera extends Camera> {
  71025. /**
  71026. * Defines the camera the input is attached to.
  71027. */
  71028. camera: Nullable<TCamera>;
  71029. /**
  71030. * Gets the class name of the current intput.
  71031. * @returns the class name
  71032. */
  71033. getClassName(): string;
  71034. /**
  71035. * Get the friendly name associated with the input class.
  71036. * @returns the input friendly name
  71037. */
  71038. getSimpleName(): string;
  71039. /**
  71040. * Attach the input controls to a specific dom element to get the input from.
  71041. * @param element Defines the element the controls should be listened from
  71042. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71043. */
  71044. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71045. /**
  71046. * Detach the current controls from the specified dom element.
  71047. * @param element Defines the element to stop listening the inputs from
  71048. */
  71049. detachControl(element: Nullable<HTMLElement>): void;
  71050. /**
  71051. * Update the current camera state depending on the inputs that have been used this frame.
  71052. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71053. */
  71054. checkInputs?: () => void;
  71055. }
  71056. /**
  71057. * Represents a map of input types to input instance or input index to input instance.
  71058. */
  71059. export interface CameraInputsMap<TCamera extends Camera> {
  71060. /**
  71061. * Accessor to the input by input type.
  71062. */
  71063. [name: string]: ICameraInput<TCamera>;
  71064. /**
  71065. * Accessor to the input by input index.
  71066. */
  71067. [idx: number]: ICameraInput<TCamera>;
  71068. }
  71069. /**
  71070. * This represents the input manager used within a camera.
  71071. * It helps dealing with all the different kind of input attached to a camera.
  71072. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71073. */
  71074. export class CameraInputsManager<TCamera extends Camera> {
  71075. /**
  71076. * Defines the list of inputs attahed to the camera.
  71077. */
  71078. attached: CameraInputsMap<TCamera>;
  71079. /**
  71080. * Defines the dom element the camera is collecting inputs from.
  71081. * This is null if the controls have not been attached.
  71082. */
  71083. attachedElement: Nullable<HTMLElement>;
  71084. /**
  71085. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71086. */
  71087. noPreventDefault: boolean;
  71088. /**
  71089. * Defined the camera the input manager belongs to.
  71090. */
  71091. camera: TCamera;
  71092. /**
  71093. * Update the current camera state depending on the inputs that have been used this frame.
  71094. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71095. */
  71096. checkInputs: () => void;
  71097. /**
  71098. * Instantiate a new Camera Input Manager.
  71099. * @param camera Defines the camera the input manager blongs to
  71100. */
  71101. constructor(camera: TCamera);
  71102. /**
  71103. * Add an input method to a camera
  71104. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71105. * @param input camera input method
  71106. */
  71107. add(input: ICameraInput<TCamera>): void;
  71108. /**
  71109. * Remove a specific input method from a camera
  71110. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  71111. * @param inputToRemove camera input method
  71112. */
  71113. remove(inputToRemove: ICameraInput<TCamera>): void;
  71114. /**
  71115. * Remove a specific input type from a camera
  71116. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  71117. * @param inputType the type of the input to remove
  71118. */
  71119. removeByType(inputType: string): void;
  71120. private _addCheckInputs;
  71121. /**
  71122. * Attach the input controls to the currently attached dom element to listen the events from.
  71123. * @param input Defines the input to attach
  71124. */
  71125. attachInput(input: ICameraInput<TCamera>): void;
  71126. /**
  71127. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  71128. * @param element Defines the dom element to collect the events from
  71129. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71130. */
  71131. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  71132. /**
  71133. * Detach the current manager inputs controls from a specific dom element.
  71134. * @param element Defines the dom element to collect the events from
  71135. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  71136. */
  71137. detachElement(element: HTMLElement, disconnect?: boolean): void;
  71138. /**
  71139. * Rebuild the dynamic inputCheck function from the current list of
  71140. * defined inputs in the manager.
  71141. */
  71142. rebuildInputCheck(): void;
  71143. /**
  71144. * Remove all attached input methods from a camera
  71145. */
  71146. clear(): void;
  71147. /**
  71148. * Serialize the current input manager attached to a camera.
  71149. * This ensures than once parsed,
  71150. * the input associated to the camera will be identical to the current ones
  71151. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  71152. */
  71153. serialize(serializedCamera: any): void;
  71154. /**
  71155. * Parses an input manager serialized JSON to restore the previous list of inputs
  71156. * and states associated to a camera.
  71157. * @param parsedCamera Defines the JSON to parse
  71158. */
  71159. parse(parsedCamera: any): void;
  71160. }
  71161. }
  71162. declare module BABYLON {
  71163. /**
  71164. * Gather the list of keyboard event types as constants.
  71165. */
  71166. export class KeyboardEventTypes {
  71167. /**
  71168. * The keydown event is fired when a key becomes active (pressed).
  71169. */
  71170. static readonly KEYDOWN: number;
  71171. /**
  71172. * The keyup event is fired when a key has been released.
  71173. */
  71174. static readonly KEYUP: number;
  71175. }
  71176. /**
  71177. * This class is used to store keyboard related info for the onKeyboardObservable event.
  71178. */
  71179. export class KeyboardInfo {
  71180. /**
  71181. * Defines the type of event (KeyboardEventTypes)
  71182. */
  71183. type: number;
  71184. /**
  71185. * Defines the related dom event
  71186. */
  71187. event: KeyboardEvent;
  71188. /**
  71189. * Instantiates a new keyboard info.
  71190. * This class is used to store keyboard related info for the onKeyboardObservable event.
  71191. * @param type Defines the type of event (KeyboardEventTypes)
  71192. * @param event Defines the related dom event
  71193. */
  71194. constructor(
  71195. /**
  71196. * Defines the type of event (KeyboardEventTypes)
  71197. */
  71198. type: number,
  71199. /**
  71200. * Defines the related dom event
  71201. */
  71202. event: KeyboardEvent);
  71203. }
  71204. /**
  71205. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  71206. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  71207. */
  71208. export class KeyboardInfoPre extends KeyboardInfo {
  71209. /**
  71210. * Defines the type of event (KeyboardEventTypes)
  71211. */
  71212. type: number;
  71213. /**
  71214. * Defines the related dom event
  71215. */
  71216. event: KeyboardEvent;
  71217. /**
  71218. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  71219. */
  71220. skipOnPointerObservable: boolean;
  71221. /**
  71222. * Instantiates a new keyboard pre info.
  71223. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  71224. * @param type Defines the type of event (KeyboardEventTypes)
  71225. * @param event Defines the related dom event
  71226. */
  71227. constructor(
  71228. /**
  71229. * Defines the type of event (KeyboardEventTypes)
  71230. */
  71231. type: number,
  71232. /**
  71233. * Defines the related dom event
  71234. */
  71235. event: KeyboardEvent);
  71236. }
  71237. }
  71238. declare module BABYLON {
  71239. /**
  71240. * Manage the keyboard inputs to control the movement of a free camera.
  71241. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71242. */
  71243. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  71244. /**
  71245. * Defines the camera the input is attached to.
  71246. */
  71247. camera: FreeCamera;
  71248. /**
  71249. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  71250. */
  71251. keysUp: number[];
  71252. /**
  71253. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  71254. */
  71255. keysDown: number[];
  71256. /**
  71257. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  71258. */
  71259. keysLeft: number[];
  71260. /**
  71261. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  71262. */
  71263. keysRight: number[];
  71264. private _keys;
  71265. private _onCanvasBlurObserver;
  71266. private _onKeyboardObserver;
  71267. private _engine;
  71268. private _scene;
  71269. /**
  71270. * Attach the input controls to a specific dom element to get the input from.
  71271. * @param element Defines the element the controls should be listened from
  71272. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71273. */
  71274. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71275. /**
  71276. * Detach the current controls from the specified dom element.
  71277. * @param element Defines the element to stop listening the inputs from
  71278. */
  71279. detachControl(element: Nullable<HTMLElement>): void;
  71280. /**
  71281. * Update the current camera state depending on the inputs that have been used this frame.
  71282. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71283. */
  71284. checkInputs(): void;
  71285. /**
  71286. * Gets the class name of the current intput.
  71287. * @returns the class name
  71288. */
  71289. getClassName(): string;
  71290. /** @hidden */
  71291. _onLostFocus(): void;
  71292. /**
  71293. * Get the friendly name associated with the input class.
  71294. * @returns the input friendly name
  71295. */
  71296. getSimpleName(): string;
  71297. }
  71298. }
  71299. declare module BABYLON {
  71300. /**
  71301. * A multi-material is used to apply different materials to different parts of the same object without the need of
  71302. * separate meshes. This can be use to improve performances.
  71303. * @see http://doc.babylonjs.com/how_to/multi_materials
  71304. */
  71305. export class MultiMaterial extends Material {
  71306. private _subMaterials;
  71307. /**
  71308. * Gets or Sets the list of Materials used within the multi material.
  71309. * They need to be ordered according to the submeshes order in the associated mesh
  71310. */
  71311. subMaterials: Nullable<Material>[];
  71312. /**
  71313. * Function used to align with Node.getChildren()
  71314. * @returns the list of Materials used within the multi material
  71315. */
  71316. getChildren(): Nullable<Material>[];
  71317. /**
  71318. * Instantiates a new Multi Material
  71319. * A multi-material is used to apply different materials to different parts of the same object without the need of
  71320. * separate meshes. This can be use to improve performances.
  71321. * @see http://doc.babylonjs.com/how_to/multi_materials
  71322. * @param name Define the name in the scene
  71323. * @param scene Define the scene the material belongs to
  71324. */
  71325. constructor(name: string, scene: Scene);
  71326. private _hookArray;
  71327. /**
  71328. * Get one of the submaterial by its index in the submaterials array
  71329. * @param index The index to look the sub material at
  71330. * @returns The Material if the index has been defined
  71331. */
  71332. getSubMaterial(index: number): Nullable<Material>;
  71333. /**
  71334. * Get the list of active textures for the whole sub materials list.
  71335. * @returns All the textures that will be used during the rendering
  71336. */
  71337. getActiveTextures(): BaseTexture[];
  71338. /**
  71339. * Gets the current class name of the material e.g. "MultiMaterial"
  71340. * Mainly use in serialization.
  71341. * @returns the class name
  71342. */
  71343. getClassName(): string;
  71344. /**
  71345. * Checks if the material is ready to render the requested sub mesh
  71346. * @param mesh Define the mesh the submesh belongs to
  71347. * @param subMesh Define the sub mesh to look readyness for
  71348. * @param useInstances Define whether or not the material is used with instances
  71349. * @returns true if ready, otherwise false
  71350. */
  71351. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  71352. /**
  71353. * Clones the current material and its related sub materials
  71354. * @param name Define the name of the newly cloned material
  71355. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  71356. * @returns the cloned material
  71357. */
  71358. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  71359. /**
  71360. * Serializes the materials into a JSON representation.
  71361. * @returns the JSON representation
  71362. */
  71363. serialize(): any;
  71364. /**
  71365. * Dispose the material and release its associated resources
  71366. * @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)
  71367. * @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)
  71368. * @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)
  71369. */
  71370. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  71371. /**
  71372. * Creates a MultiMaterial from parsed MultiMaterial data.
  71373. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  71374. * @param scene defines the hosting scene
  71375. * @returns a new MultiMaterial
  71376. */
  71377. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  71378. }
  71379. }
  71380. declare module BABYLON {
  71381. /**
  71382. * Class used to represent data loading progression
  71383. */
  71384. export class SceneLoaderFlags {
  71385. private static _ForceFullSceneLoadingForIncremental;
  71386. private static _ShowLoadingScreen;
  71387. private static _CleanBoneMatrixWeights;
  71388. private static _loggingLevel;
  71389. /**
  71390. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  71391. */
  71392. static ForceFullSceneLoadingForIncremental: boolean;
  71393. /**
  71394. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  71395. */
  71396. static ShowLoadingScreen: boolean;
  71397. /**
  71398. * Defines the current logging level (while loading the scene)
  71399. * @ignorenaming
  71400. */
  71401. static loggingLevel: number;
  71402. /**
  71403. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  71404. */
  71405. static CleanBoneMatrixWeights: boolean;
  71406. }
  71407. }
  71408. declare module BABYLON {
  71409. /**
  71410. * 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.
  71411. * @see https://doc.babylonjs.com/how_to/transformnode
  71412. */
  71413. export class TransformNode extends Node {
  71414. /**
  71415. * Object will not rotate to face the camera
  71416. */
  71417. static BILLBOARDMODE_NONE: number;
  71418. /**
  71419. * Object will rotate to face the camera but only on the x axis
  71420. */
  71421. static BILLBOARDMODE_X: number;
  71422. /**
  71423. * Object will rotate to face the camera but only on the y axis
  71424. */
  71425. static BILLBOARDMODE_Y: number;
  71426. /**
  71427. * Object will rotate to face the camera but only on the z axis
  71428. */
  71429. static BILLBOARDMODE_Z: number;
  71430. /**
  71431. * Object will rotate to face the camera
  71432. */
  71433. static BILLBOARDMODE_ALL: number;
  71434. private _forward;
  71435. private _forwardInverted;
  71436. private _up;
  71437. private _right;
  71438. private _rightInverted;
  71439. private _position;
  71440. private _rotation;
  71441. private _rotationQuaternion;
  71442. protected _scaling: Vector3;
  71443. protected _isDirty: boolean;
  71444. private _transformToBoneReferal;
  71445. private _billboardMode;
  71446. /**
  71447. * Gets or sets the billboard mode. Default is 0.
  71448. *
  71449. * | Value | Type | Description |
  71450. * | --- | --- | --- |
  71451. * | 0 | BILLBOARDMODE_NONE | |
  71452. * | 1 | BILLBOARDMODE_X | |
  71453. * | 2 | BILLBOARDMODE_Y | |
  71454. * | 4 | BILLBOARDMODE_Z | |
  71455. * | 7 | BILLBOARDMODE_ALL | |
  71456. *
  71457. */
  71458. billboardMode: number;
  71459. private _preserveParentRotationForBillboard;
  71460. /**
  71461. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  71462. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  71463. */
  71464. preserveParentRotationForBillboard: boolean;
  71465. /**
  71466. * 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
  71467. */
  71468. scalingDeterminant: number;
  71469. private _infiniteDistance;
  71470. /**
  71471. * Gets or sets the distance of the object to max, often used by skybox
  71472. */
  71473. infiniteDistance: boolean;
  71474. /**
  71475. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  71476. * By default the system will update normals to compensate
  71477. */
  71478. ignoreNonUniformScaling: boolean;
  71479. /**
  71480. * 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
  71481. */
  71482. reIntegrateRotationIntoRotationQuaternion: boolean;
  71483. /** @hidden */
  71484. _poseMatrix: Nullable<Matrix>;
  71485. /** @hidden */
  71486. _localMatrix: Matrix;
  71487. private _usePivotMatrix;
  71488. private _absolutePosition;
  71489. private _pivotMatrix;
  71490. private _pivotMatrixInverse;
  71491. protected _postMultiplyPivotMatrix: boolean;
  71492. protected _isWorldMatrixFrozen: boolean;
  71493. /** @hidden */
  71494. _indexInSceneTransformNodesArray: number;
  71495. /**
  71496. * An event triggered after the world matrix is updated
  71497. */
  71498. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  71499. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  71500. /**
  71501. * Gets a string identifying the name of the class
  71502. * @returns "TransformNode" string
  71503. */
  71504. getClassName(): string;
  71505. /**
  71506. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  71507. */
  71508. position: Vector3;
  71509. /**
  71510. * 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)).
  71511. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  71512. */
  71513. rotation: Vector3;
  71514. /**
  71515. * 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)).
  71516. */
  71517. scaling: Vector3;
  71518. /**
  71519. * 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).
  71520. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  71521. */
  71522. rotationQuaternion: Nullable<Quaternion>;
  71523. /**
  71524. * The forward direction of that transform in world space.
  71525. */
  71526. readonly forward: Vector3;
  71527. /**
  71528. * The up direction of that transform in world space.
  71529. */
  71530. readonly up: Vector3;
  71531. /**
  71532. * The right direction of that transform in world space.
  71533. */
  71534. readonly right: Vector3;
  71535. /**
  71536. * Copies the parameter passed Matrix into the mesh Pose matrix.
  71537. * @param matrix the matrix to copy the pose from
  71538. * @returns this TransformNode.
  71539. */
  71540. updatePoseMatrix(matrix: Matrix): TransformNode;
  71541. /**
  71542. * Returns the mesh Pose matrix.
  71543. * @returns the pose matrix
  71544. */
  71545. getPoseMatrix(): Matrix;
  71546. /** @hidden */
  71547. _isSynchronized(): boolean;
  71548. /** @hidden */
  71549. _initCache(): void;
  71550. /**
  71551. * Flag the transform node as dirty (Forcing it to update everything)
  71552. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  71553. * @returns this transform node
  71554. */
  71555. markAsDirty(property: string): TransformNode;
  71556. /**
  71557. * Returns the current mesh absolute position.
  71558. * Returns a Vector3.
  71559. */
  71560. readonly absolutePosition: Vector3;
  71561. /**
  71562. * Sets a new matrix to apply before all other transformation
  71563. * @param matrix defines the transform matrix
  71564. * @returns the current TransformNode
  71565. */
  71566. setPreTransformMatrix(matrix: Matrix): TransformNode;
  71567. /**
  71568. * Sets a new pivot matrix to the current node
  71569. * @param matrix defines the new pivot matrix to use
  71570. * @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
  71571. * @returns the current TransformNode
  71572. */
  71573. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  71574. /**
  71575. * Returns the mesh pivot matrix.
  71576. * Default : Identity.
  71577. * @returns the matrix
  71578. */
  71579. getPivotMatrix(): Matrix;
  71580. /**
  71581. * Prevents the World matrix to be computed any longer.
  71582. * @returns the TransformNode.
  71583. */
  71584. freezeWorldMatrix(): TransformNode;
  71585. /**
  71586. * Allows back the World matrix computation.
  71587. * @returns the TransformNode.
  71588. */
  71589. unfreezeWorldMatrix(): this;
  71590. /**
  71591. * True if the World matrix has been frozen.
  71592. */
  71593. readonly isWorldMatrixFrozen: boolean;
  71594. /**
  71595. * Retuns the mesh absolute position in the World.
  71596. * @returns a Vector3.
  71597. */
  71598. getAbsolutePosition(): Vector3;
  71599. /**
  71600. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  71601. * @param absolutePosition the absolute position to set
  71602. * @returns the TransformNode.
  71603. */
  71604. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  71605. /**
  71606. * Sets the mesh position in its local space.
  71607. * @param vector3 the position to set in localspace
  71608. * @returns the TransformNode.
  71609. */
  71610. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  71611. /**
  71612. * Returns the mesh position in the local space from the current World matrix values.
  71613. * @returns a new Vector3.
  71614. */
  71615. getPositionExpressedInLocalSpace(): Vector3;
  71616. /**
  71617. * Translates the mesh along the passed Vector3 in its local space.
  71618. * @param vector3 the distance to translate in localspace
  71619. * @returns the TransformNode.
  71620. */
  71621. locallyTranslate(vector3: Vector3): TransformNode;
  71622. private static _lookAtVectorCache;
  71623. /**
  71624. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  71625. * @param targetPoint the position (must be in same space as current mesh) to look at
  71626. * @param yawCor optional yaw (y-axis) correction in radians
  71627. * @param pitchCor optional pitch (x-axis) correction in radians
  71628. * @param rollCor optional roll (z-axis) correction in radians
  71629. * @param space the choosen space of the target
  71630. * @returns the TransformNode.
  71631. */
  71632. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  71633. /**
  71634. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  71635. * This Vector3 is expressed in the World space.
  71636. * @param localAxis axis to rotate
  71637. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  71638. */
  71639. getDirection(localAxis: Vector3): Vector3;
  71640. /**
  71641. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  71642. * localAxis is expressed in the mesh local space.
  71643. * result is computed in the Wordl space from the mesh World matrix.
  71644. * @param localAxis axis to rotate
  71645. * @param result the resulting transformnode
  71646. * @returns this TransformNode.
  71647. */
  71648. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  71649. /**
  71650. * Sets this transform node rotation to the given local axis.
  71651. * @param localAxis the axis in local space
  71652. * @param yawCor optional yaw (y-axis) correction in radians
  71653. * @param pitchCor optional pitch (x-axis) correction in radians
  71654. * @param rollCor optional roll (z-axis) correction in radians
  71655. * @returns this TransformNode
  71656. */
  71657. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  71658. /**
  71659. * Sets a new pivot point to the current node
  71660. * @param point defines the new pivot point to use
  71661. * @param space defines if the point is in world or local space (local by default)
  71662. * @returns the current TransformNode
  71663. */
  71664. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  71665. /**
  71666. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  71667. * @returns the pivot point
  71668. */
  71669. getPivotPoint(): Vector3;
  71670. /**
  71671. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  71672. * @param result the vector3 to store the result
  71673. * @returns this TransformNode.
  71674. */
  71675. getPivotPointToRef(result: Vector3): TransformNode;
  71676. /**
  71677. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  71678. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  71679. */
  71680. getAbsolutePivotPoint(): Vector3;
  71681. /**
  71682. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  71683. * @param result vector3 to store the result
  71684. * @returns this TransformNode.
  71685. */
  71686. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  71687. /**
  71688. * Defines the passed node as the parent of the current node.
  71689. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  71690. * @see https://doc.babylonjs.com/how_to/parenting
  71691. * @param node the node ot set as the parent
  71692. * @returns this TransformNode.
  71693. */
  71694. setParent(node: Nullable<Node>): TransformNode;
  71695. private _nonUniformScaling;
  71696. /**
  71697. * True if the scaling property of this object is non uniform eg. (1,2,1)
  71698. */
  71699. readonly nonUniformScaling: boolean;
  71700. /** @hidden */
  71701. _updateNonUniformScalingState(value: boolean): boolean;
  71702. /**
  71703. * Attach the current TransformNode to another TransformNode associated with a bone
  71704. * @param bone Bone affecting the TransformNode
  71705. * @param affectedTransformNode TransformNode associated with the bone
  71706. * @returns this object
  71707. */
  71708. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  71709. /**
  71710. * Detach the transform node if its associated with a bone
  71711. * @returns this object
  71712. */
  71713. detachFromBone(): TransformNode;
  71714. private static _rotationAxisCache;
  71715. /**
  71716. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  71717. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  71718. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  71719. * The passed axis is also normalized.
  71720. * @param axis the axis to rotate around
  71721. * @param amount the amount to rotate in radians
  71722. * @param space Space to rotate in (Default: local)
  71723. * @returns the TransformNode.
  71724. */
  71725. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  71726. /**
  71727. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  71728. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  71729. * The passed axis is also normalized. .
  71730. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  71731. * @param point the point to rotate around
  71732. * @param axis the axis to rotate around
  71733. * @param amount the amount to rotate in radians
  71734. * @returns the TransformNode
  71735. */
  71736. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  71737. /**
  71738. * Translates the mesh along the axis vector for the passed distance in the given space.
  71739. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  71740. * @param axis the axis to translate in
  71741. * @param distance the distance to translate
  71742. * @param space Space to rotate in (Default: local)
  71743. * @returns the TransformNode.
  71744. */
  71745. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  71746. /**
  71747. * Adds a rotation step to the mesh current rotation.
  71748. * x, y, z are Euler angles expressed in radians.
  71749. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  71750. * This means this rotation is made in the mesh local space only.
  71751. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  71752. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  71753. * ```javascript
  71754. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  71755. * ```
  71756. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  71757. * 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.
  71758. * @param x Rotation to add
  71759. * @param y Rotation to add
  71760. * @param z Rotation to add
  71761. * @returns the TransformNode.
  71762. */
  71763. addRotation(x: number, y: number, z: number): TransformNode;
  71764. /**
  71765. * @hidden
  71766. */
  71767. protected _getEffectiveParent(): Nullable<Node>;
  71768. /**
  71769. * Computes the world matrix of the node
  71770. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  71771. * @returns the world matrix
  71772. */
  71773. computeWorldMatrix(force?: boolean): Matrix;
  71774. protected _afterComputeWorldMatrix(): void;
  71775. /**
  71776. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  71777. * @param func callback function to add
  71778. *
  71779. * @returns the TransformNode.
  71780. */
  71781. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  71782. /**
  71783. * Removes a registered callback function.
  71784. * @param func callback function to remove
  71785. * @returns the TransformNode.
  71786. */
  71787. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  71788. /**
  71789. * Gets the position of the current mesh in camera space
  71790. * @param camera defines the camera to use
  71791. * @returns a position
  71792. */
  71793. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  71794. /**
  71795. * Returns the distance from the mesh to the active camera
  71796. * @param camera defines the camera to use
  71797. * @returns the distance
  71798. */
  71799. getDistanceToCamera(camera?: Nullable<Camera>): number;
  71800. /**
  71801. * Clone the current transform node
  71802. * @param name Name of the new clone
  71803. * @param newParent New parent for the clone
  71804. * @param doNotCloneChildren Do not clone children hierarchy
  71805. * @returns the new transform node
  71806. */
  71807. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  71808. /**
  71809. * Serializes the objects information.
  71810. * @param currentSerializationObject defines the object to serialize in
  71811. * @returns the serialized object
  71812. */
  71813. serialize(currentSerializationObject?: any): any;
  71814. /**
  71815. * Returns a new TransformNode object parsed from the source provided.
  71816. * @param parsedTransformNode is the source.
  71817. * @param scene the scne the object belongs to
  71818. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  71819. * @returns a new TransformNode object parsed from the source provided.
  71820. */
  71821. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  71822. /**
  71823. * Get all child-transformNodes of this node
  71824. * @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
  71825. * @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
  71826. * @returns an array of TransformNode
  71827. */
  71828. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  71829. /**
  71830. * Releases resources associated with this transform node.
  71831. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  71832. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  71833. */
  71834. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  71835. /**
  71836. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  71837. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  71838. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  71839. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  71840. * @returns the current mesh
  71841. */
  71842. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  71843. }
  71844. }
  71845. declare module BABYLON {
  71846. /**
  71847. * Class used to override all child animations of a given target
  71848. */
  71849. export class AnimationPropertiesOverride {
  71850. /**
  71851. * Gets or sets a value indicating if animation blending must be used
  71852. */
  71853. enableBlending: boolean;
  71854. /**
  71855. * Gets or sets the blending speed to use when enableBlending is true
  71856. */
  71857. blendingSpeed: number;
  71858. /**
  71859. * Gets or sets the default loop mode to use
  71860. */
  71861. loopMode: number;
  71862. }
  71863. }
  71864. declare module BABYLON {
  71865. /**
  71866. * Class used to store bone information
  71867. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  71868. */
  71869. export class Bone extends Node {
  71870. /**
  71871. * defines the bone name
  71872. */
  71873. name: string;
  71874. private static _tmpVecs;
  71875. private static _tmpQuat;
  71876. private static _tmpMats;
  71877. /**
  71878. * Gets the list of child bones
  71879. */
  71880. children: Bone[];
  71881. /** Gets the animations associated with this bone */
  71882. animations: Animation[];
  71883. /**
  71884. * Gets or sets bone length
  71885. */
  71886. length: number;
  71887. /**
  71888. * @hidden Internal only
  71889. * Set this value to map this bone to a different index in the transform matrices
  71890. * Set this value to -1 to exclude the bone from the transform matrices
  71891. */
  71892. _index: Nullable<number>;
  71893. private _skeleton;
  71894. private _localMatrix;
  71895. private _restPose;
  71896. private _baseMatrix;
  71897. private _absoluteTransform;
  71898. private _invertedAbsoluteTransform;
  71899. private _parent;
  71900. private _scalingDeterminant;
  71901. private _worldTransform;
  71902. private _localScaling;
  71903. private _localRotation;
  71904. private _localPosition;
  71905. private _needToDecompose;
  71906. private _needToCompose;
  71907. /** @hidden */
  71908. _linkedTransformNode: Nullable<TransformNode>;
  71909. /** @hidden */
  71910. _waitingTransformNodeId: Nullable<string>;
  71911. /** @hidden */
  71912. /** @hidden */
  71913. _matrix: Matrix;
  71914. /**
  71915. * Create a new bone
  71916. * @param name defines the bone name
  71917. * @param skeleton defines the parent skeleton
  71918. * @param parentBone defines the parent (can be null if the bone is the root)
  71919. * @param localMatrix defines the local matrix
  71920. * @param restPose defines the rest pose matrix
  71921. * @param baseMatrix defines the base matrix
  71922. * @param index defines index of the bone in the hiearchy
  71923. */
  71924. constructor(
  71925. /**
  71926. * defines the bone name
  71927. */
  71928. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  71929. /**
  71930. * Gets the current object class name.
  71931. * @return the class name
  71932. */
  71933. getClassName(): string;
  71934. /**
  71935. * Gets the parent skeleton
  71936. * @returns a skeleton
  71937. */
  71938. getSkeleton(): Skeleton;
  71939. /**
  71940. * Gets parent bone
  71941. * @returns a bone or null if the bone is the root of the bone hierarchy
  71942. */
  71943. getParent(): Nullable<Bone>;
  71944. /**
  71945. * Returns an array containing the root bones
  71946. * @returns an array containing the root bones
  71947. */
  71948. getChildren(): Array<Bone>;
  71949. /**
  71950. * Sets the parent bone
  71951. * @param parent defines the parent (can be null if the bone is the root)
  71952. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  71953. */
  71954. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  71955. /**
  71956. * Gets the local matrix
  71957. * @returns a matrix
  71958. */
  71959. getLocalMatrix(): Matrix;
  71960. /**
  71961. * Gets the base matrix (initial matrix which remains unchanged)
  71962. * @returns a matrix
  71963. */
  71964. getBaseMatrix(): Matrix;
  71965. /**
  71966. * Gets the rest pose matrix
  71967. * @returns a matrix
  71968. */
  71969. getRestPose(): Matrix;
  71970. /**
  71971. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  71972. */
  71973. getWorldMatrix(): Matrix;
  71974. /**
  71975. * Sets the local matrix to rest pose matrix
  71976. */
  71977. returnToRest(): void;
  71978. /**
  71979. * Gets the inverse of the absolute transform matrix.
  71980. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  71981. * @returns a matrix
  71982. */
  71983. getInvertedAbsoluteTransform(): Matrix;
  71984. /**
  71985. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  71986. * @returns a matrix
  71987. */
  71988. getAbsoluteTransform(): Matrix;
  71989. /**
  71990. * Links with the given transform node.
  71991. * The local matrix of this bone is copied from the transform node every frame.
  71992. * @param transformNode defines the transform node to link to
  71993. */
  71994. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  71995. /** Gets or sets current position (in local space) */
  71996. position: Vector3;
  71997. /** Gets or sets current rotation (in local space) */
  71998. rotation: Vector3;
  71999. /** Gets or sets current rotation quaternion (in local space) */
  72000. rotationQuaternion: Quaternion;
  72001. /** Gets or sets current scaling (in local space) */
  72002. scaling: Vector3;
  72003. /**
  72004. * Gets the animation properties override
  72005. */
  72006. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  72007. private _decompose;
  72008. private _compose;
  72009. /**
  72010. * Update the base and local matrices
  72011. * @param matrix defines the new base or local matrix
  72012. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  72013. * @param updateLocalMatrix defines if the local matrix should be updated
  72014. */
  72015. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  72016. /** @hidden */
  72017. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  72018. /**
  72019. * Flag the bone as dirty (Forcing it to update everything)
  72020. */
  72021. markAsDirty(): void;
  72022. /** @hidden */
  72023. _markAsDirtyAndCompose(): void;
  72024. private _markAsDirtyAndDecompose;
  72025. /**
  72026. * Translate the bone in local or world space
  72027. * @param vec The amount to translate the bone
  72028. * @param space The space that the translation is in
  72029. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72030. */
  72031. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  72032. /**
  72033. * Set the postion of the bone in local or world space
  72034. * @param position The position to set the bone
  72035. * @param space The space that the position is in
  72036. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72037. */
  72038. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  72039. /**
  72040. * Set the absolute position of the bone (world space)
  72041. * @param position The position to set the bone
  72042. * @param mesh The mesh that this bone is attached to
  72043. */
  72044. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  72045. /**
  72046. * Scale the bone on the x, y and z axes (in local space)
  72047. * @param x The amount to scale the bone on the x axis
  72048. * @param y The amount to scale the bone on the y axis
  72049. * @param z The amount to scale the bone on the z axis
  72050. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  72051. */
  72052. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  72053. /**
  72054. * Set the bone scaling in local space
  72055. * @param scale defines the scaling vector
  72056. */
  72057. setScale(scale: Vector3): void;
  72058. /**
  72059. * Gets the current scaling in local space
  72060. * @returns the current scaling vector
  72061. */
  72062. getScale(): Vector3;
  72063. /**
  72064. * Gets the current scaling in local space and stores it in a target vector
  72065. * @param result defines the target vector
  72066. */
  72067. getScaleToRef(result: Vector3): void;
  72068. /**
  72069. * Set the yaw, pitch, and roll of the bone in local or world space
  72070. * @param yaw The rotation of the bone on the y axis
  72071. * @param pitch The rotation of the bone on the x axis
  72072. * @param roll The rotation of the bone on the z axis
  72073. * @param space The space that the axes of rotation are in
  72074. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72075. */
  72076. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  72077. /**
  72078. * Add a rotation to the bone on an axis in local or world space
  72079. * @param axis The axis to rotate the bone on
  72080. * @param amount The amount to rotate the bone
  72081. * @param space The space that the axis is in
  72082. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72083. */
  72084. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  72085. /**
  72086. * Set the rotation of the bone to a particular axis angle in local or world space
  72087. * @param axis The axis to rotate the bone on
  72088. * @param angle The angle that the bone should be rotated to
  72089. * @param space The space that the axis is in
  72090. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72091. */
  72092. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  72093. /**
  72094. * Set the euler rotation of the bone in local of world space
  72095. * @param rotation The euler rotation that the bone should be set to
  72096. * @param space The space that the rotation is in
  72097. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72098. */
  72099. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  72100. /**
  72101. * Set the quaternion rotation of the bone in local of world space
  72102. * @param quat The quaternion rotation that the bone should be set to
  72103. * @param space The space that the rotation is in
  72104. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72105. */
  72106. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  72107. /**
  72108. * Set the rotation matrix of the bone in local of world space
  72109. * @param rotMat The rotation matrix that the bone should be set to
  72110. * @param space The space that the rotation is in
  72111. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72112. */
  72113. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  72114. private _rotateWithMatrix;
  72115. private _getNegativeRotationToRef;
  72116. /**
  72117. * Get the position of the bone in local or world space
  72118. * @param space The space that the returned position is in
  72119. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72120. * @returns The position of the bone
  72121. */
  72122. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  72123. /**
  72124. * Copy the position of the bone to a vector3 in local or world space
  72125. * @param space The space that the returned position is in
  72126. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72127. * @param result The vector3 to copy the position to
  72128. */
  72129. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  72130. /**
  72131. * Get the absolute position of the bone (world space)
  72132. * @param mesh The mesh that this bone is attached to
  72133. * @returns The absolute position of the bone
  72134. */
  72135. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  72136. /**
  72137. * Copy the absolute position of the bone (world space) to the result param
  72138. * @param mesh The mesh that this bone is attached to
  72139. * @param result The vector3 to copy the absolute position to
  72140. */
  72141. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  72142. /**
  72143. * Compute the absolute transforms of this bone and its children
  72144. */
  72145. computeAbsoluteTransforms(): void;
  72146. /**
  72147. * Get the world direction from an axis that is in the local space of the bone
  72148. * @param localAxis The local direction that is used to compute the world direction
  72149. * @param mesh The mesh that this bone is attached to
  72150. * @returns The world direction
  72151. */
  72152. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  72153. /**
  72154. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  72155. * @param localAxis The local direction that is used to compute the world direction
  72156. * @param mesh The mesh that this bone is attached to
  72157. * @param result The vector3 that the world direction will be copied to
  72158. */
  72159. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  72160. /**
  72161. * Get the euler rotation of the bone in local or world space
  72162. * @param space The space that the rotation should be in
  72163. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72164. * @returns The euler rotation
  72165. */
  72166. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  72167. /**
  72168. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  72169. * @param space The space that the rotation should be in
  72170. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72171. * @param result The vector3 that the rotation should be copied to
  72172. */
  72173. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  72174. /**
  72175. * Get the quaternion rotation of the bone in either local or world space
  72176. * @param space The space that the rotation should be in
  72177. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72178. * @returns The quaternion rotation
  72179. */
  72180. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  72181. /**
  72182. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  72183. * @param space The space that the rotation should be in
  72184. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72185. * @param result The quaternion that the rotation should be copied to
  72186. */
  72187. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  72188. /**
  72189. * Get the rotation matrix of the bone in local or world space
  72190. * @param space The space that the rotation should be in
  72191. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72192. * @returns The rotation matrix
  72193. */
  72194. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  72195. /**
  72196. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  72197. * @param space The space that the rotation should be in
  72198. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72199. * @param result The quaternion that the rotation should be copied to
  72200. */
  72201. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  72202. /**
  72203. * Get the world position of a point that is in the local space of the bone
  72204. * @param position The local position
  72205. * @param mesh The mesh that this bone is attached to
  72206. * @returns The world position
  72207. */
  72208. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  72209. /**
  72210. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  72211. * @param position The local position
  72212. * @param mesh The mesh that this bone is attached to
  72213. * @param result The vector3 that the world position should be copied to
  72214. */
  72215. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  72216. /**
  72217. * Get the local position of a point that is in world space
  72218. * @param position The world position
  72219. * @param mesh The mesh that this bone is attached to
  72220. * @returns The local position
  72221. */
  72222. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  72223. /**
  72224. * Get the local position of a point that is in world space and copy it to the result param
  72225. * @param position The world position
  72226. * @param mesh The mesh that this bone is attached to
  72227. * @param result The vector3 that the local position should be copied to
  72228. */
  72229. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  72230. }
  72231. }
  72232. declare module BABYLON {
  72233. interface Engine {
  72234. /**
  72235. * Creates a raw texture
  72236. * @param data defines the data to store in the texture
  72237. * @param width defines the width of the texture
  72238. * @param height defines the height of the texture
  72239. * @param format defines the format of the data
  72240. * @param generateMipMaps defines if the engine should generate the mip levels
  72241. * @param invertY defines if data must be stored with Y axis inverted
  72242. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  72243. * @param compression defines the compression used (null by default)
  72244. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72245. * @returns the raw texture inside an InternalTexture
  72246. */
  72247. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  72248. /**
  72249. * Update a raw texture
  72250. * @param texture defines the texture to update
  72251. * @param data defines the data to store in the texture
  72252. * @param format defines the format of the data
  72253. * @param invertY defines if data must be stored with Y axis inverted
  72254. */
  72255. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  72256. /**
  72257. * Update a raw texture
  72258. * @param texture defines the texture to update
  72259. * @param data defines the data to store in the texture
  72260. * @param format defines the format of the data
  72261. * @param invertY defines if data must be stored with Y axis inverted
  72262. * @param compression defines the compression used (null by default)
  72263. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72264. */
  72265. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  72266. /**
  72267. * Creates a new raw cube texture
  72268. * @param data defines the array of data to use to create each face
  72269. * @param size defines the size of the textures
  72270. * @param format defines the format of the data
  72271. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  72272. * @param generateMipMaps defines if the engine should generate the mip levels
  72273. * @param invertY defines if data must be stored with Y axis inverted
  72274. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  72275. * @param compression defines the compression used (null by default)
  72276. * @returns the cube texture as an InternalTexture
  72277. */
  72278. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  72279. /**
  72280. * Update a raw cube texture
  72281. * @param texture defines the texture to udpdate
  72282. * @param data defines the data to store
  72283. * @param format defines the data format
  72284. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72285. * @param invertY defines if data must be stored with Y axis inverted
  72286. */
  72287. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  72288. /**
  72289. * Update a raw cube texture
  72290. * @param texture defines the texture to udpdate
  72291. * @param data defines the data to store
  72292. * @param format defines the data format
  72293. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72294. * @param invertY defines if data must be stored with Y axis inverted
  72295. * @param compression defines the compression used (null by default)
  72296. */
  72297. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  72298. /**
  72299. * Update a raw cube texture
  72300. * @param texture defines the texture to udpdate
  72301. * @param data defines the data to store
  72302. * @param format defines the data format
  72303. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72304. * @param invertY defines if data must be stored with Y axis inverted
  72305. * @param compression defines the compression used (null by default)
  72306. * @param level defines which level of the texture to update
  72307. */
  72308. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  72309. /**
  72310. * Creates a new raw cube texture from a specified url
  72311. * @param url defines the url where the data is located
  72312. * @param scene defines the current scene
  72313. * @param size defines the size of the textures
  72314. * @param format defines the format of the data
  72315. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  72316. * @param noMipmap defines if the engine should avoid generating the mip levels
  72317. * @param callback defines a callback used to extract texture data from loaded data
  72318. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  72319. * @param onLoad defines a callback called when texture is loaded
  72320. * @param onError defines a callback called if there is an error
  72321. * @returns the cube texture as an InternalTexture
  72322. */
  72323. 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;
  72324. /**
  72325. * Creates a new raw cube texture from a specified url
  72326. * @param url defines the url where the data is located
  72327. * @param scene defines the current scene
  72328. * @param size defines the size of the textures
  72329. * @param format defines the format of the data
  72330. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  72331. * @param noMipmap defines if the engine should avoid generating the mip levels
  72332. * @param callback defines a callback used to extract texture data from loaded data
  72333. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  72334. * @param onLoad defines a callback called when texture is loaded
  72335. * @param onError defines a callback called if there is an error
  72336. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  72337. * @param invertY defines if data must be stored with Y axis inverted
  72338. * @returns the cube texture as an InternalTexture
  72339. */
  72340. 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;
  72341. /**
  72342. * Creates a new raw 3D texture
  72343. * @param data defines the data used to create the texture
  72344. * @param width defines the width of the texture
  72345. * @param height defines the height of the texture
  72346. * @param depth defines the depth of the texture
  72347. * @param format defines the format of the texture
  72348. * @param generateMipMaps defines if the engine must generate mip levels
  72349. * @param invertY defines if data must be stored with Y axis inverted
  72350. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  72351. * @param compression defines the compressed used (can be null)
  72352. * @param textureType defines the compressed used (can be null)
  72353. * @returns a new raw 3D texture (stored in an InternalTexture)
  72354. */
  72355. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  72356. /**
  72357. * Update a raw 3D texture
  72358. * @param texture defines the texture to update
  72359. * @param data defines the data to store
  72360. * @param format defines the data format
  72361. * @param invertY defines if data must be stored with Y axis inverted
  72362. */
  72363. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  72364. /**
  72365. * Update a raw 3D texture
  72366. * @param texture defines the texture to update
  72367. * @param data defines the data to store
  72368. * @param format defines the data format
  72369. * @param invertY defines if data must be stored with Y axis inverted
  72370. * @param compression defines the used compression (can be null)
  72371. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  72372. */
  72373. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  72374. }
  72375. }
  72376. declare module BABYLON {
  72377. /**
  72378. * Raw texture can help creating a texture directly from an array of data.
  72379. * This can be super useful if you either get the data from an uncompressed source or
  72380. * if you wish to create your texture pixel by pixel.
  72381. */
  72382. export class RawTexture extends Texture {
  72383. /**
  72384. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  72385. */
  72386. format: number;
  72387. private _engine;
  72388. /**
  72389. * Instantiates a new RawTexture.
  72390. * Raw texture can help creating a texture directly from an array of data.
  72391. * This can be super useful if you either get the data from an uncompressed source or
  72392. * if you wish to create your texture pixel by pixel.
  72393. * @param data define the array of data to use to create the texture
  72394. * @param width define the width of the texture
  72395. * @param height define the height of the texture
  72396. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  72397. * @param scene define the scene the texture belongs to
  72398. * @param generateMipMaps define whether mip maps should be generated or not
  72399. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72400. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72401. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72402. */
  72403. constructor(data: ArrayBufferView, width: number, height: number,
  72404. /**
  72405. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  72406. */
  72407. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  72408. /**
  72409. * Updates the texture underlying data.
  72410. * @param data Define the new data of the texture
  72411. */
  72412. update(data: ArrayBufferView): void;
  72413. /**
  72414. * Creates a luminance texture from some data.
  72415. * @param data Define the texture data
  72416. * @param width Define the width of the texture
  72417. * @param height Define the height of the texture
  72418. * @param scene Define the scene the texture belongs to
  72419. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72420. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72421. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72422. * @returns the luminance texture
  72423. */
  72424. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72425. /**
  72426. * Creates a luminance alpha texture from some data.
  72427. * @param data Define the texture data
  72428. * @param width Define the width of the texture
  72429. * @param height Define the height of the texture
  72430. * @param scene Define the scene the texture belongs to
  72431. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72432. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72433. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72434. * @returns the luminance alpha texture
  72435. */
  72436. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72437. /**
  72438. * Creates an alpha texture from some data.
  72439. * @param data Define the texture data
  72440. * @param width Define the width of the texture
  72441. * @param height Define the height of the texture
  72442. * @param scene Define the scene the texture belongs to
  72443. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72444. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72445. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72446. * @returns the alpha texture
  72447. */
  72448. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72449. /**
  72450. * Creates a RGB texture from some data.
  72451. * @param data Define the texture data
  72452. * @param width Define the width of the texture
  72453. * @param height Define the height of the texture
  72454. * @param scene Define the scene the texture belongs to
  72455. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72456. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72457. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72458. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72459. * @returns the RGB alpha texture
  72460. */
  72461. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72462. /**
  72463. * Creates a RGBA texture from some data.
  72464. * @param data Define the texture data
  72465. * @param width Define the width of the texture
  72466. * @param height Define the height of the texture
  72467. * @param scene Define the scene the texture belongs to
  72468. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72469. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72470. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72471. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72472. * @returns the RGBA texture
  72473. */
  72474. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72475. /**
  72476. * Creates a R texture from some data.
  72477. * @param data Define the texture data
  72478. * @param width Define the width of the texture
  72479. * @param height Define the height of the texture
  72480. * @param scene Define the scene the texture belongs to
  72481. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72482. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72483. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72484. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72485. * @returns the R texture
  72486. */
  72487. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72488. }
  72489. }
  72490. declare module BABYLON {
  72491. /**
  72492. * Defines a runtime animation
  72493. */
  72494. export class RuntimeAnimation {
  72495. private _events;
  72496. /**
  72497. * The current frame of the runtime animation
  72498. */
  72499. private _currentFrame;
  72500. /**
  72501. * The animation used by the runtime animation
  72502. */
  72503. private _animation;
  72504. /**
  72505. * The target of the runtime animation
  72506. */
  72507. private _target;
  72508. /**
  72509. * The initiating animatable
  72510. */
  72511. private _host;
  72512. /**
  72513. * The original value of the runtime animation
  72514. */
  72515. private _originalValue;
  72516. /**
  72517. * The original blend value of the runtime animation
  72518. */
  72519. private _originalBlendValue;
  72520. /**
  72521. * The offsets cache of the runtime animation
  72522. */
  72523. private _offsetsCache;
  72524. /**
  72525. * The high limits cache of the runtime animation
  72526. */
  72527. private _highLimitsCache;
  72528. /**
  72529. * Specifies if the runtime animation has been stopped
  72530. */
  72531. private _stopped;
  72532. /**
  72533. * The blending factor of the runtime animation
  72534. */
  72535. private _blendingFactor;
  72536. /**
  72537. * The BabylonJS scene
  72538. */
  72539. private _scene;
  72540. /**
  72541. * The current value of the runtime animation
  72542. */
  72543. private _currentValue;
  72544. /** @hidden */
  72545. _animationState: _IAnimationState;
  72546. /**
  72547. * The active target of the runtime animation
  72548. */
  72549. private _activeTargets;
  72550. private _currentActiveTarget;
  72551. private _directTarget;
  72552. /**
  72553. * The target path of the runtime animation
  72554. */
  72555. private _targetPath;
  72556. /**
  72557. * The weight of the runtime animation
  72558. */
  72559. private _weight;
  72560. /**
  72561. * The ratio offset of the runtime animation
  72562. */
  72563. private _ratioOffset;
  72564. /**
  72565. * The previous delay of the runtime animation
  72566. */
  72567. private _previousDelay;
  72568. /**
  72569. * The previous ratio of the runtime animation
  72570. */
  72571. private _previousRatio;
  72572. private _enableBlending;
  72573. private _keys;
  72574. private _minFrame;
  72575. private _maxFrame;
  72576. private _minValue;
  72577. private _maxValue;
  72578. private _targetIsArray;
  72579. /**
  72580. * Gets the current frame of the runtime animation
  72581. */
  72582. readonly currentFrame: number;
  72583. /**
  72584. * Gets the weight of the runtime animation
  72585. */
  72586. readonly weight: number;
  72587. /**
  72588. * Gets the current value of the runtime animation
  72589. */
  72590. readonly currentValue: any;
  72591. /**
  72592. * Gets the target path of the runtime animation
  72593. */
  72594. readonly targetPath: string;
  72595. /**
  72596. * Gets the actual target of the runtime animation
  72597. */
  72598. readonly target: any;
  72599. /** @hidden */
  72600. _onLoop: () => void;
  72601. /**
  72602. * Create a new RuntimeAnimation object
  72603. * @param target defines the target of the animation
  72604. * @param animation defines the source animation object
  72605. * @param scene defines the hosting scene
  72606. * @param host defines the initiating Animatable
  72607. */
  72608. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  72609. private _preparePath;
  72610. /**
  72611. * Gets the animation from the runtime animation
  72612. */
  72613. readonly animation: Animation;
  72614. /**
  72615. * Resets the runtime animation to the beginning
  72616. * @param restoreOriginal defines whether to restore the target property to the original value
  72617. */
  72618. reset(restoreOriginal?: boolean): void;
  72619. /**
  72620. * Specifies if the runtime animation is stopped
  72621. * @returns Boolean specifying if the runtime animation is stopped
  72622. */
  72623. isStopped(): boolean;
  72624. /**
  72625. * Disposes of the runtime animation
  72626. */
  72627. dispose(): void;
  72628. /**
  72629. * Apply the interpolated value to the target
  72630. * @param currentValue defines the value computed by the animation
  72631. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  72632. */
  72633. setValue(currentValue: any, weight: number): void;
  72634. private _getOriginalValues;
  72635. private _setValue;
  72636. /**
  72637. * Gets the loop pmode of the runtime animation
  72638. * @returns Loop Mode
  72639. */
  72640. private _getCorrectLoopMode;
  72641. /**
  72642. * Move the current animation to a given frame
  72643. * @param frame defines the frame to move to
  72644. */
  72645. goToFrame(frame: number): void;
  72646. /**
  72647. * @hidden Internal use only
  72648. */
  72649. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  72650. /**
  72651. * Execute the current animation
  72652. * @param delay defines the delay to add to the current frame
  72653. * @param from defines the lower bound of the animation range
  72654. * @param to defines the upper bound of the animation range
  72655. * @param loop defines if the current animation must loop
  72656. * @param speedRatio defines the current speed ratio
  72657. * @param weight defines the weight of the animation (default is -1 so no weight)
  72658. * @param onLoop optional callback called when animation loops
  72659. * @returns a boolean indicating if the animation is running
  72660. */
  72661. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  72662. }
  72663. }
  72664. declare module BABYLON {
  72665. /**
  72666. * Class used to store an actual running animation
  72667. */
  72668. export class Animatable {
  72669. /** defines the target object */
  72670. target: any;
  72671. /** defines the starting frame number (default is 0) */
  72672. fromFrame: number;
  72673. /** defines the ending frame number (default is 100) */
  72674. toFrame: number;
  72675. /** defines if the animation must loop (default is false) */
  72676. loopAnimation: boolean;
  72677. /** defines a callback to call when animation ends if it is not looping */
  72678. onAnimationEnd?: (() => void) | null | undefined;
  72679. /** defines a callback to call when animation loops */
  72680. onAnimationLoop?: (() => void) | null | undefined;
  72681. private _localDelayOffset;
  72682. private _pausedDelay;
  72683. private _runtimeAnimations;
  72684. private _paused;
  72685. private _scene;
  72686. private _speedRatio;
  72687. private _weight;
  72688. private _syncRoot;
  72689. /**
  72690. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  72691. * This will only apply for non looping animation (default is true)
  72692. */
  72693. disposeOnEnd: boolean;
  72694. /**
  72695. * Gets a boolean indicating if the animation has started
  72696. */
  72697. animationStarted: boolean;
  72698. /**
  72699. * Observer raised when the animation ends
  72700. */
  72701. onAnimationEndObservable: Observable<Animatable>;
  72702. /**
  72703. * Observer raised when the animation loops
  72704. */
  72705. onAnimationLoopObservable: Observable<Animatable>;
  72706. /**
  72707. * Gets the root Animatable used to synchronize and normalize animations
  72708. */
  72709. readonly syncRoot: Nullable<Animatable>;
  72710. /**
  72711. * Gets the current frame of the first RuntimeAnimation
  72712. * Used to synchronize Animatables
  72713. */
  72714. readonly masterFrame: number;
  72715. /**
  72716. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  72717. */
  72718. weight: number;
  72719. /**
  72720. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  72721. */
  72722. speedRatio: number;
  72723. /**
  72724. * Creates a new Animatable
  72725. * @param scene defines the hosting scene
  72726. * @param target defines the target object
  72727. * @param fromFrame defines the starting frame number (default is 0)
  72728. * @param toFrame defines the ending frame number (default is 100)
  72729. * @param loopAnimation defines if the animation must loop (default is false)
  72730. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  72731. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  72732. * @param animations defines a group of animation to add to the new Animatable
  72733. * @param onAnimationLoop defines a callback to call when animation loops
  72734. */
  72735. constructor(scene: Scene,
  72736. /** defines the target object */
  72737. target: any,
  72738. /** defines the starting frame number (default is 0) */
  72739. fromFrame?: number,
  72740. /** defines the ending frame number (default is 100) */
  72741. toFrame?: number,
  72742. /** defines if the animation must loop (default is false) */
  72743. loopAnimation?: boolean, speedRatio?: number,
  72744. /** defines a callback to call when animation ends if it is not looping */
  72745. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  72746. /** defines a callback to call when animation loops */
  72747. onAnimationLoop?: (() => void) | null | undefined);
  72748. /**
  72749. * Synchronize and normalize current Animatable with a source Animatable
  72750. * This is useful when using animation weights and when animations are not of the same length
  72751. * @param root defines the root Animatable to synchronize with
  72752. * @returns the current Animatable
  72753. */
  72754. syncWith(root: Animatable): Animatable;
  72755. /**
  72756. * Gets the list of runtime animations
  72757. * @returns an array of RuntimeAnimation
  72758. */
  72759. getAnimations(): RuntimeAnimation[];
  72760. /**
  72761. * Adds more animations to the current animatable
  72762. * @param target defines the target of the animations
  72763. * @param animations defines the new animations to add
  72764. */
  72765. appendAnimations(target: any, animations: Animation[]): void;
  72766. /**
  72767. * Gets the source animation for a specific property
  72768. * @param property defines the propertyu to look for
  72769. * @returns null or the source animation for the given property
  72770. */
  72771. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  72772. /**
  72773. * Gets the runtime animation for a specific property
  72774. * @param property defines the propertyu to look for
  72775. * @returns null or the runtime animation for the given property
  72776. */
  72777. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  72778. /**
  72779. * Resets the animatable to its original state
  72780. */
  72781. reset(): void;
  72782. /**
  72783. * Allows the animatable to blend with current running animations
  72784. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  72785. * @param blendingSpeed defines the blending speed to use
  72786. */
  72787. enableBlending(blendingSpeed: number): void;
  72788. /**
  72789. * Disable animation blending
  72790. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  72791. */
  72792. disableBlending(): void;
  72793. /**
  72794. * Jump directly to a given frame
  72795. * @param frame defines the frame to jump to
  72796. */
  72797. goToFrame(frame: number): void;
  72798. /**
  72799. * Pause the animation
  72800. */
  72801. pause(): void;
  72802. /**
  72803. * Restart the animation
  72804. */
  72805. restart(): void;
  72806. private _raiseOnAnimationEnd;
  72807. /**
  72808. * Stop and delete the current animation
  72809. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  72810. * @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)
  72811. */
  72812. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  72813. /**
  72814. * Wait asynchronously for the animation to end
  72815. * @returns a promise which will be fullfilled when the animation ends
  72816. */
  72817. waitAsync(): Promise<Animatable>;
  72818. /** @hidden */
  72819. _animate(delay: number): boolean;
  72820. }
  72821. interface Scene {
  72822. /** @hidden */
  72823. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  72824. /** @hidden */
  72825. _processLateAnimationBindingsForMatrices(holder: {
  72826. totalWeight: number;
  72827. animations: RuntimeAnimation[];
  72828. originalValue: Matrix;
  72829. }): any;
  72830. /** @hidden */
  72831. _processLateAnimationBindingsForQuaternions(holder: {
  72832. totalWeight: number;
  72833. animations: RuntimeAnimation[];
  72834. originalValue: Quaternion;
  72835. }, refQuaternion: Quaternion): Quaternion;
  72836. /** @hidden */
  72837. _processLateAnimationBindings(): void;
  72838. /**
  72839. * Will start the animation sequence of a given target
  72840. * @param target defines the target
  72841. * @param from defines from which frame should animation start
  72842. * @param to defines until which frame should animation run.
  72843. * @param weight defines the weight to apply to the animation (1.0 by default)
  72844. * @param loop defines if the animation loops
  72845. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72846. * @param onAnimationEnd defines the function to be executed when the animation ends
  72847. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72848. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  72849. * @param onAnimationLoop defines the callback to call when an animation loops
  72850. * @returns the animatable object created for this animation
  72851. */
  72852. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  72853. /**
  72854. * Will start the animation sequence of a given target
  72855. * @param target defines the target
  72856. * @param from defines from which frame should animation start
  72857. * @param to defines until which frame should animation run.
  72858. * @param loop defines if the animation loops
  72859. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72860. * @param onAnimationEnd defines the function to be executed when the animation ends
  72861. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72862. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  72863. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  72864. * @param onAnimationLoop defines the callback to call when an animation loops
  72865. * @returns the animatable object created for this animation
  72866. */
  72867. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  72868. /**
  72869. * Will start the animation sequence of a given target and its hierarchy
  72870. * @param target defines the target
  72871. * @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.
  72872. * @param from defines from which frame should animation start
  72873. * @param to defines until which frame should animation run.
  72874. * @param loop defines if the animation loops
  72875. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72876. * @param onAnimationEnd defines the function to be executed when the animation ends
  72877. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72878. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  72879. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  72880. * @param onAnimationLoop defines the callback to call when an animation loops
  72881. * @returns the list of created animatables
  72882. */
  72883. 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[];
  72884. /**
  72885. * Begin a new animation on a given node
  72886. * @param target defines the target where the animation will take place
  72887. * @param animations defines the list of animations to start
  72888. * @param from defines the initial value
  72889. * @param to defines the final value
  72890. * @param loop defines if you want animation to loop (off by default)
  72891. * @param speedRatio defines the speed ratio to apply to all animations
  72892. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  72893. * @param onAnimationLoop defines the callback to call when an animation loops
  72894. * @returns the list of created animatables
  72895. */
  72896. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  72897. /**
  72898. * Begin a new animation on a given node and its hierarchy
  72899. * @param target defines the root node where the animation will take place
  72900. * @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.
  72901. * @param animations defines the list of animations to start
  72902. * @param from defines the initial value
  72903. * @param to defines the final value
  72904. * @param loop defines if you want animation to loop (off by default)
  72905. * @param speedRatio defines the speed ratio to apply to all animations
  72906. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  72907. * @param onAnimationLoop defines the callback to call when an animation loops
  72908. * @returns the list of animatables created for all nodes
  72909. */
  72910. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  72911. /**
  72912. * Gets the animatable associated with a specific target
  72913. * @param target defines the target of the animatable
  72914. * @returns the required animatable if found
  72915. */
  72916. getAnimatableByTarget(target: any): Nullable<Animatable>;
  72917. /**
  72918. * Gets all animatables associated with a given target
  72919. * @param target defines the target to look animatables for
  72920. * @returns an array of Animatables
  72921. */
  72922. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  72923. /**
  72924. * Stops and removes all animations that have been applied to the scene
  72925. */
  72926. stopAllAnimations(): void;
  72927. }
  72928. interface Bone {
  72929. /**
  72930. * Copy an animation range from another bone
  72931. * @param source defines the source bone
  72932. * @param rangeName defines the range name to copy
  72933. * @param frameOffset defines the frame offset
  72934. * @param rescaleAsRequired defines if rescaling must be applied if required
  72935. * @param skelDimensionsRatio defines the scaling ratio
  72936. * @returns true if operation was successful
  72937. */
  72938. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  72939. }
  72940. }
  72941. declare module BABYLON {
  72942. /**
  72943. * Class used to handle skinning animations
  72944. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  72945. */
  72946. export class Skeleton implements IAnimatable {
  72947. /** defines the skeleton name */
  72948. name: string;
  72949. /** defines the skeleton Id */
  72950. id: string;
  72951. /**
  72952. * Defines the list of child bones
  72953. */
  72954. bones: Bone[];
  72955. /**
  72956. * Defines an estimate of the dimension of the skeleton at rest
  72957. */
  72958. dimensionsAtRest: Vector3;
  72959. /**
  72960. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  72961. */
  72962. needInitialSkinMatrix: boolean;
  72963. /**
  72964. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  72965. */
  72966. overrideMesh: Nullable<AbstractMesh>;
  72967. /**
  72968. * Gets the list of animations attached to this skeleton
  72969. */
  72970. animations: Array<Animation>;
  72971. private _scene;
  72972. private _isDirty;
  72973. private _transformMatrices;
  72974. private _transformMatrixTexture;
  72975. private _meshesWithPoseMatrix;
  72976. private _animatables;
  72977. private _identity;
  72978. private _synchronizedWithMesh;
  72979. private _ranges;
  72980. private _lastAbsoluteTransformsUpdateId;
  72981. private _canUseTextureForBones;
  72982. private _uniqueId;
  72983. /** @hidden */
  72984. _numBonesWithLinkedTransformNode: number;
  72985. /** @hidden */
  72986. _hasWaitingData: Nullable<boolean>;
  72987. /**
  72988. * Specifies if the skeleton should be serialized
  72989. */
  72990. doNotSerialize: boolean;
  72991. private _useTextureToStoreBoneMatrices;
  72992. /**
  72993. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  72994. * Please note that this option is not available if the hardware does not support it
  72995. */
  72996. useTextureToStoreBoneMatrices: boolean;
  72997. private _animationPropertiesOverride;
  72998. /**
  72999. * Gets or sets the animation properties override
  73000. */
  73001. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  73002. /**
  73003. * List of inspectable custom properties (used by the Inspector)
  73004. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73005. */
  73006. inspectableCustomProperties: IInspectable[];
  73007. /**
  73008. * An observable triggered before computing the skeleton's matrices
  73009. */
  73010. onBeforeComputeObservable: Observable<Skeleton>;
  73011. /**
  73012. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  73013. */
  73014. readonly isUsingTextureForMatrices: boolean;
  73015. /**
  73016. * Gets the unique ID of this skeleton
  73017. */
  73018. readonly uniqueId: number;
  73019. /**
  73020. * Creates a new skeleton
  73021. * @param name defines the skeleton name
  73022. * @param id defines the skeleton Id
  73023. * @param scene defines the hosting scene
  73024. */
  73025. constructor(
  73026. /** defines the skeleton name */
  73027. name: string,
  73028. /** defines the skeleton Id */
  73029. id: string, scene: Scene);
  73030. /**
  73031. * Gets the current object class name.
  73032. * @return the class name
  73033. */
  73034. getClassName(): string;
  73035. /**
  73036. * Returns an array containing the root bones
  73037. * @returns an array containing the root bones
  73038. */
  73039. getChildren(): Array<Bone>;
  73040. /**
  73041. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  73042. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  73043. * @returns a Float32Array containing matrices data
  73044. */
  73045. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  73046. /**
  73047. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  73048. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  73049. * @returns a raw texture containing the data
  73050. */
  73051. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  73052. /**
  73053. * Gets the current hosting scene
  73054. * @returns a scene object
  73055. */
  73056. getScene(): Scene;
  73057. /**
  73058. * Gets a string representing the current skeleton data
  73059. * @param fullDetails defines a boolean indicating if we want a verbose version
  73060. * @returns a string representing the current skeleton data
  73061. */
  73062. toString(fullDetails?: boolean): string;
  73063. /**
  73064. * Get bone's index searching by name
  73065. * @param name defines bone's name to search for
  73066. * @return the indice of the bone. Returns -1 if not found
  73067. */
  73068. getBoneIndexByName(name: string): number;
  73069. /**
  73070. * Creater a new animation range
  73071. * @param name defines the name of the range
  73072. * @param from defines the start key
  73073. * @param to defines the end key
  73074. */
  73075. createAnimationRange(name: string, from: number, to: number): void;
  73076. /**
  73077. * Delete a specific animation range
  73078. * @param name defines the name of the range
  73079. * @param deleteFrames defines if frames must be removed as well
  73080. */
  73081. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  73082. /**
  73083. * Gets a specific animation range
  73084. * @param name defines the name of the range to look for
  73085. * @returns the requested animation range or null if not found
  73086. */
  73087. getAnimationRange(name: string): Nullable<AnimationRange>;
  73088. /**
  73089. * Gets the list of all animation ranges defined on this skeleton
  73090. * @returns an array
  73091. */
  73092. getAnimationRanges(): Nullable<AnimationRange>[];
  73093. /**
  73094. * Copy animation range from a source skeleton.
  73095. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  73096. * @param source defines the source skeleton
  73097. * @param name defines the name of the range to copy
  73098. * @param rescaleAsRequired defines if rescaling must be applied if required
  73099. * @returns true if operation was successful
  73100. */
  73101. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  73102. /**
  73103. * Forces the skeleton to go to rest pose
  73104. */
  73105. returnToRest(): void;
  73106. private _getHighestAnimationFrame;
  73107. /**
  73108. * Begin a specific animation range
  73109. * @param name defines the name of the range to start
  73110. * @param loop defines if looping must be turned on (false by default)
  73111. * @param speedRatio defines the speed ratio to apply (1 by default)
  73112. * @param onAnimationEnd defines a callback which will be called when animation will end
  73113. * @returns a new animatable
  73114. */
  73115. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  73116. /** @hidden */
  73117. _markAsDirty(): void;
  73118. /** @hidden */
  73119. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  73120. /** @hidden */
  73121. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  73122. private _computeTransformMatrices;
  73123. /**
  73124. * Build all resources required to render a skeleton
  73125. */
  73126. prepare(): void;
  73127. /**
  73128. * Gets the list of animatables currently running for this skeleton
  73129. * @returns an array of animatables
  73130. */
  73131. getAnimatables(): IAnimatable[];
  73132. /**
  73133. * Clone the current skeleton
  73134. * @param name defines the name of the new skeleton
  73135. * @param id defines the id of the new skeleton
  73136. * @returns the new skeleton
  73137. */
  73138. clone(name: string, id: string): Skeleton;
  73139. /**
  73140. * Enable animation blending for this skeleton
  73141. * @param blendingSpeed defines the blending speed to apply
  73142. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  73143. */
  73144. enableBlending(blendingSpeed?: number): void;
  73145. /**
  73146. * Releases all resources associated with the current skeleton
  73147. */
  73148. dispose(): void;
  73149. /**
  73150. * Serialize the skeleton in a JSON object
  73151. * @returns a JSON object
  73152. */
  73153. serialize(): any;
  73154. /**
  73155. * Creates a new skeleton from serialized data
  73156. * @param parsedSkeleton defines the serialized data
  73157. * @param scene defines the hosting scene
  73158. * @returns a new skeleton
  73159. */
  73160. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  73161. /**
  73162. * Compute all node absolute transforms
  73163. * @param forceUpdate defines if computation must be done even if cache is up to date
  73164. */
  73165. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  73166. /**
  73167. * Gets the root pose matrix
  73168. * @returns a matrix
  73169. */
  73170. getPoseMatrix(): Nullable<Matrix>;
  73171. /**
  73172. * Sorts bones per internal index
  73173. */
  73174. sortBones(): void;
  73175. private _sortBones;
  73176. }
  73177. }
  73178. declare module BABYLON {
  73179. /**
  73180. * Defines a target to use with MorphTargetManager
  73181. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  73182. */
  73183. export class MorphTarget implements IAnimatable {
  73184. /** defines the name of the target */
  73185. name: string;
  73186. /**
  73187. * Gets or sets the list of animations
  73188. */
  73189. animations: Animation[];
  73190. private _scene;
  73191. private _positions;
  73192. private _normals;
  73193. private _tangents;
  73194. private _uvs;
  73195. private _influence;
  73196. /**
  73197. * Observable raised when the influence changes
  73198. */
  73199. onInfluenceChanged: Observable<boolean>;
  73200. /** @hidden */
  73201. _onDataLayoutChanged: Observable<void>;
  73202. /**
  73203. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  73204. */
  73205. influence: number;
  73206. /**
  73207. * Gets or sets the id of the morph Target
  73208. */
  73209. id: string;
  73210. private _animationPropertiesOverride;
  73211. /**
  73212. * Gets or sets the animation properties override
  73213. */
  73214. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  73215. /**
  73216. * Creates a new MorphTarget
  73217. * @param name defines the name of the target
  73218. * @param influence defines the influence to use
  73219. * @param scene defines the scene the morphtarget belongs to
  73220. */
  73221. constructor(
  73222. /** defines the name of the target */
  73223. name: string, influence?: number, scene?: Nullable<Scene>);
  73224. /**
  73225. * Gets a boolean defining if the target contains position data
  73226. */
  73227. readonly hasPositions: boolean;
  73228. /**
  73229. * Gets a boolean defining if the target contains normal data
  73230. */
  73231. readonly hasNormals: boolean;
  73232. /**
  73233. * Gets a boolean defining if the target contains tangent data
  73234. */
  73235. readonly hasTangents: boolean;
  73236. /**
  73237. * Gets a boolean defining if the target contains texture coordinates data
  73238. */
  73239. readonly hasUVs: boolean;
  73240. /**
  73241. * Affects position data to this target
  73242. * @param data defines the position data to use
  73243. */
  73244. setPositions(data: Nullable<FloatArray>): void;
  73245. /**
  73246. * Gets the position data stored in this target
  73247. * @returns a FloatArray containing the position data (or null if not present)
  73248. */
  73249. getPositions(): Nullable<FloatArray>;
  73250. /**
  73251. * Affects normal data to this target
  73252. * @param data defines the normal data to use
  73253. */
  73254. setNormals(data: Nullable<FloatArray>): void;
  73255. /**
  73256. * Gets the normal data stored in this target
  73257. * @returns a FloatArray containing the normal data (or null if not present)
  73258. */
  73259. getNormals(): Nullable<FloatArray>;
  73260. /**
  73261. * Affects tangent data to this target
  73262. * @param data defines the tangent data to use
  73263. */
  73264. setTangents(data: Nullable<FloatArray>): void;
  73265. /**
  73266. * Gets the tangent data stored in this target
  73267. * @returns a FloatArray containing the tangent data (or null if not present)
  73268. */
  73269. getTangents(): Nullable<FloatArray>;
  73270. /**
  73271. * Affects texture coordinates data to this target
  73272. * @param data defines the texture coordinates data to use
  73273. */
  73274. setUVs(data: Nullable<FloatArray>): void;
  73275. /**
  73276. * Gets the texture coordinates data stored in this target
  73277. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  73278. */
  73279. getUVs(): Nullable<FloatArray>;
  73280. /**
  73281. * Serializes the current target into a Serialization object
  73282. * @returns the serialized object
  73283. */
  73284. serialize(): any;
  73285. /**
  73286. * Returns the string "MorphTarget"
  73287. * @returns "MorphTarget"
  73288. */
  73289. getClassName(): string;
  73290. /**
  73291. * Creates a new target from serialized data
  73292. * @param serializationObject defines the serialized data to use
  73293. * @returns a new MorphTarget
  73294. */
  73295. static Parse(serializationObject: any): MorphTarget;
  73296. /**
  73297. * Creates a MorphTarget from mesh data
  73298. * @param mesh defines the source mesh
  73299. * @param name defines the name to use for the new target
  73300. * @param influence defines the influence to attach to the target
  73301. * @returns a new MorphTarget
  73302. */
  73303. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  73304. }
  73305. }
  73306. declare module BABYLON {
  73307. /**
  73308. * This class is used to deform meshes using morphing between different targets
  73309. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  73310. */
  73311. export class MorphTargetManager {
  73312. private _targets;
  73313. private _targetInfluenceChangedObservers;
  73314. private _targetDataLayoutChangedObservers;
  73315. private _activeTargets;
  73316. private _scene;
  73317. private _influences;
  73318. private _supportsNormals;
  73319. private _supportsTangents;
  73320. private _supportsUVs;
  73321. private _vertexCount;
  73322. private _uniqueId;
  73323. private _tempInfluences;
  73324. /**
  73325. * Gets or sets a boolean indicating if normals must be morphed
  73326. */
  73327. enableNormalMorphing: boolean;
  73328. /**
  73329. * Gets or sets a boolean indicating if tangents must be morphed
  73330. */
  73331. enableTangentMorphing: boolean;
  73332. /**
  73333. * Gets or sets a boolean indicating if UV must be morphed
  73334. */
  73335. enableUVMorphing: boolean;
  73336. /**
  73337. * Creates a new MorphTargetManager
  73338. * @param scene defines the current scene
  73339. */
  73340. constructor(scene?: Nullable<Scene>);
  73341. /**
  73342. * Gets the unique ID of this manager
  73343. */
  73344. readonly uniqueId: number;
  73345. /**
  73346. * Gets the number of vertices handled by this manager
  73347. */
  73348. readonly vertexCount: number;
  73349. /**
  73350. * Gets a boolean indicating if this manager supports morphing of normals
  73351. */
  73352. readonly supportsNormals: boolean;
  73353. /**
  73354. * Gets a boolean indicating if this manager supports morphing of tangents
  73355. */
  73356. readonly supportsTangents: boolean;
  73357. /**
  73358. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  73359. */
  73360. readonly supportsUVs: boolean;
  73361. /**
  73362. * Gets the number of targets stored in this manager
  73363. */
  73364. readonly numTargets: number;
  73365. /**
  73366. * Gets the number of influencers (ie. the number of targets with influences > 0)
  73367. */
  73368. readonly numInfluencers: number;
  73369. /**
  73370. * Gets the list of influences (one per target)
  73371. */
  73372. readonly influences: Float32Array;
  73373. /**
  73374. * Gets the active target at specified index. An active target is a target with an influence > 0
  73375. * @param index defines the index to check
  73376. * @returns the requested target
  73377. */
  73378. getActiveTarget(index: number): MorphTarget;
  73379. /**
  73380. * Gets the target at specified index
  73381. * @param index defines the index to check
  73382. * @returns the requested target
  73383. */
  73384. getTarget(index: number): MorphTarget;
  73385. /**
  73386. * Add a new target to this manager
  73387. * @param target defines the target to add
  73388. */
  73389. addTarget(target: MorphTarget): void;
  73390. /**
  73391. * Removes a target from the manager
  73392. * @param target defines the target to remove
  73393. */
  73394. removeTarget(target: MorphTarget): void;
  73395. /**
  73396. * Serializes the current manager into a Serialization object
  73397. * @returns the serialized object
  73398. */
  73399. serialize(): any;
  73400. private _syncActiveTargets;
  73401. /**
  73402. * Syncrhonize the targets with all the meshes using this morph target manager
  73403. */
  73404. synchronize(): void;
  73405. /**
  73406. * Creates a new MorphTargetManager from serialized data
  73407. * @param serializationObject defines the serialized data
  73408. * @param scene defines the hosting scene
  73409. * @returns the new MorphTargetManager
  73410. */
  73411. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  73412. }
  73413. }
  73414. declare module BABYLON {
  73415. /**
  73416. * Groups all the scene component constants in one place to ease maintenance.
  73417. * @hidden
  73418. */
  73419. export class SceneComponentConstants {
  73420. static readonly NAME_EFFECTLAYER: string;
  73421. static readonly NAME_LAYER: string;
  73422. static readonly NAME_LENSFLARESYSTEM: string;
  73423. static readonly NAME_BOUNDINGBOXRENDERER: string;
  73424. static readonly NAME_PARTICLESYSTEM: string;
  73425. static readonly NAME_GAMEPAD: string;
  73426. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  73427. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  73428. static readonly NAME_DEPTHRENDERER: string;
  73429. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  73430. static readonly NAME_SPRITE: string;
  73431. static readonly NAME_OUTLINERENDERER: string;
  73432. static readonly NAME_PROCEDURALTEXTURE: string;
  73433. static readonly NAME_SHADOWGENERATOR: string;
  73434. static readonly NAME_OCTREE: string;
  73435. static readonly NAME_PHYSICSENGINE: string;
  73436. static readonly NAME_AUDIO: string;
  73437. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  73438. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  73439. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  73440. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  73441. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  73442. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  73443. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  73444. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  73445. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  73446. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  73447. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  73448. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  73449. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  73450. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  73451. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  73452. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  73453. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  73454. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  73455. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  73456. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  73457. static readonly STEP_AFTERRENDER_AUDIO: number;
  73458. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  73459. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  73460. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  73461. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  73462. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  73463. static readonly STEP_POINTERMOVE_SPRITE: number;
  73464. static readonly STEP_POINTERDOWN_SPRITE: number;
  73465. static readonly STEP_POINTERUP_SPRITE: number;
  73466. }
  73467. /**
  73468. * This represents a scene component.
  73469. *
  73470. * This is used to decouple the dependency the scene is having on the different workloads like
  73471. * layers, post processes...
  73472. */
  73473. export interface ISceneComponent {
  73474. /**
  73475. * The name of the component. Each component must have a unique name.
  73476. */
  73477. name: string;
  73478. /**
  73479. * The scene the component belongs to.
  73480. */
  73481. scene: Scene;
  73482. /**
  73483. * Register the component to one instance of a scene.
  73484. */
  73485. register(): void;
  73486. /**
  73487. * Rebuilds the elements related to this component in case of
  73488. * context lost for instance.
  73489. */
  73490. rebuild(): void;
  73491. /**
  73492. * Disposes the component and the associated ressources.
  73493. */
  73494. dispose(): void;
  73495. }
  73496. /**
  73497. * This represents a SERIALIZABLE scene component.
  73498. *
  73499. * This extends Scene Component to add Serialization methods on top.
  73500. */
  73501. export interface ISceneSerializableComponent extends ISceneComponent {
  73502. /**
  73503. * Adds all the elements from the container to the scene
  73504. * @param container the container holding the elements
  73505. */
  73506. addFromContainer(container: AbstractScene): void;
  73507. /**
  73508. * Removes all the elements in the container from the scene
  73509. * @param container contains the elements to remove
  73510. * @param dispose if the removed element should be disposed (default: false)
  73511. */
  73512. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  73513. /**
  73514. * Serializes the component data to the specified json object
  73515. * @param serializationObject The object to serialize to
  73516. */
  73517. serialize(serializationObject: any): void;
  73518. }
  73519. /**
  73520. * Strong typing of a Mesh related stage step action
  73521. */
  73522. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  73523. /**
  73524. * Strong typing of a Evaluate Sub Mesh related stage step action
  73525. */
  73526. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  73527. /**
  73528. * Strong typing of a Active Mesh related stage step action
  73529. */
  73530. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  73531. /**
  73532. * Strong typing of a Camera related stage step action
  73533. */
  73534. export type CameraStageAction = (camera: Camera) => void;
  73535. /**
  73536. * Strong typing of a Camera Frame buffer related stage step action
  73537. */
  73538. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  73539. /**
  73540. * Strong typing of a Render Target related stage step action
  73541. */
  73542. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  73543. /**
  73544. * Strong typing of a RenderingGroup related stage step action
  73545. */
  73546. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  73547. /**
  73548. * Strong typing of a Mesh Render related stage step action
  73549. */
  73550. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  73551. /**
  73552. * Strong typing of a simple stage step action
  73553. */
  73554. export type SimpleStageAction = () => void;
  73555. /**
  73556. * Strong typing of a render target action.
  73557. */
  73558. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  73559. /**
  73560. * Strong typing of a pointer move action.
  73561. */
  73562. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  73563. /**
  73564. * Strong typing of a pointer up/down action.
  73565. */
  73566. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  73567. /**
  73568. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  73569. * @hidden
  73570. */
  73571. export class Stage<T extends Function> extends Array<{
  73572. index: number;
  73573. component: ISceneComponent;
  73574. action: T;
  73575. }> {
  73576. /**
  73577. * Hide ctor from the rest of the world.
  73578. * @param items The items to add.
  73579. */
  73580. private constructor();
  73581. /**
  73582. * Creates a new Stage.
  73583. * @returns A new instance of a Stage
  73584. */
  73585. static Create<T extends Function>(): Stage<T>;
  73586. /**
  73587. * Registers a step in an ordered way in the targeted stage.
  73588. * @param index Defines the position to register the step in
  73589. * @param component Defines the component attached to the step
  73590. * @param action Defines the action to launch during the step
  73591. */
  73592. registerStep(index: number, component: ISceneComponent, action: T): void;
  73593. /**
  73594. * Clears all the steps from the stage.
  73595. */
  73596. clear(): void;
  73597. }
  73598. }
  73599. declare module BABYLON {
  73600. /**
  73601. * Class used to represent a specific level of detail of a mesh
  73602. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  73603. */
  73604. export class MeshLODLevel {
  73605. /** Defines the distance where this level should star being displayed */
  73606. distance: number;
  73607. /** Defines the mesh to use to render this level */
  73608. mesh: Nullable<Mesh>;
  73609. /**
  73610. * Creates a new LOD level
  73611. * @param distance defines the distance where this level should star being displayed
  73612. * @param mesh defines the mesh to use to render this level
  73613. */
  73614. constructor(
  73615. /** Defines the distance where this level should star being displayed */
  73616. distance: number,
  73617. /** Defines the mesh to use to render this level */
  73618. mesh: Nullable<Mesh>);
  73619. }
  73620. }
  73621. declare module BABYLON {
  73622. /**
  73623. * Interface describing all the common properties and methods a shadow light needs to implement.
  73624. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  73625. * as well as binding the different shadow properties to the effects.
  73626. */
  73627. export interface IShadowLight extends Light {
  73628. /**
  73629. * The light id in the scene (used in scene.findLighById for instance)
  73630. */
  73631. id: string;
  73632. /**
  73633. * The position the shdow will be casted from.
  73634. */
  73635. position: Vector3;
  73636. /**
  73637. * In 2d mode (needCube being false), the direction used to cast the shadow.
  73638. */
  73639. direction: Vector3;
  73640. /**
  73641. * The transformed position. Position of the light in world space taking parenting in account.
  73642. */
  73643. transformedPosition: Vector3;
  73644. /**
  73645. * The transformed direction. Direction of the light in world space taking parenting in account.
  73646. */
  73647. transformedDirection: Vector3;
  73648. /**
  73649. * The friendly name of the light in the scene.
  73650. */
  73651. name: string;
  73652. /**
  73653. * Defines the shadow projection clipping minimum z value.
  73654. */
  73655. shadowMinZ: number;
  73656. /**
  73657. * Defines the shadow projection clipping maximum z value.
  73658. */
  73659. shadowMaxZ: number;
  73660. /**
  73661. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73662. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73663. */
  73664. computeTransformedInformation(): boolean;
  73665. /**
  73666. * Gets the scene the light belongs to.
  73667. * @returns The scene
  73668. */
  73669. getScene(): Scene;
  73670. /**
  73671. * Callback defining a custom Projection Matrix Builder.
  73672. * This can be used to override the default projection matrix computation.
  73673. */
  73674. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73675. /**
  73676. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73677. * @param matrix The materix to updated with the projection information
  73678. * @param viewMatrix The transform matrix of the light
  73679. * @param renderList The list of mesh to render in the map
  73680. * @returns The current light
  73681. */
  73682. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73683. /**
  73684. * Gets the current depth scale used in ESM.
  73685. * @returns The scale
  73686. */
  73687. getDepthScale(): number;
  73688. /**
  73689. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73690. * @returns true if a cube texture needs to be use
  73691. */
  73692. needCube(): boolean;
  73693. /**
  73694. * Detects if the projection matrix requires to be recomputed this frame.
  73695. * @returns true if it requires to be recomputed otherwise, false.
  73696. */
  73697. needProjectionMatrixCompute(): boolean;
  73698. /**
  73699. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73700. */
  73701. forceProjectionMatrixCompute(): void;
  73702. /**
  73703. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73704. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73705. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73706. */
  73707. getShadowDirection(faceIndex?: number): Vector3;
  73708. /**
  73709. * Gets the minZ used for shadow according to both the scene and the light.
  73710. * @param activeCamera The camera we are returning the min for
  73711. * @returns the depth min z
  73712. */
  73713. getDepthMinZ(activeCamera: Camera): number;
  73714. /**
  73715. * Gets the maxZ used for shadow according to both the scene and the light.
  73716. * @param activeCamera The camera we are returning the max for
  73717. * @returns the depth max z
  73718. */
  73719. getDepthMaxZ(activeCamera: Camera): number;
  73720. }
  73721. /**
  73722. * Base implementation IShadowLight
  73723. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  73724. */
  73725. export abstract class ShadowLight extends Light implements IShadowLight {
  73726. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  73727. protected _position: Vector3;
  73728. protected _setPosition(value: Vector3): void;
  73729. /**
  73730. * Sets the position the shadow will be casted from. Also use as the light position for both
  73731. * point and spot lights.
  73732. */
  73733. /**
  73734. * Sets the position the shadow will be casted from. Also use as the light position for both
  73735. * point and spot lights.
  73736. */
  73737. position: Vector3;
  73738. protected _direction: Vector3;
  73739. protected _setDirection(value: Vector3): void;
  73740. /**
  73741. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  73742. * Also use as the light direction on spot and directional lights.
  73743. */
  73744. /**
  73745. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  73746. * Also use as the light direction on spot and directional lights.
  73747. */
  73748. direction: Vector3;
  73749. private _shadowMinZ;
  73750. /**
  73751. * Gets the shadow projection clipping minimum z value.
  73752. */
  73753. /**
  73754. * Sets the shadow projection clipping minimum z value.
  73755. */
  73756. shadowMinZ: number;
  73757. private _shadowMaxZ;
  73758. /**
  73759. * Sets the shadow projection clipping maximum z value.
  73760. */
  73761. /**
  73762. * Gets the shadow projection clipping maximum z value.
  73763. */
  73764. shadowMaxZ: number;
  73765. /**
  73766. * Callback defining a custom Projection Matrix Builder.
  73767. * This can be used to override the default projection matrix computation.
  73768. */
  73769. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73770. /**
  73771. * The transformed position. Position of the light in world space taking parenting in account.
  73772. */
  73773. transformedPosition: Vector3;
  73774. /**
  73775. * The transformed direction. Direction of the light in world space taking parenting in account.
  73776. */
  73777. transformedDirection: Vector3;
  73778. private _needProjectionMatrixCompute;
  73779. /**
  73780. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73781. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73782. */
  73783. computeTransformedInformation(): boolean;
  73784. /**
  73785. * Return the depth scale used for the shadow map.
  73786. * @returns the depth scale.
  73787. */
  73788. getDepthScale(): number;
  73789. /**
  73790. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73791. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73792. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73793. */
  73794. getShadowDirection(faceIndex?: number): Vector3;
  73795. /**
  73796. * Returns the ShadowLight absolute position in the World.
  73797. * @returns the position vector in world space
  73798. */
  73799. getAbsolutePosition(): Vector3;
  73800. /**
  73801. * Sets the ShadowLight direction toward the passed target.
  73802. * @param target The point to target in local space
  73803. * @returns the updated ShadowLight direction
  73804. */
  73805. setDirectionToTarget(target: Vector3): Vector3;
  73806. /**
  73807. * Returns the light rotation in euler definition.
  73808. * @returns the x y z rotation in local space.
  73809. */
  73810. getRotation(): Vector3;
  73811. /**
  73812. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73813. * @returns true if a cube texture needs to be use
  73814. */
  73815. needCube(): boolean;
  73816. /**
  73817. * Detects if the projection matrix requires to be recomputed this frame.
  73818. * @returns true if it requires to be recomputed otherwise, false.
  73819. */
  73820. needProjectionMatrixCompute(): boolean;
  73821. /**
  73822. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73823. */
  73824. forceProjectionMatrixCompute(): void;
  73825. /** @hidden */
  73826. _initCache(): void;
  73827. /** @hidden */
  73828. _isSynchronized(): boolean;
  73829. /**
  73830. * Computes the world matrix of the node
  73831. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  73832. * @returns the world matrix
  73833. */
  73834. computeWorldMatrix(force?: boolean): Matrix;
  73835. /**
  73836. * Gets the minZ used for shadow according to both the scene and the light.
  73837. * @param activeCamera The camera we are returning the min for
  73838. * @returns the depth min z
  73839. */
  73840. getDepthMinZ(activeCamera: Camera): number;
  73841. /**
  73842. * Gets the maxZ used for shadow according to both the scene and the light.
  73843. * @param activeCamera The camera we are returning the max for
  73844. * @returns the depth max z
  73845. */
  73846. getDepthMaxZ(activeCamera: Camera): number;
  73847. /**
  73848. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73849. * @param matrix The materix to updated with the projection information
  73850. * @param viewMatrix The transform matrix of the light
  73851. * @param renderList The list of mesh to render in the map
  73852. * @returns The current light
  73853. */
  73854. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73855. }
  73856. }
  73857. declare module BABYLON {
  73858. /**
  73859. * "Static Class" containing the most commonly used helper while dealing with material for
  73860. * rendering purpose.
  73861. *
  73862. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  73863. *
  73864. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  73865. */
  73866. export class MaterialHelper {
  73867. /**
  73868. * Bind the current view position to an effect.
  73869. * @param effect The effect to be bound
  73870. * @param scene The scene the eyes position is used from
  73871. */
  73872. static BindEyePosition(effect: Effect, scene: Scene): void;
  73873. /**
  73874. * Helps preparing the defines values about the UVs in used in the effect.
  73875. * UVs are shared as much as we can accross channels in the shaders.
  73876. * @param texture The texture we are preparing the UVs for
  73877. * @param defines The defines to update
  73878. * @param key The channel key "diffuse", "specular"... used in the shader
  73879. */
  73880. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  73881. /**
  73882. * Binds a texture matrix value to its corrsponding uniform
  73883. * @param texture The texture to bind the matrix for
  73884. * @param uniformBuffer The uniform buffer receivin the data
  73885. * @param key The channel key "diffuse", "specular"... used in the shader
  73886. */
  73887. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  73888. /**
  73889. * Gets the current status of the fog (should it be enabled?)
  73890. * @param mesh defines the mesh to evaluate for fog support
  73891. * @param scene defines the hosting scene
  73892. * @returns true if fog must be enabled
  73893. */
  73894. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  73895. /**
  73896. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  73897. * @param mesh defines the current mesh
  73898. * @param scene defines the current scene
  73899. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  73900. * @param pointsCloud defines if point cloud rendering has to be turned on
  73901. * @param fogEnabled defines if fog has to be turned on
  73902. * @param alphaTest defines if alpha testing has to be turned on
  73903. * @param defines defines the current list of defines
  73904. */
  73905. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  73906. /**
  73907. * Helper used to prepare the list of defines associated with frame values for shader compilation
  73908. * @param scene defines the current scene
  73909. * @param engine defines the current engine
  73910. * @param defines specifies the list of active defines
  73911. * @param useInstances defines if instances have to be turned on
  73912. * @param useClipPlane defines if clip plane have to be turned on
  73913. */
  73914. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  73915. /**
  73916. * Prepares the defines for bones
  73917. * @param mesh The mesh containing the geometry data we will draw
  73918. * @param defines The defines to update
  73919. */
  73920. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  73921. /**
  73922. * Prepares the defines for morph targets
  73923. * @param mesh The mesh containing the geometry data we will draw
  73924. * @param defines The defines to update
  73925. */
  73926. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  73927. /**
  73928. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  73929. * @param mesh The mesh containing the geometry data we will draw
  73930. * @param defines The defines to update
  73931. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  73932. * @param useBones Precise whether bones should be used or not (override mesh info)
  73933. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  73934. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  73935. * @returns false if defines are considered not dirty and have not been checked
  73936. */
  73937. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  73938. /**
  73939. * Prepares the defines related to multiview
  73940. * @param scene The scene we are intending to draw
  73941. * @param defines The defines to update
  73942. */
  73943. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  73944. /**
  73945. * Prepares the defines related to the light information passed in parameter
  73946. * @param scene The scene we are intending to draw
  73947. * @param mesh The mesh the effect is compiling for
  73948. * @param light The light the effect is compiling for
  73949. * @param lightIndex The index of the light
  73950. * @param defines The defines to update
  73951. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73952. * @param state Defines the current state regarding what is needed (normals, etc...)
  73953. */
  73954. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  73955. needNormals: boolean;
  73956. needRebuild: boolean;
  73957. shadowEnabled: boolean;
  73958. specularEnabled: boolean;
  73959. lightmapMode: boolean;
  73960. }): void;
  73961. /**
  73962. * Prepares the defines related to the light information passed in parameter
  73963. * @param scene The scene we are intending to draw
  73964. * @param mesh The mesh the effect is compiling for
  73965. * @param defines The defines to update
  73966. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73967. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  73968. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  73969. * @returns true if normals will be required for the rest of the effect
  73970. */
  73971. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  73972. /**
  73973. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  73974. * @param lightIndex defines the light index
  73975. * @param uniformsList The uniform list
  73976. * @param samplersList The sampler list
  73977. * @param projectedLightTexture defines if projected texture must be used
  73978. * @param uniformBuffersList defines an optional list of uniform buffers
  73979. */
  73980. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  73981. /**
  73982. * Prepares the uniforms and samplers list to be used in the effect
  73983. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  73984. * @param samplersList The sampler list
  73985. * @param defines The defines helping in the list generation
  73986. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  73987. */
  73988. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  73989. /**
  73990. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  73991. * @param defines The defines to update while falling back
  73992. * @param fallbacks The authorized effect fallbacks
  73993. * @param maxSimultaneousLights The maximum number of lights allowed
  73994. * @param rank the current rank of the Effect
  73995. * @returns The newly affected rank
  73996. */
  73997. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  73998. private static _TmpMorphInfluencers;
  73999. /**
  74000. * Prepares the list of attributes required for morph targets according to the effect defines.
  74001. * @param attribs The current list of supported attribs
  74002. * @param mesh The mesh to prepare the morph targets attributes for
  74003. * @param influencers The number of influencers
  74004. */
  74005. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  74006. /**
  74007. * Prepares the list of attributes required for morph targets according to the effect defines.
  74008. * @param attribs The current list of supported attribs
  74009. * @param mesh The mesh to prepare the morph targets attributes for
  74010. * @param defines The current Defines of the effect
  74011. */
  74012. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  74013. /**
  74014. * Prepares the list of attributes required for bones according to the effect defines.
  74015. * @param attribs The current list of supported attribs
  74016. * @param mesh The mesh to prepare the bones attributes for
  74017. * @param defines The current Defines of the effect
  74018. * @param fallbacks The current efffect fallback strategy
  74019. */
  74020. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  74021. /**
  74022. * Check and prepare the list of attributes required for instances according to the effect defines.
  74023. * @param attribs The current list of supported attribs
  74024. * @param defines The current MaterialDefines of the effect
  74025. */
  74026. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  74027. /**
  74028. * Add the list of attributes required for instances to the attribs array.
  74029. * @param attribs The current list of supported attribs
  74030. */
  74031. static PushAttributesForInstances(attribs: string[]): void;
  74032. /**
  74033. * Binds the light shadow information to the effect for the given mesh.
  74034. * @param light The light containing the generator
  74035. * @param scene The scene the lights belongs to
  74036. * @param mesh The mesh we are binding the information to render
  74037. * @param lightIndex The light index in the effect used to render the mesh
  74038. * @param effect The effect we are binding the data to
  74039. */
  74040. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  74041. /**
  74042. * Binds the light information to the effect.
  74043. * @param light The light containing the generator
  74044. * @param effect The effect we are binding the data to
  74045. * @param lightIndex The light index in the effect used to render
  74046. */
  74047. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  74048. /**
  74049. * Binds the lights information from the scene to the effect for the given mesh.
  74050. * @param light Light to bind
  74051. * @param lightIndex Light index
  74052. * @param scene The scene where the light belongs to
  74053. * @param mesh The mesh we are binding the information to render
  74054. * @param effect The effect we are binding the data to
  74055. * @param useSpecular Defines if specular is supported
  74056. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  74057. */
  74058. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  74059. /**
  74060. * Binds the lights information from the scene to the effect for the given mesh.
  74061. * @param scene The scene the lights belongs to
  74062. * @param mesh The mesh we are binding the information to render
  74063. * @param effect The effect we are binding the data to
  74064. * @param defines The generated defines for the effect
  74065. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  74066. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  74067. */
  74068. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  74069. private static _tempFogColor;
  74070. /**
  74071. * Binds the fog information from the scene to the effect for the given mesh.
  74072. * @param scene The scene the lights belongs to
  74073. * @param mesh The mesh we are binding the information to render
  74074. * @param effect The effect we are binding the data to
  74075. * @param linearSpace Defines if the fog effect is applied in linear space
  74076. */
  74077. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  74078. /**
  74079. * Binds the bones information from the mesh to the effect.
  74080. * @param mesh The mesh we are binding the information to render
  74081. * @param effect The effect we are binding the data to
  74082. */
  74083. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  74084. /**
  74085. * Binds the morph targets information from the mesh to the effect.
  74086. * @param abstractMesh The mesh we are binding the information to render
  74087. * @param effect The effect we are binding the data to
  74088. */
  74089. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  74090. /**
  74091. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  74092. * @param defines The generated defines used in the effect
  74093. * @param effect The effect we are binding the data to
  74094. * @param scene The scene we are willing to render with logarithmic scale for
  74095. */
  74096. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  74097. /**
  74098. * Binds the clip plane information from the scene to the effect.
  74099. * @param scene The scene the clip plane information are extracted from
  74100. * @param effect The effect we are binding the data to
  74101. */
  74102. static BindClipPlane(effect: Effect, scene: Scene): void;
  74103. }
  74104. }
  74105. declare module BABYLON {
  74106. /** @hidden */
  74107. export var shadowMapPixelShader: {
  74108. name: string;
  74109. shader: string;
  74110. };
  74111. }
  74112. declare module BABYLON {
  74113. /** @hidden */
  74114. export var bonesDeclaration: {
  74115. name: string;
  74116. shader: string;
  74117. };
  74118. }
  74119. declare module BABYLON {
  74120. /** @hidden */
  74121. export var morphTargetsVertexGlobalDeclaration: {
  74122. name: string;
  74123. shader: string;
  74124. };
  74125. }
  74126. declare module BABYLON {
  74127. /** @hidden */
  74128. export var morphTargetsVertexDeclaration: {
  74129. name: string;
  74130. shader: string;
  74131. };
  74132. }
  74133. declare module BABYLON {
  74134. /** @hidden */
  74135. export var instancesDeclaration: {
  74136. name: string;
  74137. shader: string;
  74138. };
  74139. }
  74140. declare module BABYLON {
  74141. /** @hidden */
  74142. export var helperFunctions: {
  74143. name: string;
  74144. shader: string;
  74145. };
  74146. }
  74147. declare module BABYLON {
  74148. /** @hidden */
  74149. export var morphTargetsVertex: {
  74150. name: string;
  74151. shader: string;
  74152. };
  74153. }
  74154. declare module BABYLON {
  74155. /** @hidden */
  74156. export var instancesVertex: {
  74157. name: string;
  74158. shader: string;
  74159. };
  74160. }
  74161. declare module BABYLON {
  74162. /** @hidden */
  74163. export var bonesVertex: {
  74164. name: string;
  74165. shader: string;
  74166. };
  74167. }
  74168. declare module BABYLON {
  74169. /** @hidden */
  74170. export var shadowMapVertexShader: {
  74171. name: string;
  74172. shader: string;
  74173. };
  74174. }
  74175. declare module BABYLON {
  74176. /** @hidden */
  74177. export var depthBoxBlurPixelShader: {
  74178. name: string;
  74179. shader: string;
  74180. };
  74181. }
  74182. declare module BABYLON {
  74183. /**
  74184. * Defines the options associated with the creation of a custom shader for a shadow generator.
  74185. */
  74186. export interface ICustomShaderOptions {
  74187. /**
  74188. * Gets or sets the custom shader name to use
  74189. */
  74190. shaderName: string;
  74191. /**
  74192. * The list of attribute names used in the shader
  74193. */
  74194. attributes?: string[];
  74195. /**
  74196. * The list of unifrom names used in the shader
  74197. */
  74198. uniforms?: string[];
  74199. /**
  74200. * The list of sampler names used in the shader
  74201. */
  74202. samplers?: string[];
  74203. /**
  74204. * The list of defines used in the shader
  74205. */
  74206. defines?: string[];
  74207. }
  74208. /**
  74209. * Interface to implement to create a shadow generator compatible with BJS.
  74210. */
  74211. export interface IShadowGenerator {
  74212. /**
  74213. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74214. * @returns The render target texture if present otherwise, null
  74215. */
  74216. getShadowMap(): Nullable<RenderTargetTexture>;
  74217. /**
  74218. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74219. * @returns The render target texture if the shadow map is present otherwise, null
  74220. */
  74221. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74222. /**
  74223. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74224. * @param subMesh The submesh we want to render in the shadow map
  74225. * @param useInstances Defines wether will draw in the map using instances
  74226. * @returns true if ready otherwise, false
  74227. */
  74228. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74229. /**
  74230. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74231. * @param defines Defines of the material we want to update
  74232. * @param lightIndex Index of the light in the enabled light list of the material
  74233. */
  74234. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  74235. /**
  74236. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74237. * defined in the generator but impacting the effect).
  74238. * It implies the unifroms available on the materials are the standard BJS ones.
  74239. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74240. * @param effect The effect we are binfing the information for
  74241. */
  74242. bindShadowLight(lightIndex: string, effect: Effect): void;
  74243. /**
  74244. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74245. * (eq to shadow prjection matrix * light transform matrix)
  74246. * @returns The transform matrix used to create the shadow map
  74247. */
  74248. getTransformMatrix(): Matrix;
  74249. /**
  74250. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74251. * Cube and 2D textures for instance.
  74252. */
  74253. recreateShadowMap(): void;
  74254. /**
  74255. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74256. * @param onCompiled Callback triggered at the and of the effects compilation
  74257. * @param options Sets of optional options forcing the compilation with different modes
  74258. */
  74259. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74260. useInstances: boolean;
  74261. }>): void;
  74262. /**
  74263. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74264. * @param options Sets of optional options forcing the compilation with different modes
  74265. * @returns A promise that resolves when the compilation completes
  74266. */
  74267. forceCompilationAsync(options?: Partial<{
  74268. useInstances: boolean;
  74269. }>): Promise<void>;
  74270. /**
  74271. * Serializes the shadow generator setup to a json object.
  74272. * @returns The serialized JSON object
  74273. */
  74274. serialize(): any;
  74275. /**
  74276. * Disposes the Shadow map and related Textures and effects.
  74277. */
  74278. dispose(): void;
  74279. }
  74280. /**
  74281. * Default implementation IShadowGenerator.
  74282. * This is the main object responsible of generating shadows in the framework.
  74283. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  74284. */
  74285. export class ShadowGenerator implements IShadowGenerator {
  74286. /**
  74287. * Shadow generator mode None: no filtering applied.
  74288. */
  74289. static readonly FILTER_NONE: number;
  74290. /**
  74291. * Shadow generator mode ESM: Exponential Shadow Mapping.
  74292. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74293. */
  74294. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  74295. /**
  74296. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  74297. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  74298. */
  74299. static readonly FILTER_POISSONSAMPLING: number;
  74300. /**
  74301. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  74302. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74303. */
  74304. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  74305. /**
  74306. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  74307. * edge artifacts on steep falloff.
  74308. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74309. */
  74310. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  74311. /**
  74312. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  74313. * edge artifacts on steep falloff.
  74314. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74315. */
  74316. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  74317. /**
  74318. * Shadow generator mode PCF: Percentage Closer Filtering
  74319. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  74320. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  74321. */
  74322. static readonly FILTER_PCF: number;
  74323. /**
  74324. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  74325. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  74326. * Contact Hardening
  74327. */
  74328. static readonly FILTER_PCSS: number;
  74329. /**
  74330. * Reserved for PCF and PCSS
  74331. * Highest Quality.
  74332. *
  74333. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  74334. *
  74335. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  74336. */
  74337. static readonly QUALITY_HIGH: number;
  74338. /**
  74339. * Reserved for PCF and PCSS
  74340. * Good tradeoff for quality/perf cross devices
  74341. *
  74342. * Execute PCF on a 3*3 kernel.
  74343. *
  74344. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  74345. */
  74346. static readonly QUALITY_MEDIUM: number;
  74347. /**
  74348. * Reserved for PCF and PCSS
  74349. * The lowest quality but the fastest.
  74350. *
  74351. * Execute PCF on a 1*1 kernel.
  74352. *
  74353. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  74354. */
  74355. static readonly QUALITY_LOW: number;
  74356. /** Gets or sets the custom shader name to use */
  74357. customShaderOptions: ICustomShaderOptions;
  74358. /**
  74359. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  74360. */
  74361. onBeforeShadowMapRenderObservable: Observable<Effect>;
  74362. /**
  74363. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  74364. */
  74365. onAfterShadowMapRenderObservable: Observable<Effect>;
  74366. /**
  74367. * Observable triggered before a mesh is rendered in the shadow map.
  74368. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  74369. */
  74370. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  74371. /**
  74372. * Observable triggered after a mesh is rendered in the shadow map.
  74373. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  74374. */
  74375. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  74376. private _bias;
  74377. /**
  74378. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  74379. */
  74380. /**
  74381. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  74382. */
  74383. bias: number;
  74384. private _normalBias;
  74385. /**
  74386. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  74387. */
  74388. /**
  74389. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  74390. */
  74391. normalBias: number;
  74392. private _blurBoxOffset;
  74393. /**
  74394. * Gets the blur box offset: offset applied during the blur pass.
  74395. * Only useful if useKernelBlur = false
  74396. */
  74397. /**
  74398. * Sets the blur box offset: offset applied during the blur pass.
  74399. * Only useful if useKernelBlur = false
  74400. */
  74401. blurBoxOffset: number;
  74402. private _blurScale;
  74403. /**
  74404. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  74405. * 2 means half of the size.
  74406. */
  74407. /**
  74408. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  74409. * 2 means half of the size.
  74410. */
  74411. blurScale: number;
  74412. private _blurKernel;
  74413. /**
  74414. * Gets the blur kernel: kernel size of the blur pass.
  74415. * Only useful if useKernelBlur = true
  74416. */
  74417. /**
  74418. * Sets the blur kernel: kernel size of the blur pass.
  74419. * Only useful if useKernelBlur = true
  74420. */
  74421. blurKernel: number;
  74422. private _useKernelBlur;
  74423. /**
  74424. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  74425. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  74426. */
  74427. /**
  74428. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  74429. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  74430. */
  74431. useKernelBlur: boolean;
  74432. private _depthScale;
  74433. /**
  74434. * Gets the depth scale used in ESM mode.
  74435. */
  74436. /**
  74437. * Sets the depth scale used in ESM mode.
  74438. * This can override the scale stored on the light.
  74439. */
  74440. depthScale: number;
  74441. private _filter;
  74442. /**
  74443. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  74444. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74445. */
  74446. /**
  74447. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  74448. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74449. */
  74450. filter: number;
  74451. /**
  74452. * Gets if the current filter is set to Poisson Sampling.
  74453. */
  74454. /**
  74455. * Sets the current filter to Poisson Sampling.
  74456. */
  74457. usePoissonSampling: boolean;
  74458. /**
  74459. * Gets if the current filter is set to ESM.
  74460. */
  74461. /**
  74462. * Sets the current filter is to ESM.
  74463. */
  74464. useExponentialShadowMap: boolean;
  74465. /**
  74466. * Gets if the current filter is set to filtered ESM.
  74467. */
  74468. /**
  74469. * Gets if the current filter is set to filtered ESM.
  74470. */
  74471. useBlurExponentialShadowMap: boolean;
  74472. /**
  74473. * Gets if the current filter is set to "close ESM" (using the inverse of the
  74474. * exponential to prevent steep falloff artifacts).
  74475. */
  74476. /**
  74477. * Sets the current filter to "close ESM" (using the inverse of the
  74478. * exponential to prevent steep falloff artifacts).
  74479. */
  74480. useCloseExponentialShadowMap: boolean;
  74481. /**
  74482. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  74483. * exponential to prevent steep falloff artifacts).
  74484. */
  74485. /**
  74486. * Sets the current filter to filtered "close ESM" (using the inverse of the
  74487. * exponential to prevent steep falloff artifacts).
  74488. */
  74489. useBlurCloseExponentialShadowMap: boolean;
  74490. /**
  74491. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  74492. */
  74493. /**
  74494. * Sets the current filter to "PCF" (percentage closer filtering).
  74495. */
  74496. usePercentageCloserFiltering: boolean;
  74497. private _filteringQuality;
  74498. /**
  74499. * Gets the PCF or PCSS Quality.
  74500. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74501. */
  74502. /**
  74503. * Sets the PCF or PCSS Quality.
  74504. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74505. */
  74506. filteringQuality: number;
  74507. /**
  74508. * Gets if the current filter is set to "PCSS" (contact hardening).
  74509. */
  74510. /**
  74511. * Sets the current filter to "PCSS" (contact hardening).
  74512. */
  74513. useContactHardeningShadow: boolean;
  74514. private _contactHardeningLightSizeUVRatio;
  74515. /**
  74516. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74517. * Using a ratio helps keeping shape stability independently of the map size.
  74518. *
  74519. * It does not account for the light projection as it was having too much
  74520. * instability during the light setup or during light position changes.
  74521. *
  74522. * Only valid if useContactHardeningShadow is true.
  74523. */
  74524. /**
  74525. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74526. * Using a ratio helps keeping shape stability independently of the map size.
  74527. *
  74528. * It does not account for the light projection as it was having too much
  74529. * instability during the light setup or during light position changes.
  74530. *
  74531. * Only valid if useContactHardeningShadow is true.
  74532. */
  74533. contactHardeningLightSizeUVRatio: number;
  74534. private _darkness;
  74535. /** Gets or sets the actual darkness of a shadow */
  74536. darkness: number;
  74537. /**
  74538. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  74539. * 0 means strongest and 1 would means no shadow.
  74540. * @returns the darkness.
  74541. */
  74542. getDarkness(): number;
  74543. /**
  74544. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  74545. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  74546. * @returns the shadow generator allowing fluent coding.
  74547. */
  74548. setDarkness(darkness: number): ShadowGenerator;
  74549. private _transparencyShadow;
  74550. /** Gets or sets the ability to have transparent shadow */
  74551. transparencyShadow: boolean;
  74552. /**
  74553. * Sets the ability to have transparent shadow (boolean).
  74554. * @param transparent True if transparent else False
  74555. * @returns the shadow generator allowing fluent coding
  74556. */
  74557. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  74558. private _shadowMap;
  74559. private _shadowMap2;
  74560. /**
  74561. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74562. * @returns The render target texture if present otherwise, null
  74563. */
  74564. getShadowMap(): Nullable<RenderTargetTexture>;
  74565. /**
  74566. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74567. * @returns The render target texture if the shadow map is present otherwise, null
  74568. */
  74569. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74570. /**
  74571. * Gets the class name of that object
  74572. * @returns "ShadowGenerator"
  74573. */
  74574. getClassName(): string;
  74575. /**
  74576. * Helper function to add a mesh and its descendants to the list of shadow casters.
  74577. * @param mesh Mesh to add
  74578. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  74579. * @returns the Shadow Generator itself
  74580. */
  74581. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74582. /**
  74583. * Helper function to remove a mesh and its descendants from the list of shadow casters
  74584. * @param mesh Mesh to remove
  74585. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  74586. * @returns the Shadow Generator itself
  74587. */
  74588. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74589. /**
  74590. * Controls the extent to which the shadows fade out at the edge of the frustum
  74591. * Used only by directionals and spots
  74592. */
  74593. frustumEdgeFalloff: number;
  74594. private _light;
  74595. /**
  74596. * Returns the associated light object.
  74597. * @returns the light generating the shadow
  74598. */
  74599. getLight(): IShadowLight;
  74600. /**
  74601. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  74602. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  74603. * It might on the other hand introduce peter panning.
  74604. */
  74605. forceBackFacesOnly: boolean;
  74606. private _scene;
  74607. private _lightDirection;
  74608. private _effect;
  74609. private _viewMatrix;
  74610. private _projectionMatrix;
  74611. private _transformMatrix;
  74612. private _cachedPosition;
  74613. private _cachedDirection;
  74614. private _cachedDefines;
  74615. private _currentRenderID;
  74616. private _boxBlurPostprocess;
  74617. private _kernelBlurXPostprocess;
  74618. private _kernelBlurYPostprocess;
  74619. private _blurPostProcesses;
  74620. private _mapSize;
  74621. private _currentFaceIndex;
  74622. private _currentFaceIndexCache;
  74623. private _textureType;
  74624. private _defaultTextureMatrix;
  74625. /** @hidden */
  74626. static _SceneComponentInitialization: (scene: Scene) => void;
  74627. /**
  74628. * Creates a ShadowGenerator object.
  74629. * A ShadowGenerator is the required tool to use the shadows.
  74630. * Each light casting shadows needs to use its own ShadowGenerator.
  74631. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  74632. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  74633. * @param light The light object generating the shadows.
  74634. * @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.
  74635. */
  74636. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  74637. private _initializeGenerator;
  74638. private _initializeShadowMap;
  74639. private _initializeBlurRTTAndPostProcesses;
  74640. private _renderForShadowMap;
  74641. private _renderSubMeshForShadowMap;
  74642. private _applyFilterValues;
  74643. /**
  74644. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74645. * @param onCompiled Callback triggered at the and of the effects compilation
  74646. * @param options Sets of optional options forcing the compilation with different modes
  74647. */
  74648. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74649. useInstances: boolean;
  74650. }>): void;
  74651. /**
  74652. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74653. * @param options Sets of optional options forcing the compilation with different modes
  74654. * @returns A promise that resolves when the compilation completes
  74655. */
  74656. forceCompilationAsync(options?: Partial<{
  74657. useInstances: boolean;
  74658. }>): Promise<void>;
  74659. /**
  74660. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74661. * @param subMesh The submesh we want to render in the shadow map
  74662. * @param useInstances Defines wether will draw in the map using instances
  74663. * @returns true if ready otherwise, false
  74664. */
  74665. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74666. /**
  74667. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74668. * @param defines Defines of the material we want to update
  74669. * @param lightIndex Index of the light in the enabled light list of the material
  74670. */
  74671. prepareDefines(defines: any, lightIndex: number): void;
  74672. /**
  74673. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74674. * defined in the generator but impacting the effect).
  74675. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74676. * @param effect The effect we are binfing the information for
  74677. */
  74678. bindShadowLight(lightIndex: string, effect: Effect): void;
  74679. /**
  74680. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74681. * (eq to shadow prjection matrix * light transform matrix)
  74682. * @returns The transform matrix used to create the shadow map
  74683. */
  74684. getTransformMatrix(): Matrix;
  74685. /**
  74686. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74687. * Cube and 2D textures for instance.
  74688. */
  74689. recreateShadowMap(): void;
  74690. private _disposeBlurPostProcesses;
  74691. private _disposeRTTandPostProcesses;
  74692. /**
  74693. * Disposes the ShadowGenerator.
  74694. * Returns nothing.
  74695. */
  74696. dispose(): void;
  74697. /**
  74698. * Serializes the shadow generator setup to a json object.
  74699. * @returns The serialized JSON object
  74700. */
  74701. serialize(): any;
  74702. /**
  74703. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  74704. * @param parsedShadowGenerator The JSON object to parse
  74705. * @param scene The scene to create the shadow map for
  74706. * @returns The parsed shadow generator
  74707. */
  74708. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  74709. }
  74710. }
  74711. declare module BABYLON {
  74712. /**
  74713. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  74714. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  74715. * 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.
  74716. */
  74717. export abstract class Light extends Node {
  74718. /**
  74719. * Falloff Default: light is falling off following the material specification:
  74720. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  74721. */
  74722. static readonly FALLOFF_DEFAULT: number;
  74723. /**
  74724. * Falloff Physical: light is falling off following the inverse squared distance law.
  74725. */
  74726. static readonly FALLOFF_PHYSICAL: number;
  74727. /**
  74728. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  74729. * to enhance interoperability with other engines.
  74730. */
  74731. static readonly FALLOFF_GLTF: number;
  74732. /**
  74733. * Falloff Standard: light is falling off like in the standard material
  74734. * to enhance interoperability with other materials.
  74735. */
  74736. static readonly FALLOFF_STANDARD: number;
  74737. /**
  74738. * If every light affecting the material is in this lightmapMode,
  74739. * material.lightmapTexture adds or multiplies
  74740. * (depends on material.useLightmapAsShadowmap)
  74741. * after every other light calculations.
  74742. */
  74743. static readonly LIGHTMAP_DEFAULT: number;
  74744. /**
  74745. * material.lightmapTexture as only diffuse lighting from this light
  74746. * adds only specular lighting from this light
  74747. * adds dynamic shadows
  74748. */
  74749. static readonly LIGHTMAP_SPECULAR: number;
  74750. /**
  74751. * material.lightmapTexture as only lighting
  74752. * no light calculation from this light
  74753. * only adds dynamic shadows from this light
  74754. */
  74755. static readonly LIGHTMAP_SHADOWSONLY: number;
  74756. /**
  74757. * Each light type uses the default quantity according to its type:
  74758. * point/spot lights use luminous intensity
  74759. * directional lights use illuminance
  74760. */
  74761. static readonly INTENSITYMODE_AUTOMATIC: number;
  74762. /**
  74763. * lumen (lm)
  74764. */
  74765. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  74766. /**
  74767. * candela (lm/sr)
  74768. */
  74769. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  74770. /**
  74771. * lux (lm/m^2)
  74772. */
  74773. static readonly INTENSITYMODE_ILLUMINANCE: number;
  74774. /**
  74775. * nit (cd/m^2)
  74776. */
  74777. static readonly INTENSITYMODE_LUMINANCE: number;
  74778. /**
  74779. * Light type const id of the point light.
  74780. */
  74781. static readonly LIGHTTYPEID_POINTLIGHT: number;
  74782. /**
  74783. * Light type const id of the directional light.
  74784. */
  74785. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  74786. /**
  74787. * Light type const id of the spot light.
  74788. */
  74789. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  74790. /**
  74791. * Light type const id of the hemispheric light.
  74792. */
  74793. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  74794. /**
  74795. * Diffuse gives the basic color to an object.
  74796. */
  74797. diffuse: Color3;
  74798. /**
  74799. * Specular produces a highlight color on an object.
  74800. * Note: This is note affecting PBR materials.
  74801. */
  74802. specular: Color3;
  74803. /**
  74804. * Defines the falloff type for this light. This lets overrriding how punctual light are
  74805. * falling off base on range or angle.
  74806. * This can be set to any values in Light.FALLOFF_x.
  74807. *
  74808. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  74809. * other types of materials.
  74810. */
  74811. falloffType: number;
  74812. /**
  74813. * Strength of the light.
  74814. * Note: By default it is define in the framework own unit.
  74815. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  74816. */
  74817. intensity: number;
  74818. private _range;
  74819. protected _inverseSquaredRange: number;
  74820. /**
  74821. * Defines how far from the source the light is impacting in scene units.
  74822. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74823. */
  74824. /**
  74825. * Defines how far from the source the light is impacting in scene units.
  74826. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74827. */
  74828. range: number;
  74829. /**
  74830. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  74831. * of light.
  74832. */
  74833. private _photometricScale;
  74834. private _intensityMode;
  74835. /**
  74836. * Gets the photometric scale used to interpret the intensity.
  74837. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74838. */
  74839. /**
  74840. * Sets the photometric scale used to interpret the intensity.
  74841. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74842. */
  74843. intensityMode: number;
  74844. private _radius;
  74845. /**
  74846. * Gets the light radius used by PBR Materials to simulate soft area lights.
  74847. */
  74848. /**
  74849. * sets the light radius used by PBR Materials to simulate soft area lights.
  74850. */
  74851. radius: number;
  74852. private _renderPriority;
  74853. /**
  74854. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  74855. * exceeding the number allowed of the materials.
  74856. */
  74857. renderPriority: number;
  74858. private _shadowEnabled;
  74859. /**
  74860. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74861. * the current shadow generator.
  74862. */
  74863. /**
  74864. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74865. * the current shadow generator.
  74866. */
  74867. shadowEnabled: boolean;
  74868. private _includedOnlyMeshes;
  74869. /**
  74870. * Gets the only meshes impacted by this light.
  74871. */
  74872. /**
  74873. * Sets the only meshes impacted by this light.
  74874. */
  74875. includedOnlyMeshes: AbstractMesh[];
  74876. private _excludedMeshes;
  74877. /**
  74878. * Gets the meshes not impacted by this light.
  74879. */
  74880. /**
  74881. * Sets the meshes not impacted by this light.
  74882. */
  74883. excludedMeshes: AbstractMesh[];
  74884. private _excludeWithLayerMask;
  74885. /**
  74886. * Gets the layer id use to find what meshes are not impacted by the light.
  74887. * Inactive if 0
  74888. */
  74889. /**
  74890. * Sets the layer id use to find what meshes are not impacted by the light.
  74891. * Inactive if 0
  74892. */
  74893. excludeWithLayerMask: number;
  74894. private _includeOnlyWithLayerMask;
  74895. /**
  74896. * Gets the layer id use to find what meshes are impacted by the light.
  74897. * Inactive if 0
  74898. */
  74899. /**
  74900. * Sets the layer id use to find what meshes are impacted by the light.
  74901. * Inactive if 0
  74902. */
  74903. includeOnlyWithLayerMask: number;
  74904. private _lightmapMode;
  74905. /**
  74906. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74907. */
  74908. /**
  74909. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74910. */
  74911. lightmapMode: number;
  74912. /**
  74913. * Shadow generator associted to the light.
  74914. * @hidden Internal use only.
  74915. */
  74916. _shadowGenerator: Nullable<IShadowGenerator>;
  74917. /**
  74918. * @hidden Internal use only.
  74919. */
  74920. _excludedMeshesIds: string[];
  74921. /**
  74922. * @hidden Internal use only.
  74923. */
  74924. _includedOnlyMeshesIds: string[];
  74925. /**
  74926. * The current light unifom buffer.
  74927. * @hidden Internal use only.
  74928. */
  74929. _uniformBuffer: UniformBuffer;
  74930. /**
  74931. * Creates a Light object in the scene.
  74932. * Documentation : https://doc.babylonjs.com/babylon101/lights
  74933. * @param name The firendly name of the light
  74934. * @param scene The scene the light belongs too
  74935. */
  74936. constructor(name: string, scene: Scene);
  74937. protected abstract _buildUniformLayout(): void;
  74938. /**
  74939. * Sets the passed Effect "effect" with the Light information.
  74940. * @param effect The effect to update
  74941. * @param lightIndex The index of the light in the effect to update
  74942. * @returns The light
  74943. */
  74944. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  74945. /**
  74946. * Returns the string "Light".
  74947. * @returns the class name
  74948. */
  74949. getClassName(): string;
  74950. /** @hidden */
  74951. readonly _isLight: boolean;
  74952. /**
  74953. * Converts the light information to a readable string for debug purpose.
  74954. * @param fullDetails Supports for multiple levels of logging within scene loading
  74955. * @returns the human readable light info
  74956. */
  74957. toString(fullDetails?: boolean): string;
  74958. /** @hidden */
  74959. protected _syncParentEnabledState(): void;
  74960. /**
  74961. * Set the enabled state of this node.
  74962. * @param value - the new enabled state
  74963. */
  74964. setEnabled(value: boolean): void;
  74965. /**
  74966. * Returns the Light associated shadow generator if any.
  74967. * @return the associated shadow generator.
  74968. */
  74969. getShadowGenerator(): Nullable<IShadowGenerator>;
  74970. /**
  74971. * Returns a Vector3, the absolute light position in the World.
  74972. * @returns the world space position of the light
  74973. */
  74974. getAbsolutePosition(): Vector3;
  74975. /**
  74976. * Specifies if the light will affect the passed mesh.
  74977. * @param mesh The mesh to test against the light
  74978. * @return true the mesh is affected otherwise, false.
  74979. */
  74980. canAffectMesh(mesh: AbstractMesh): boolean;
  74981. /**
  74982. * Sort function to order lights for rendering.
  74983. * @param a First Light object to compare to second.
  74984. * @param b Second Light object to compare first.
  74985. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  74986. */
  74987. static CompareLightsPriority(a: Light, b: Light): number;
  74988. /**
  74989. * Releases resources associated with this node.
  74990. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  74991. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  74992. */
  74993. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74994. /**
  74995. * Returns the light type ID (integer).
  74996. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  74997. */
  74998. getTypeID(): number;
  74999. /**
  75000. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  75001. * @returns the scaled intensity in intensity mode unit
  75002. */
  75003. getScaledIntensity(): number;
  75004. /**
  75005. * Returns a new Light object, named "name", from the current one.
  75006. * @param name The name of the cloned light
  75007. * @returns the new created light
  75008. */
  75009. clone(name: string): Nullable<Light>;
  75010. /**
  75011. * Serializes the current light into a Serialization object.
  75012. * @returns the serialized object.
  75013. */
  75014. serialize(): any;
  75015. /**
  75016. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  75017. * This new light is named "name" and added to the passed scene.
  75018. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  75019. * @param name The friendly name of the light
  75020. * @param scene The scene the new light will belong to
  75021. * @returns the constructor function
  75022. */
  75023. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  75024. /**
  75025. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  75026. * @param parsedLight The JSON representation of the light
  75027. * @param scene The scene to create the parsed light in
  75028. * @returns the created light after parsing
  75029. */
  75030. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  75031. private _hookArrayForExcluded;
  75032. private _hookArrayForIncludedOnly;
  75033. private _resyncMeshes;
  75034. /**
  75035. * Forces the meshes to update their light related information in their rendering used effects
  75036. * @hidden Internal Use Only
  75037. */
  75038. _markMeshesAsLightDirty(): void;
  75039. /**
  75040. * Recomputes the cached photometric scale if needed.
  75041. */
  75042. private _computePhotometricScale;
  75043. /**
  75044. * Returns the Photometric Scale according to the light type and intensity mode.
  75045. */
  75046. private _getPhotometricScale;
  75047. /**
  75048. * Reorder the light in the scene according to their defined priority.
  75049. * @hidden Internal Use Only
  75050. */
  75051. _reorderLightsInScene(): void;
  75052. /**
  75053. * Prepares the list of defines specific to the light type.
  75054. * @param defines the list of defines
  75055. * @param lightIndex defines the index of the light for the effect
  75056. */
  75057. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  75058. }
  75059. }
  75060. declare module BABYLON {
  75061. /**
  75062. * Creates an instance based on a source mesh.
  75063. */
  75064. export class InstancedMesh extends AbstractMesh {
  75065. private _sourceMesh;
  75066. private _currentLOD;
  75067. /** @hidden */
  75068. _indexInSourceMeshInstanceArray: number;
  75069. constructor(name: string, source: Mesh);
  75070. /**
  75071. * Returns the string "InstancedMesh".
  75072. */
  75073. getClassName(): string;
  75074. /** Gets the list of lights affecting that mesh */
  75075. readonly lightSources: Light[];
  75076. _resyncLightSources(): void;
  75077. _resyncLighSource(light: Light): void;
  75078. _removeLightSource(light: Light): void;
  75079. /**
  75080. * If the source mesh receives shadows
  75081. */
  75082. readonly receiveShadows: boolean;
  75083. /**
  75084. * The material of the source mesh
  75085. */
  75086. readonly material: Nullable<Material>;
  75087. /**
  75088. * Visibility of the source mesh
  75089. */
  75090. readonly visibility: number;
  75091. /**
  75092. * Skeleton of the source mesh
  75093. */
  75094. readonly skeleton: Nullable<Skeleton>;
  75095. /**
  75096. * Rendering ground id of the source mesh
  75097. */
  75098. renderingGroupId: number;
  75099. /**
  75100. * Returns the total number of vertices (integer).
  75101. */
  75102. getTotalVertices(): number;
  75103. /**
  75104. * Returns a positive integer : the total number of indices in this mesh geometry.
  75105. * @returns the numner of indices or zero if the mesh has no geometry.
  75106. */
  75107. getTotalIndices(): number;
  75108. /**
  75109. * The source mesh of the instance
  75110. */
  75111. readonly sourceMesh: Mesh;
  75112. /**
  75113. * Is this node ready to be used/rendered
  75114. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  75115. * @return {boolean} is it ready
  75116. */
  75117. isReady(completeCheck?: boolean): boolean;
  75118. /**
  75119. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  75120. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  75121. * @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.
  75122. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  75123. */
  75124. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  75125. /**
  75126. * Sets the vertex data of the mesh geometry for the requested `kind`.
  75127. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  75128. * The `data` are either a numeric array either a Float32Array.
  75129. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  75130. * 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).
  75131. * Note that a new underlying VertexBuffer object is created each call.
  75132. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  75133. *
  75134. * Possible `kind` values :
  75135. * - VertexBuffer.PositionKind
  75136. * - VertexBuffer.UVKind
  75137. * - VertexBuffer.UV2Kind
  75138. * - VertexBuffer.UV3Kind
  75139. * - VertexBuffer.UV4Kind
  75140. * - VertexBuffer.UV5Kind
  75141. * - VertexBuffer.UV6Kind
  75142. * - VertexBuffer.ColorKind
  75143. * - VertexBuffer.MatricesIndicesKind
  75144. * - VertexBuffer.MatricesIndicesExtraKind
  75145. * - VertexBuffer.MatricesWeightsKind
  75146. * - VertexBuffer.MatricesWeightsExtraKind
  75147. *
  75148. * Returns the Mesh.
  75149. */
  75150. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  75151. /**
  75152. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  75153. * If the mesh has no geometry, it is simply returned as it is.
  75154. * The `data` are either a numeric array either a Float32Array.
  75155. * No new underlying VertexBuffer object is created.
  75156. * 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.
  75157. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  75158. *
  75159. * Possible `kind` values :
  75160. * - VertexBuffer.PositionKind
  75161. * - VertexBuffer.UVKind
  75162. * - VertexBuffer.UV2Kind
  75163. * - VertexBuffer.UV3Kind
  75164. * - VertexBuffer.UV4Kind
  75165. * - VertexBuffer.UV5Kind
  75166. * - VertexBuffer.UV6Kind
  75167. * - VertexBuffer.ColorKind
  75168. * - VertexBuffer.MatricesIndicesKind
  75169. * - VertexBuffer.MatricesIndicesExtraKind
  75170. * - VertexBuffer.MatricesWeightsKind
  75171. * - VertexBuffer.MatricesWeightsExtraKind
  75172. *
  75173. * Returns the Mesh.
  75174. */
  75175. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  75176. /**
  75177. * Sets the mesh indices.
  75178. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  75179. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  75180. * This method creates a new index buffer each call.
  75181. * Returns the Mesh.
  75182. */
  75183. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  75184. /**
  75185. * Boolean : True if the mesh owns the requested kind of data.
  75186. */
  75187. isVerticesDataPresent(kind: string): boolean;
  75188. /**
  75189. * Returns an array of indices (IndicesArray).
  75190. */
  75191. getIndices(): Nullable<IndicesArray>;
  75192. readonly _positions: Nullable<Vector3[]>;
  75193. /**
  75194. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  75195. * This means the mesh underlying bounding box and sphere are recomputed.
  75196. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  75197. * @returns the current mesh
  75198. */
  75199. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  75200. /** @hidden */
  75201. _preActivate(): InstancedMesh;
  75202. /** @hidden */
  75203. _activate(renderId: number, intermediateRendering: boolean): boolean;
  75204. /** @hidden */
  75205. _postActivate(): void;
  75206. getWorldMatrix(): Matrix;
  75207. readonly isAnInstance: boolean;
  75208. /**
  75209. * Returns the current associated LOD AbstractMesh.
  75210. */
  75211. getLOD(camera: Camera): AbstractMesh;
  75212. /** @hidden */
  75213. _syncSubMeshes(): InstancedMesh;
  75214. /** @hidden */
  75215. _generatePointsArray(): boolean;
  75216. /**
  75217. * Creates a new InstancedMesh from the current mesh.
  75218. * - name (string) : the cloned mesh name
  75219. * - newParent (optional Node) : the optional Node to parent the clone to.
  75220. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  75221. *
  75222. * Returns the clone.
  75223. */
  75224. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  75225. /**
  75226. * Disposes the InstancedMesh.
  75227. * Returns nothing.
  75228. */
  75229. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  75230. }
  75231. }
  75232. declare module BABYLON {
  75233. /**
  75234. * Defines the options associated with the creation of a shader material.
  75235. */
  75236. export interface IShaderMaterialOptions {
  75237. /**
  75238. * Does the material work in alpha blend mode
  75239. */
  75240. needAlphaBlending: boolean;
  75241. /**
  75242. * Does the material work in alpha test mode
  75243. */
  75244. needAlphaTesting: boolean;
  75245. /**
  75246. * The list of attribute names used in the shader
  75247. */
  75248. attributes: string[];
  75249. /**
  75250. * The list of unifrom names used in the shader
  75251. */
  75252. uniforms: string[];
  75253. /**
  75254. * The list of UBO names used in the shader
  75255. */
  75256. uniformBuffers: string[];
  75257. /**
  75258. * The list of sampler names used in the shader
  75259. */
  75260. samplers: string[];
  75261. /**
  75262. * The list of defines used in the shader
  75263. */
  75264. defines: string[];
  75265. }
  75266. /**
  75267. * 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.
  75268. *
  75269. * This returned material effects how the mesh will look based on the code in the shaders.
  75270. *
  75271. * @see http://doc.babylonjs.com/how_to/shader_material
  75272. */
  75273. export class ShaderMaterial extends Material {
  75274. private _shaderPath;
  75275. private _options;
  75276. private _textures;
  75277. private _textureArrays;
  75278. private _floats;
  75279. private _ints;
  75280. private _floatsArrays;
  75281. private _colors3;
  75282. private _colors3Arrays;
  75283. private _colors4;
  75284. private _colors4Arrays;
  75285. private _vectors2;
  75286. private _vectors3;
  75287. private _vectors4;
  75288. private _matrices;
  75289. private _matrices3x3;
  75290. private _matrices2x2;
  75291. private _vectors2Arrays;
  75292. private _vectors3Arrays;
  75293. private _vectors4Arrays;
  75294. private _cachedWorldViewMatrix;
  75295. private _cachedWorldViewProjectionMatrix;
  75296. private _renderId;
  75297. /**
  75298. * Instantiate a new shader material.
  75299. * 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.
  75300. * This returned material effects how the mesh will look based on the code in the shaders.
  75301. * @see http://doc.babylonjs.com/how_to/shader_material
  75302. * @param name Define the name of the material in the scene
  75303. * @param scene Define the scene the material belongs to
  75304. * @param shaderPath Defines the route to the shader code in one of three ways:
  75305. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  75306. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  75307. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  75308. * @param options Define the options used to create the shader
  75309. */
  75310. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  75311. /**
  75312. * Gets the options used to compile the shader.
  75313. * They can be modified to trigger a new compilation
  75314. */
  75315. readonly options: IShaderMaterialOptions;
  75316. /**
  75317. * Gets the current class name of the material e.g. "ShaderMaterial"
  75318. * Mainly use in serialization.
  75319. * @returns the class name
  75320. */
  75321. getClassName(): string;
  75322. /**
  75323. * Specifies if the material will require alpha blending
  75324. * @returns a boolean specifying if alpha blending is needed
  75325. */
  75326. needAlphaBlending(): boolean;
  75327. /**
  75328. * Specifies if this material should be rendered in alpha test mode
  75329. * @returns a boolean specifying if an alpha test is needed.
  75330. */
  75331. needAlphaTesting(): boolean;
  75332. private _checkUniform;
  75333. /**
  75334. * Set a texture in the shader.
  75335. * @param name Define the name of the uniform samplers as defined in the shader
  75336. * @param texture Define the texture to bind to this sampler
  75337. * @return the material itself allowing "fluent" like uniform updates
  75338. */
  75339. setTexture(name: string, texture: Texture): ShaderMaterial;
  75340. /**
  75341. * Set a texture array in the shader.
  75342. * @param name Define the name of the uniform sampler array as defined in the shader
  75343. * @param textures Define the list of textures to bind to this sampler
  75344. * @return the material itself allowing "fluent" like uniform updates
  75345. */
  75346. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  75347. /**
  75348. * Set a float in the shader.
  75349. * @param name Define the name of the uniform as defined in the shader
  75350. * @param value Define the value to give to the uniform
  75351. * @return the material itself allowing "fluent" like uniform updates
  75352. */
  75353. setFloat(name: string, value: number): ShaderMaterial;
  75354. /**
  75355. * Set a int in the shader.
  75356. * @param name Define the name of the uniform as defined in the shader
  75357. * @param value Define the value to give to the uniform
  75358. * @return the material itself allowing "fluent" like uniform updates
  75359. */
  75360. setInt(name: string, value: number): ShaderMaterial;
  75361. /**
  75362. * Set an array of floats in the shader.
  75363. * @param name Define the name of the uniform as defined in the shader
  75364. * @param value Define the value to give to the uniform
  75365. * @return the material itself allowing "fluent" like uniform updates
  75366. */
  75367. setFloats(name: string, value: number[]): ShaderMaterial;
  75368. /**
  75369. * Set a vec3 in the shader from a Color3.
  75370. * @param name Define the name of the uniform as defined in the shader
  75371. * @param value Define the value to give to the uniform
  75372. * @return the material itself allowing "fluent" like uniform updates
  75373. */
  75374. setColor3(name: string, value: Color3): ShaderMaterial;
  75375. /**
  75376. * Set a vec3 array in the shader from a Color3 array.
  75377. * @param name Define the name of the uniform as defined in the shader
  75378. * @param value Define the value to give to the uniform
  75379. * @return the material itself allowing "fluent" like uniform updates
  75380. */
  75381. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  75382. /**
  75383. * Set a vec4 in the shader from a Color4.
  75384. * @param name Define the name of the uniform as defined in the shader
  75385. * @param value Define the value to give to the uniform
  75386. * @return the material itself allowing "fluent" like uniform updates
  75387. */
  75388. setColor4(name: string, value: Color4): ShaderMaterial;
  75389. /**
  75390. * Set a vec4 array in the shader from a Color4 array.
  75391. * @param name Define the name of the uniform as defined in the shader
  75392. * @param value Define the value to give to the uniform
  75393. * @return the material itself allowing "fluent" like uniform updates
  75394. */
  75395. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  75396. /**
  75397. * Set a vec2 in the shader from a Vector2.
  75398. * @param name Define the name of the uniform as defined in the shader
  75399. * @param value Define the value to give to the uniform
  75400. * @return the material itself allowing "fluent" like uniform updates
  75401. */
  75402. setVector2(name: string, value: Vector2): ShaderMaterial;
  75403. /**
  75404. * Set a vec3 in the shader from a Vector3.
  75405. * @param name Define the name of the uniform as defined in the shader
  75406. * @param value Define the value to give to the uniform
  75407. * @return the material itself allowing "fluent" like uniform updates
  75408. */
  75409. setVector3(name: string, value: Vector3): ShaderMaterial;
  75410. /**
  75411. * Set a vec4 in the shader from a Vector4.
  75412. * @param name Define the name of the uniform as defined in the shader
  75413. * @param value Define the value to give to the uniform
  75414. * @return the material itself allowing "fluent" like uniform updates
  75415. */
  75416. setVector4(name: string, value: Vector4): ShaderMaterial;
  75417. /**
  75418. * Set a mat4 in the shader from a Matrix.
  75419. * @param name Define the name of the uniform as defined in the shader
  75420. * @param value Define the value to give to the uniform
  75421. * @return the material itself allowing "fluent" like uniform updates
  75422. */
  75423. setMatrix(name: string, value: Matrix): ShaderMaterial;
  75424. /**
  75425. * Set a mat3 in the shader from a Float32Array.
  75426. * @param name Define the name of the uniform as defined in the shader
  75427. * @param value Define the value to give to the uniform
  75428. * @return the material itself allowing "fluent" like uniform updates
  75429. */
  75430. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  75431. /**
  75432. * Set a mat2 in the shader from a Float32Array.
  75433. * @param name Define the name of the uniform as defined in the shader
  75434. * @param value Define the value to give to the uniform
  75435. * @return the material itself allowing "fluent" like uniform updates
  75436. */
  75437. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  75438. /**
  75439. * Set a vec2 array in the shader from a number array.
  75440. * @param name Define the name of the uniform as defined in the shader
  75441. * @param value Define the value to give to the uniform
  75442. * @return the material itself allowing "fluent" like uniform updates
  75443. */
  75444. setArray2(name: string, value: number[]): ShaderMaterial;
  75445. /**
  75446. * Set a vec3 array in the shader from a number array.
  75447. * @param name Define the name of the uniform as defined in the shader
  75448. * @param value Define the value to give to the uniform
  75449. * @return the material itself allowing "fluent" like uniform updates
  75450. */
  75451. setArray3(name: string, value: number[]): ShaderMaterial;
  75452. /**
  75453. * Set a vec4 array in the shader from a number array.
  75454. * @param name Define the name of the uniform as defined in the shader
  75455. * @param value Define the value to give to the uniform
  75456. * @return the material itself allowing "fluent" like uniform updates
  75457. */
  75458. setArray4(name: string, value: number[]): ShaderMaterial;
  75459. private _checkCache;
  75460. /**
  75461. * Specifies that the submesh is ready to be used
  75462. * @param mesh defines the mesh to check
  75463. * @param subMesh defines which submesh to check
  75464. * @param useInstances specifies that instances should be used
  75465. * @returns a boolean indicating that the submesh is ready or not
  75466. */
  75467. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  75468. /**
  75469. * Checks if the material is ready to render the requested mesh
  75470. * @param mesh Define the mesh to render
  75471. * @param useInstances Define whether or not the material is used with instances
  75472. * @returns true if ready, otherwise false
  75473. */
  75474. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  75475. /**
  75476. * Binds the world matrix to the material
  75477. * @param world defines the world transformation matrix
  75478. */
  75479. bindOnlyWorldMatrix(world: Matrix): void;
  75480. /**
  75481. * Binds the material to the mesh
  75482. * @param world defines the world transformation matrix
  75483. * @param mesh defines the mesh to bind the material to
  75484. */
  75485. bind(world: Matrix, mesh?: Mesh): void;
  75486. /**
  75487. * Gets the active textures from the material
  75488. * @returns an array of textures
  75489. */
  75490. getActiveTextures(): BaseTexture[];
  75491. /**
  75492. * Specifies if the material uses a texture
  75493. * @param texture defines the texture to check against the material
  75494. * @returns a boolean specifying if the material uses the texture
  75495. */
  75496. hasTexture(texture: BaseTexture): boolean;
  75497. /**
  75498. * Makes a duplicate of the material, and gives it a new name
  75499. * @param name defines the new name for the duplicated material
  75500. * @returns the cloned material
  75501. */
  75502. clone(name: string): ShaderMaterial;
  75503. /**
  75504. * Disposes the material
  75505. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  75506. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  75507. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  75508. */
  75509. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  75510. /**
  75511. * Serializes this material in a JSON representation
  75512. * @returns the serialized material object
  75513. */
  75514. serialize(): any;
  75515. /**
  75516. * Creates a shader material from parsed shader material data
  75517. * @param source defines the JSON represnetation of the material
  75518. * @param scene defines the hosting scene
  75519. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  75520. * @returns a new material
  75521. */
  75522. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  75523. }
  75524. }
  75525. declare module BABYLON {
  75526. /** @hidden */
  75527. export var clipPlaneFragmentDeclaration: {
  75528. name: string;
  75529. shader: string;
  75530. };
  75531. }
  75532. declare module BABYLON {
  75533. /** @hidden */
  75534. export var clipPlaneFragment: {
  75535. name: string;
  75536. shader: string;
  75537. };
  75538. }
  75539. declare module BABYLON {
  75540. /** @hidden */
  75541. export var colorPixelShader: {
  75542. name: string;
  75543. shader: string;
  75544. };
  75545. }
  75546. declare module BABYLON {
  75547. /** @hidden */
  75548. export var clipPlaneVertexDeclaration: {
  75549. name: string;
  75550. shader: string;
  75551. };
  75552. }
  75553. declare module BABYLON {
  75554. /** @hidden */
  75555. export var clipPlaneVertex: {
  75556. name: string;
  75557. shader: string;
  75558. };
  75559. }
  75560. declare module BABYLON {
  75561. /** @hidden */
  75562. export var colorVertexShader: {
  75563. name: string;
  75564. shader: string;
  75565. };
  75566. }
  75567. declare module BABYLON {
  75568. /**
  75569. * Line mesh
  75570. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  75571. */
  75572. export class LinesMesh extends Mesh {
  75573. /**
  75574. * If vertex color should be applied to the mesh
  75575. */
  75576. readonly useVertexColor?: boolean | undefined;
  75577. /**
  75578. * If vertex alpha should be applied to the mesh
  75579. */
  75580. readonly useVertexAlpha?: boolean | undefined;
  75581. /**
  75582. * Color of the line (Default: White)
  75583. */
  75584. color: Color3;
  75585. /**
  75586. * Alpha of the line (Default: 1)
  75587. */
  75588. alpha: number;
  75589. /**
  75590. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75591. * This margin is expressed in world space coordinates, so its value may vary.
  75592. * Default value is 0.1
  75593. */
  75594. intersectionThreshold: number;
  75595. private _colorShader;
  75596. private color4;
  75597. /**
  75598. * Creates a new LinesMesh
  75599. * @param name defines the name
  75600. * @param scene defines the hosting scene
  75601. * @param parent defines the parent mesh if any
  75602. * @param source defines the optional source LinesMesh used to clone data from
  75603. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  75604. * When false, achieved by calling a clone(), also passing False.
  75605. * This will make creation of children, recursive.
  75606. * @param useVertexColor defines if this LinesMesh supports vertex color
  75607. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  75608. */
  75609. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  75610. /**
  75611. * If vertex color should be applied to the mesh
  75612. */
  75613. useVertexColor?: boolean | undefined,
  75614. /**
  75615. * If vertex alpha should be applied to the mesh
  75616. */
  75617. useVertexAlpha?: boolean | undefined);
  75618. private _addClipPlaneDefine;
  75619. private _removeClipPlaneDefine;
  75620. isReady(): boolean;
  75621. /**
  75622. * Returns the string "LineMesh"
  75623. */
  75624. getClassName(): string;
  75625. /**
  75626. * @hidden
  75627. */
  75628. /**
  75629. * @hidden
  75630. */
  75631. material: Material;
  75632. /**
  75633. * @hidden
  75634. */
  75635. readonly checkCollisions: boolean;
  75636. /** @hidden */
  75637. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  75638. /** @hidden */
  75639. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  75640. /**
  75641. * Disposes of the line mesh
  75642. * @param doNotRecurse If children should be disposed
  75643. */
  75644. dispose(doNotRecurse?: boolean): void;
  75645. /**
  75646. * Returns a new LineMesh object cloned from the current one.
  75647. */
  75648. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  75649. /**
  75650. * Creates a new InstancedLinesMesh object from the mesh model.
  75651. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  75652. * @param name defines the name of the new instance
  75653. * @returns a new InstancedLinesMesh
  75654. */
  75655. createInstance(name: string): InstancedLinesMesh;
  75656. }
  75657. /**
  75658. * Creates an instance based on a source LinesMesh
  75659. */
  75660. export class InstancedLinesMesh extends InstancedMesh {
  75661. /**
  75662. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75663. * This margin is expressed in world space coordinates, so its value may vary.
  75664. * Initilized with the intersectionThreshold value of the source LinesMesh
  75665. */
  75666. intersectionThreshold: number;
  75667. constructor(name: string, source: LinesMesh);
  75668. /**
  75669. * Returns the string "InstancedLinesMesh".
  75670. */
  75671. getClassName(): string;
  75672. }
  75673. }
  75674. declare module BABYLON {
  75675. /**
  75676. * Mesh representing the gorund
  75677. */
  75678. export class GroundMesh extends Mesh {
  75679. /** If octree should be generated */
  75680. generateOctree: boolean;
  75681. private _heightQuads;
  75682. /** @hidden */
  75683. _subdivisionsX: number;
  75684. /** @hidden */
  75685. _subdivisionsY: number;
  75686. /** @hidden */
  75687. _width: number;
  75688. /** @hidden */
  75689. _height: number;
  75690. /** @hidden */
  75691. _minX: number;
  75692. /** @hidden */
  75693. _maxX: number;
  75694. /** @hidden */
  75695. _minZ: number;
  75696. /** @hidden */
  75697. _maxZ: number;
  75698. constructor(name: string, scene: Scene);
  75699. /**
  75700. * "GroundMesh"
  75701. * @returns "GroundMesh"
  75702. */
  75703. getClassName(): string;
  75704. /**
  75705. * The minimum of x and y subdivisions
  75706. */
  75707. readonly subdivisions: number;
  75708. /**
  75709. * X subdivisions
  75710. */
  75711. readonly subdivisionsX: number;
  75712. /**
  75713. * Y subdivisions
  75714. */
  75715. readonly subdivisionsY: number;
  75716. /**
  75717. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  75718. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  75719. * @param chunksCount the number of subdivisions for x and y
  75720. * @param octreeBlocksSize (Default: 32)
  75721. */
  75722. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  75723. /**
  75724. * Returns a height (y) value in the Worl system :
  75725. * the ground altitude at the coordinates (x, z) expressed in the World system.
  75726. * @param x x coordinate
  75727. * @param z z coordinate
  75728. * @returns the ground y position if (x, z) are outside the ground surface.
  75729. */
  75730. getHeightAtCoordinates(x: number, z: number): number;
  75731. /**
  75732. * Returns a normalized vector (Vector3) orthogonal to the ground
  75733. * at the ground coordinates (x, z) expressed in the World system.
  75734. * @param x x coordinate
  75735. * @param z z coordinate
  75736. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  75737. */
  75738. getNormalAtCoordinates(x: number, z: number): Vector3;
  75739. /**
  75740. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  75741. * at the ground coordinates (x, z) expressed in the World system.
  75742. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  75743. * @param x x coordinate
  75744. * @param z z coordinate
  75745. * @param ref vector to store the result
  75746. * @returns the GroundMesh.
  75747. */
  75748. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  75749. /**
  75750. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  75751. * if the ground has been updated.
  75752. * This can be used in the render loop.
  75753. * @returns the GroundMesh.
  75754. */
  75755. updateCoordinateHeights(): GroundMesh;
  75756. private _getFacetAt;
  75757. private _initHeightQuads;
  75758. private _computeHeightQuads;
  75759. /**
  75760. * Serializes this ground mesh
  75761. * @param serializationObject object to write serialization to
  75762. */
  75763. serialize(serializationObject: any): void;
  75764. /**
  75765. * Parses a serialized ground mesh
  75766. * @param parsedMesh the serialized mesh
  75767. * @param scene the scene to create the ground mesh in
  75768. * @returns the created ground mesh
  75769. */
  75770. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  75771. }
  75772. }
  75773. declare module BABYLON {
  75774. /**
  75775. * Interface for Physics-Joint data
  75776. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75777. */
  75778. export interface PhysicsJointData {
  75779. /**
  75780. * The main pivot of the joint
  75781. */
  75782. mainPivot?: Vector3;
  75783. /**
  75784. * The connected pivot of the joint
  75785. */
  75786. connectedPivot?: Vector3;
  75787. /**
  75788. * The main axis of the joint
  75789. */
  75790. mainAxis?: Vector3;
  75791. /**
  75792. * The connected axis of the joint
  75793. */
  75794. connectedAxis?: Vector3;
  75795. /**
  75796. * The collision of the joint
  75797. */
  75798. collision?: boolean;
  75799. /**
  75800. * Native Oimo/Cannon/Energy data
  75801. */
  75802. nativeParams?: any;
  75803. }
  75804. /**
  75805. * This is a holder class for the physics joint created by the physics plugin
  75806. * It holds a set of functions to control the underlying joint
  75807. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75808. */
  75809. export class PhysicsJoint {
  75810. /**
  75811. * The type of the physics joint
  75812. */
  75813. type: number;
  75814. /**
  75815. * The data for the physics joint
  75816. */
  75817. jointData: PhysicsJointData;
  75818. private _physicsJoint;
  75819. protected _physicsPlugin: IPhysicsEnginePlugin;
  75820. /**
  75821. * Initializes the physics joint
  75822. * @param type The type of the physics joint
  75823. * @param jointData The data for the physics joint
  75824. */
  75825. constructor(
  75826. /**
  75827. * The type of the physics joint
  75828. */
  75829. type: number,
  75830. /**
  75831. * The data for the physics joint
  75832. */
  75833. jointData: PhysicsJointData);
  75834. /**
  75835. * Gets the physics joint
  75836. */
  75837. /**
  75838. * Sets the physics joint
  75839. */
  75840. physicsJoint: any;
  75841. /**
  75842. * Sets the physics plugin
  75843. */
  75844. physicsPlugin: IPhysicsEnginePlugin;
  75845. /**
  75846. * Execute a function that is physics-plugin specific.
  75847. * @param {Function} func the function that will be executed.
  75848. * It accepts two parameters: the physics world and the physics joint
  75849. */
  75850. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  75851. /**
  75852. * Distance-Joint type
  75853. */
  75854. static DistanceJoint: number;
  75855. /**
  75856. * Hinge-Joint type
  75857. */
  75858. static HingeJoint: number;
  75859. /**
  75860. * Ball-and-Socket joint type
  75861. */
  75862. static BallAndSocketJoint: number;
  75863. /**
  75864. * Wheel-Joint type
  75865. */
  75866. static WheelJoint: number;
  75867. /**
  75868. * Slider-Joint type
  75869. */
  75870. static SliderJoint: number;
  75871. /**
  75872. * Prismatic-Joint type
  75873. */
  75874. static PrismaticJoint: number;
  75875. /**
  75876. * Universal-Joint type
  75877. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  75878. */
  75879. static UniversalJoint: number;
  75880. /**
  75881. * Hinge-Joint 2 type
  75882. */
  75883. static Hinge2Joint: number;
  75884. /**
  75885. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  75886. */
  75887. static PointToPointJoint: number;
  75888. /**
  75889. * Spring-Joint type
  75890. */
  75891. static SpringJoint: number;
  75892. /**
  75893. * Lock-Joint type
  75894. */
  75895. static LockJoint: number;
  75896. }
  75897. /**
  75898. * A class representing a physics distance joint
  75899. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75900. */
  75901. export class DistanceJoint extends PhysicsJoint {
  75902. /**
  75903. *
  75904. * @param jointData The data for the Distance-Joint
  75905. */
  75906. constructor(jointData: DistanceJointData);
  75907. /**
  75908. * Update the predefined distance.
  75909. * @param maxDistance The maximum preferred distance
  75910. * @param minDistance The minimum preferred distance
  75911. */
  75912. updateDistance(maxDistance: number, minDistance?: number): void;
  75913. }
  75914. /**
  75915. * Represents a Motor-Enabled Joint
  75916. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75917. */
  75918. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  75919. /**
  75920. * Initializes the Motor-Enabled Joint
  75921. * @param type The type of the joint
  75922. * @param jointData The physica joint data for the joint
  75923. */
  75924. constructor(type: number, jointData: PhysicsJointData);
  75925. /**
  75926. * Set the motor values.
  75927. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75928. * @param force the force to apply
  75929. * @param maxForce max force for this motor.
  75930. */
  75931. setMotor(force?: number, maxForce?: number): void;
  75932. /**
  75933. * Set the motor's limits.
  75934. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75935. * @param upperLimit The upper limit of the motor
  75936. * @param lowerLimit The lower limit of the motor
  75937. */
  75938. setLimit(upperLimit: number, lowerLimit?: number): void;
  75939. }
  75940. /**
  75941. * This class represents a single physics Hinge-Joint
  75942. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75943. */
  75944. export class HingeJoint extends MotorEnabledJoint {
  75945. /**
  75946. * Initializes the Hinge-Joint
  75947. * @param jointData The joint data for the Hinge-Joint
  75948. */
  75949. constructor(jointData: PhysicsJointData);
  75950. /**
  75951. * Set the motor values.
  75952. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75953. * @param {number} force the force to apply
  75954. * @param {number} maxForce max force for this motor.
  75955. */
  75956. setMotor(force?: number, maxForce?: number): void;
  75957. /**
  75958. * Set the motor's limits.
  75959. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75960. * @param upperLimit The upper limit of the motor
  75961. * @param lowerLimit The lower limit of the motor
  75962. */
  75963. setLimit(upperLimit: number, lowerLimit?: number): void;
  75964. }
  75965. /**
  75966. * This class represents a dual hinge physics joint (same as wheel joint)
  75967. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75968. */
  75969. export class Hinge2Joint extends MotorEnabledJoint {
  75970. /**
  75971. * Initializes the Hinge2-Joint
  75972. * @param jointData The joint data for the Hinge2-Joint
  75973. */
  75974. constructor(jointData: PhysicsJointData);
  75975. /**
  75976. * Set the motor values.
  75977. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75978. * @param {number} targetSpeed the speed the motor is to reach
  75979. * @param {number} maxForce max force for this motor.
  75980. * @param {motorIndex} the motor's index, 0 or 1.
  75981. */
  75982. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  75983. /**
  75984. * Set the motor limits.
  75985. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75986. * @param {number} upperLimit the upper limit
  75987. * @param {number} lowerLimit lower limit
  75988. * @param {motorIndex} the motor's index, 0 or 1.
  75989. */
  75990. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75991. }
  75992. /**
  75993. * Interface for a motor enabled joint
  75994. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75995. */
  75996. export interface IMotorEnabledJoint {
  75997. /**
  75998. * Physics joint
  75999. */
  76000. physicsJoint: any;
  76001. /**
  76002. * Sets the motor of the motor-enabled joint
  76003. * @param force The force of the motor
  76004. * @param maxForce The maximum force of the motor
  76005. * @param motorIndex The index of the motor
  76006. */
  76007. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  76008. /**
  76009. * Sets the limit of the motor
  76010. * @param upperLimit The upper limit of the motor
  76011. * @param lowerLimit The lower limit of the motor
  76012. * @param motorIndex The index of the motor
  76013. */
  76014. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76015. }
  76016. /**
  76017. * Joint data for a Distance-Joint
  76018. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76019. */
  76020. export interface DistanceJointData extends PhysicsJointData {
  76021. /**
  76022. * Max distance the 2 joint objects can be apart
  76023. */
  76024. maxDistance: number;
  76025. }
  76026. /**
  76027. * Joint data from a spring joint
  76028. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76029. */
  76030. export interface SpringJointData extends PhysicsJointData {
  76031. /**
  76032. * Length of the spring
  76033. */
  76034. length: number;
  76035. /**
  76036. * Stiffness of the spring
  76037. */
  76038. stiffness: number;
  76039. /**
  76040. * Damping of the spring
  76041. */
  76042. damping: number;
  76043. /** this callback will be called when applying the force to the impostors. */
  76044. forceApplicationCallback: () => void;
  76045. }
  76046. }
  76047. declare module BABYLON {
  76048. /**
  76049. * Holds the data for the raycast result
  76050. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76051. */
  76052. export class PhysicsRaycastResult {
  76053. private _hasHit;
  76054. private _hitDistance;
  76055. private _hitNormalWorld;
  76056. private _hitPointWorld;
  76057. private _rayFromWorld;
  76058. private _rayToWorld;
  76059. /**
  76060. * Gets if there was a hit
  76061. */
  76062. readonly hasHit: boolean;
  76063. /**
  76064. * Gets the distance from the hit
  76065. */
  76066. readonly hitDistance: number;
  76067. /**
  76068. * Gets the hit normal/direction in the world
  76069. */
  76070. readonly hitNormalWorld: Vector3;
  76071. /**
  76072. * Gets the hit point in the world
  76073. */
  76074. readonly hitPointWorld: Vector3;
  76075. /**
  76076. * Gets the ray "start point" of the ray in the world
  76077. */
  76078. readonly rayFromWorld: Vector3;
  76079. /**
  76080. * Gets the ray "end point" of the ray in the world
  76081. */
  76082. readonly rayToWorld: Vector3;
  76083. /**
  76084. * Sets the hit data (normal & point in world space)
  76085. * @param hitNormalWorld defines the normal in world space
  76086. * @param hitPointWorld defines the point in world space
  76087. */
  76088. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  76089. /**
  76090. * Sets the distance from the start point to the hit point
  76091. * @param distance
  76092. */
  76093. setHitDistance(distance: number): void;
  76094. /**
  76095. * Calculates the distance manually
  76096. */
  76097. calculateHitDistance(): void;
  76098. /**
  76099. * Resets all the values to default
  76100. * @param from The from point on world space
  76101. * @param to The to point on world space
  76102. */
  76103. reset(from?: Vector3, to?: Vector3): void;
  76104. }
  76105. /**
  76106. * Interface for the size containing width and height
  76107. */
  76108. interface IXYZ {
  76109. /**
  76110. * X
  76111. */
  76112. x: number;
  76113. /**
  76114. * Y
  76115. */
  76116. y: number;
  76117. /**
  76118. * Z
  76119. */
  76120. z: number;
  76121. }
  76122. }
  76123. declare module BABYLON {
  76124. /**
  76125. * Interface used to describe a physics joint
  76126. */
  76127. export interface PhysicsImpostorJoint {
  76128. /** Defines the main impostor to which the joint is linked */
  76129. mainImpostor: PhysicsImpostor;
  76130. /** Defines the impostor that is connected to the main impostor using this joint */
  76131. connectedImpostor: PhysicsImpostor;
  76132. /** Defines the joint itself */
  76133. joint: PhysicsJoint;
  76134. }
  76135. /** @hidden */
  76136. export interface IPhysicsEnginePlugin {
  76137. world: any;
  76138. name: string;
  76139. setGravity(gravity: Vector3): void;
  76140. setTimeStep(timeStep: number): void;
  76141. getTimeStep(): number;
  76142. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  76143. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76144. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76145. generatePhysicsBody(impostor: PhysicsImpostor): void;
  76146. removePhysicsBody(impostor: PhysicsImpostor): void;
  76147. generateJoint(joint: PhysicsImpostorJoint): void;
  76148. removeJoint(joint: PhysicsImpostorJoint): void;
  76149. isSupported(): boolean;
  76150. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  76151. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  76152. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76153. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76154. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76155. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76156. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  76157. getBodyMass(impostor: PhysicsImpostor): number;
  76158. getBodyFriction(impostor: PhysicsImpostor): number;
  76159. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  76160. getBodyRestitution(impostor: PhysicsImpostor): number;
  76161. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  76162. getBodyPressure?(impostor: PhysicsImpostor): number;
  76163. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  76164. getBodyStiffness?(impostor: PhysicsImpostor): number;
  76165. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  76166. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  76167. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  76168. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  76169. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  76170. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  76171. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  76172. sleepBody(impostor: PhysicsImpostor): void;
  76173. wakeUpBody(impostor: PhysicsImpostor): void;
  76174. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  76175. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  76176. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  76177. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76178. getRadius(impostor: PhysicsImpostor): number;
  76179. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  76180. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  76181. dispose(): void;
  76182. }
  76183. /**
  76184. * Interface used to define a physics engine
  76185. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  76186. */
  76187. export interface IPhysicsEngine {
  76188. /**
  76189. * Gets the gravity vector used by the simulation
  76190. */
  76191. gravity: Vector3;
  76192. /**
  76193. * Sets the gravity vector used by the simulation
  76194. * @param gravity defines the gravity vector to use
  76195. */
  76196. setGravity(gravity: Vector3): void;
  76197. /**
  76198. * Set the time step of the physics engine.
  76199. * Default is 1/60.
  76200. * To slow it down, enter 1/600 for example.
  76201. * To speed it up, 1/30
  76202. * @param newTimeStep the new timestep to apply to this world.
  76203. */
  76204. setTimeStep(newTimeStep: number): void;
  76205. /**
  76206. * Get the time step of the physics engine.
  76207. * @returns the current time step
  76208. */
  76209. getTimeStep(): number;
  76210. /**
  76211. * Release all resources
  76212. */
  76213. dispose(): void;
  76214. /**
  76215. * Gets the name of the current physics plugin
  76216. * @returns the name of the plugin
  76217. */
  76218. getPhysicsPluginName(): string;
  76219. /**
  76220. * Adding a new impostor for the impostor tracking.
  76221. * This will be done by the impostor itself.
  76222. * @param impostor the impostor to add
  76223. */
  76224. addImpostor(impostor: PhysicsImpostor): void;
  76225. /**
  76226. * Remove an impostor from the engine.
  76227. * This impostor and its mesh will not longer be updated by the physics engine.
  76228. * @param impostor the impostor to remove
  76229. */
  76230. removeImpostor(impostor: PhysicsImpostor): void;
  76231. /**
  76232. * Add a joint to the physics engine
  76233. * @param mainImpostor defines the main impostor to which the joint is added.
  76234. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  76235. * @param joint defines the joint that will connect both impostors.
  76236. */
  76237. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76238. /**
  76239. * Removes a joint from the simulation
  76240. * @param mainImpostor defines the impostor used with the joint
  76241. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  76242. * @param joint defines the joint to remove
  76243. */
  76244. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76245. /**
  76246. * Gets the current plugin used to run the simulation
  76247. * @returns current plugin
  76248. */
  76249. getPhysicsPlugin(): IPhysicsEnginePlugin;
  76250. /**
  76251. * Gets the list of physic impostors
  76252. * @returns an array of PhysicsImpostor
  76253. */
  76254. getImpostors(): Array<PhysicsImpostor>;
  76255. /**
  76256. * Gets the impostor for a physics enabled object
  76257. * @param object defines the object impersonated by the impostor
  76258. * @returns the PhysicsImpostor or null if not found
  76259. */
  76260. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  76261. /**
  76262. * Gets the impostor for a physics body object
  76263. * @param body defines physics body used by the impostor
  76264. * @returns the PhysicsImpostor or null if not found
  76265. */
  76266. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  76267. /**
  76268. * Does a raycast in the physics world
  76269. * @param from when should the ray start?
  76270. * @param to when should the ray end?
  76271. * @returns PhysicsRaycastResult
  76272. */
  76273. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  76274. /**
  76275. * Called by the scene. No need to call it.
  76276. * @param delta defines the timespam between frames
  76277. */
  76278. _step(delta: number): void;
  76279. }
  76280. }
  76281. declare module BABYLON {
  76282. /**
  76283. * The interface for the physics imposter parameters
  76284. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76285. */
  76286. export interface PhysicsImpostorParameters {
  76287. /**
  76288. * The mass of the physics imposter
  76289. */
  76290. mass: number;
  76291. /**
  76292. * The friction of the physics imposter
  76293. */
  76294. friction?: number;
  76295. /**
  76296. * The coefficient of restitution of the physics imposter
  76297. */
  76298. restitution?: number;
  76299. /**
  76300. * The native options of the physics imposter
  76301. */
  76302. nativeOptions?: any;
  76303. /**
  76304. * Specifies if the parent should be ignored
  76305. */
  76306. ignoreParent?: boolean;
  76307. /**
  76308. * Specifies if bi-directional transformations should be disabled
  76309. */
  76310. disableBidirectionalTransformation?: boolean;
  76311. /**
  76312. * The pressure inside the physics imposter, soft object only
  76313. */
  76314. pressure?: number;
  76315. /**
  76316. * The stiffness the physics imposter, soft object only
  76317. */
  76318. stiffness?: number;
  76319. /**
  76320. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  76321. */
  76322. velocityIterations?: number;
  76323. /**
  76324. * The number of iterations used in maintaining consistent vertex positions, soft object only
  76325. */
  76326. positionIterations?: number;
  76327. /**
  76328. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  76329. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  76330. * Add to fix multiple points
  76331. */
  76332. fixedPoints?: number;
  76333. /**
  76334. * The collision margin around a soft object
  76335. */
  76336. margin?: number;
  76337. /**
  76338. * The collision margin around a soft object
  76339. */
  76340. damping?: number;
  76341. /**
  76342. * The path for a rope based on an extrusion
  76343. */
  76344. path?: any;
  76345. /**
  76346. * The shape of an extrusion used for a rope based on an extrusion
  76347. */
  76348. shape?: any;
  76349. }
  76350. /**
  76351. * Interface for a physics-enabled object
  76352. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76353. */
  76354. export interface IPhysicsEnabledObject {
  76355. /**
  76356. * The position of the physics-enabled object
  76357. */
  76358. position: Vector3;
  76359. /**
  76360. * The rotation of the physics-enabled object
  76361. */
  76362. rotationQuaternion: Nullable<Quaternion>;
  76363. /**
  76364. * The scale of the physics-enabled object
  76365. */
  76366. scaling: Vector3;
  76367. /**
  76368. * The rotation of the physics-enabled object
  76369. */
  76370. rotation?: Vector3;
  76371. /**
  76372. * The parent of the physics-enabled object
  76373. */
  76374. parent?: any;
  76375. /**
  76376. * The bounding info of the physics-enabled object
  76377. * @returns The bounding info of the physics-enabled object
  76378. */
  76379. getBoundingInfo(): BoundingInfo;
  76380. /**
  76381. * Computes the world matrix
  76382. * @param force Specifies if the world matrix should be computed by force
  76383. * @returns A world matrix
  76384. */
  76385. computeWorldMatrix(force: boolean): Matrix;
  76386. /**
  76387. * Gets the world matrix
  76388. * @returns A world matrix
  76389. */
  76390. getWorldMatrix?(): Matrix;
  76391. /**
  76392. * Gets the child meshes
  76393. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  76394. * @returns An array of abstract meshes
  76395. */
  76396. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  76397. /**
  76398. * Gets the vertex data
  76399. * @param kind The type of vertex data
  76400. * @returns A nullable array of numbers, or a float32 array
  76401. */
  76402. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  76403. /**
  76404. * Gets the indices from the mesh
  76405. * @returns A nullable array of index arrays
  76406. */
  76407. getIndices?(): Nullable<IndicesArray>;
  76408. /**
  76409. * Gets the scene from the mesh
  76410. * @returns the indices array or null
  76411. */
  76412. getScene?(): Scene;
  76413. /**
  76414. * Gets the absolute position from the mesh
  76415. * @returns the absolute position
  76416. */
  76417. getAbsolutePosition(): Vector3;
  76418. /**
  76419. * Gets the absolute pivot point from the mesh
  76420. * @returns the absolute pivot point
  76421. */
  76422. getAbsolutePivotPoint(): Vector3;
  76423. /**
  76424. * Rotates the mesh
  76425. * @param axis The axis of rotation
  76426. * @param amount The amount of rotation
  76427. * @param space The space of the rotation
  76428. * @returns The rotation transform node
  76429. */
  76430. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  76431. /**
  76432. * Translates the mesh
  76433. * @param axis The axis of translation
  76434. * @param distance The distance of translation
  76435. * @param space The space of the translation
  76436. * @returns The transform node
  76437. */
  76438. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  76439. /**
  76440. * Sets the absolute position of the mesh
  76441. * @param absolutePosition The absolute position of the mesh
  76442. * @returns The transform node
  76443. */
  76444. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  76445. /**
  76446. * Gets the class name of the mesh
  76447. * @returns The class name
  76448. */
  76449. getClassName(): string;
  76450. }
  76451. /**
  76452. * Represents a physics imposter
  76453. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76454. */
  76455. export class PhysicsImpostor {
  76456. /**
  76457. * The physics-enabled object used as the physics imposter
  76458. */
  76459. object: IPhysicsEnabledObject;
  76460. /**
  76461. * The type of the physics imposter
  76462. */
  76463. type: number;
  76464. private _options;
  76465. private _scene?;
  76466. /**
  76467. * The default object size of the imposter
  76468. */
  76469. static DEFAULT_OBJECT_SIZE: Vector3;
  76470. /**
  76471. * The identity quaternion of the imposter
  76472. */
  76473. static IDENTITY_QUATERNION: Quaternion;
  76474. /** @hidden */
  76475. _pluginData: any;
  76476. private _physicsEngine;
  76477. private _physicsBody;
  76478. private _bodyUpdateRequired;
  76479. private _onBeforePhysicsStepCallbacks;
  76480. private _onAfterPhysicsStepCallbacks;
  76481. /** @hidden */
  76482. _onPhysicsCollideCallbacks: Array<{
  76483. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  76484. otherImpostors: Array<PhysicsImpostor>;
  76485. }>;
  76486. private _deltaPosition;
  76487. private _deltaRotation;
  76488. private _deltaRotationConjugated;
  76489. /** @hidden */
  76490. _isFromLine: boolean;
  76491. private _parent;
  76492. private _isDisposed;
  76493. private static _tmpVecs;
  76494. private static _tmpQuat;
  76495. /**
  76496. * Specifies if the physics imposter is disposed
  76497. */
  76498. readonly isDisposed: boolean;
  76499. /**
  76500. * Gets the mass of the physics imposter
  76501. */
  76502. mass: number;
  76503. /**
  76504. * Gets the coefficient of friction
  76505. */
  76506. /**
  76507. * Sets the coefficient of friction
  76508. */
  76509. friction: number;
  76510. /**
  76511. * Gets the coefficient of restitution
  76512. */
  76513. /**
  76514. * Sets the coefficient of restitution
  76515. */
  76516. restitution: number;
  76517. /**
  76518. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  76519. */
  76520. /**
  76521. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  76522. */
  76523. pressure: number;
  76524. /**
  76525. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  76526. */
  76527. /**
  76528. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  76529. */
  76530. stiffness: number;
  76531. /**
  76532. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  76533. */
  76534. /**
  76535. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  76536. */
  76537. velocityIterations: number;
  76538. /**
  76539. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  76540. */
  76541. /**
  76542. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  76543. */
  76544. positionIterations: number;
  76545. /**
  76546. * The unique id of the physics imposter
  76547. * set by the physics engine when adding this impostor to the array
  76548. */
  76549. uniqueId: number;
  76550. /**
  76551. * @hidden
  76552. */
  76553. soft: boolean;
  76554. /**
  76555. * @hidden
  76556. */
  76557. segments: number;
  76558. private _joints;
  76559. /**
  76560. * Initializes the physics imposter
  76561. * @param object The physics-enabled object used as the physics imposter
  76562. * @param type The type of the physics imposter
  76563. * @param _options The options for the physics imposter
  76564. * @param _scene The Babylon scene
  76565. */
  76566. constructor(
  76567. /**
  76568. * The physics-enabled object used as the physics imposter
  76569. */
  76570. object: IPhysicsEnabledObject,
  76571. /**
  76572. * The type of the physics imposter
  76573. */
  76574. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  76575. /**
  76576. * This function will completly initialize this impostor.
  76577. * It will create a new body - but only if this mesh has no parent.
  76578. * If it has, this impostor will not be used other than to define the impostor
  76579. * of the child mesh.
  76580. * @hidden
  76581. */
  76582. _init(): void;
  76583. private _getPhysicsParent;
  76584. /**
  76585. * Should a new body be generated.
  76586. * @returns boolean specifying if body initialization is required
  76587. */
  76588. isBodyInitRequired(): boolean;
  76589. /**
  76590. * Sets the updated scaling
  76591. * @param updated Specifies if the scaling is updated
  76592. */
  76593. setScalingUpdated(): void;
  76594. /**
  76595. * Force a regeneration of this or the parent's impostor's body.
  76596. * Use under cautious - This will remove all joints already implemented.
  76597. */
  76598. forceUpdate(): void;
  76599. /**
  76600. * Gets the body that holds this impostor. Either its own, or its parent.
  76601. */
  76602. /**
  76603. * Set the physics body. Used mainly by the physics engine/plugin
  76604. */
  76605. physicsBody: any;
  76606. /**
  76607. * Get the parent of the physics imposter
  76608. * @returns Physics imposter or null
  76609. */
  76610. /**
  76611. * Sets the parent of the physics imposter
  76612. */
  76613. parent: Nullable<PhysicsImpostor>;
  76614. /**
  76615. * Resets the update flags
  76616. */
  76617. resetUpdateFlags(): void;
  76618. /**
  76619. * Gets the object extend size
  76620. * @returns the object extend size
  76621. */
  76622. getObjectExtendSize(): Vector3;
  76623. /**
  76624. * Gets the object center
  76625. * @returns The object center
  76626. */
  76627. getObjectCenter(): Vector3;
  76628. /**
  76629. * Get a specific parametes from the options parameter
  76630. * @param paramName The object parameter name
  76631. * @returns The object parameter
  76632. */
  76633. getParam(paramName: string): any;
  76634. /**
  76635. * Sets a specific parameter in the options given to the physics plugin
  76636. * @param paramName The parameter name
  76637. * @param value The value of the parameter
  76638. */
  76639. setParam(paramName: string, value: number): void;
  76640. /**
  76641. * Specifically change the body's mass option. Won't recreate the physics body object
  76642. * @param mass The mass of the physics imposter
  76643. */
  76644. setMass(mass: number): void;
  76645. /**
  76646. * Gets the linear velocity
  76647. * @returns linear velocity or null
  76648. */
  76649. getLinearVelocity(): Nullable<Vector3>;
  76650. /**
  76651. * Sets the linear velocity
  76652. * @param velocity linear velocity or null
  76653. */
  76654. setLinearVelocity(velocity: Nullable<Vector3>): void;
  76655. /**
  76656. * Gets the angular velocity
  76657. * @returns angular velocity or null
  76658. */
  76659. getAngularVelocity(): Nullable<Vector3>;
  76660. /**
  76661. * Sets the angular velocity
  76662. * @param velocity The velocity or null
  76663. */
  76664. setAngularVelocity(velocity: Nullable<Vector3>): void;
  76665. /**
  76666. * Execute a function with the physics plugin native code
  76667. * Provide a function the will have two variables - the world object and the physics body object
  76668. * @param func The function to execute with the physics plugin native code
  76669. */
  76670. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  76671. /**
  76672. * Register a function that will be executed before the physics world is stepping forward
  76673. * @param func The function to execute before the physics world is stepped forward
  76674. */
  76675. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76676. /**
  76677. * Unregister a function that will be executed before the physics world is stepping forward
  76678. * @param func The function to execute before the physics world is stepped forward
  76679. */
  76680. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76681. /**
  76682. * Register a function that will be executed after the physics step
  76683. * @param func The function to execute after physics step
  76684. */
  76685. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76686. /**
  76687. * Unregisters a function that will be executed after the physics step
  76688. * @param func The function to execute after physics step
  76689. */
  76690. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76691. /**
  76692. * register a function that will be executed when this impostor collides against a different body
  76693. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  76694. * @param func Callback that is executed on collision
  76695. */
  76696. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  76697. /**
  76698. * Unregisters the physics imposter on contact
  76699. * @param collideAgainst The physics object to collide against
  76700. * @param func Callback to execute on collision
  76701. */
  76702. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  76703. private _tmpQuat;
  76704. private _tmpQuat2;
  76705. /**
  76706. * Get the parent rotation
  76707. * @returns The parent rotation
  76708. */
  76709. getParentsRotation(): Quaternion;
  76710. /**
  76711. * this function is executed by the physics engine.
  76712. */
  76713. beforeStep: () => void;
  76714. /**
  76715. * this function is executed by the physics engine
  76716. */
  76717. afterStep: () => void;
  76718. /**
  76719. * Legacy collision detection event support
  76720. */
  76721. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  76722. /**
  76723. * event and body object due to cannon's event-based architecture.
  76724. */
  76725. onCollide: (e: {
  76726. body: any;
  76727. }) => void;
  76728. /**
  76729. * Apply a force
  76730. * @param force The force to apply
  76731. * @param contactPoint The contact point for the force
  76732. * @returns The physics imposter
  76733. */
  76734. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  76735. /**
  76736. * Apply an impulse
  76737. * @param force The impulse force
  76738. * @param contactPoint The contact point for the impulse force
  76739. * @returns The physics imposter
  76740. */
  76741. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  76742. /**
  76743. * A help function to create a joint
  76744. * @param otherImpostor A physics imposter used to create a joint
  76745. * @param jointType The type of joint
  76746. * @param jointData The data for the joint
  76747. * @returns The physics imposter
  76748. */
  76749. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  76750. /**
  76751. * Add a joint to this impostor with a different impostor
  76752. * @param otherImpostor A physics imposter used to add a joint
  76753. * @param joint The joint to add
  76754. * @returns The physics imposter
  76755. */
  76756. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  76757. /**
  76758. * Add an anchor to a cloth impostor
  76759. * @param otherImpostor rigid impostor to anchor to
  76760. * @param width ratio across width from 0 to 1
  76761. * @param height ratio up height from 0 to 1
  76762. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  76763. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  76764. * @returns impostor the soft imposter
  76765. */
  76766. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  76767. /**
  76768. * Add a hook to a rope impostor
  76769. * @param otherImpostor rigid impostor to anchor to
  76770. * @param length ratio across rope from 0 to 1
  76771. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  76772. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  76773. * @returns impostor the rope imposter
  76774. */
  76775. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  76776. /**
  76777. * Will keep this body still, in a sleep mode.
  76778. * @returns the physics imposter
  76779. */
  76780. sleep(): PhysicsImpostor;
  76781. /**
  76782. * Wake the body up.
  76783. * @returns The physics imposter
  76784. */
  76785. wakeUp(): PhysicsImpostor;
  76786. /**
  76787. * Clones the physics imposter
  76788. * @param newObject The physics imposter clones to this physics-enabled object
  76789. * @returns A nullable physics imposter
  76790. */
  76791. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  76792. /**
  76793. * Disposes the physics imposter
  76794. */
  76795. dispose(): void;
  76796. /**
  76797. * Sets the delta position
  76798. * @param position The delta position amount
  76799. */
  76800. setDeltaPosition(position: Vector3): void;
  76801. /**
  76802. * Sets the delta rotation
  76803. * @param rotation The delta rotation amount
  76804. */
  76805. setDeltaRotation(rotation: Quaternion): void;
  76806. /**
  76807. * Gets the box size of the physics imposter and stores the result in the input parameter
  76808. * @param result Stores the box size
  76809. * @returns The physics imposter
  76810. */
  76811. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  76812. /**
  76813. * Gets the radius of the physics imposter
  76814. * @returns Radius of the physics imposter
  76815. */
  76816. getRadius(): number;
  76817. /**
  76818. * Sync a bone with this impostor
  76819. * @param bone The bone to sync to the impostor.
  76820. * @param boneMesh The mesh that the bone is influencing.
  76821. * @param jointPivot The pivot of the joint / bone in local space.
  76822. * @param distToJoint Optional distance from the impostor to the joint.
  76823. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  76824. */
  76825. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  76826. /**
  76827. * Sync impostor to a bone
  76828. * @param bone The bone that the impostor will be synced to.
  76829. * @param boneMesh The mesh that the bone is influencing.
  76830. * @param jointPivot The pivot of the joint / bone in local space.
  76831. * @param distToJoint Optional distance from the impostor to the joint.
  76832. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  76833. * @param boneAxis Optional vector3 axis the bone is aligned with
  76834. */
  76835. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  76836. /**
  76837. * No-Imposter type
  76838. */
  76839. static NoImpostor: number;
  76840. /**
  76841. * Sphere-Imposter type
  76842. */
  76843. static SphereImpostor: number;
  76844. /**
  76845. * Box-Imposter type
  76846. */
  76847. static BoxImpostor: number;
  76848. /**
  76849. * Plane-Imposter type
  76850. */
  76851. static PlaneImpostor: number;
  76852. /**
  76853. * Mesh-imposter type
  76854. */
  76855. static MeshImpostor: number;
  76856. /**
  76857. * Capsule-Impostor type (Ammo.js plugin only)
  76858. */
  76859. static CapsuleImpostor: number;
  76860. /**
  76861. * Cylinder-Imposter type
  76862. */
  76863. static CylinderImpostor: number;
  76864. /**
  76865. * Particle-Imposter type
  76866. */
  76867. static ParticleImpostor: number;
  76868. /**
  76869. * Heightmap-Imposter type
  76870. */
  76871. static HeightmapImpostor: number;
  76872. /**
  76873. * ConvexHull-Impostor type (Ammo.js plugin only)
  76874. */
  76875. static ConvexHullImpostor: number;
  76876. /**
  76877. * Rope-Imposter type
  76878. */
  76879. static RopeImpostor: number;
  76880. /**
  76881. * Cloth-Imposter type
  76882. */
  76883. static ClothImpostor: number;
  76884. /**
  76885. * Softbody-Imposter type
  76886. */
  76887. static SoftbodyImpostor: number;
  76888. }
  76889. }
  76890. declare module BABYLON {
  76891. /**
  76892. * @hidden
  76893. **/
  76894. export class _CreationDataStorage {
  76895. closePath?: boolean;
  76896. closeArray?: boolean;
  76897. idx: number[];
  76898. dashSize: number;
  76899. gapSize: number;
  76900. path3D: Path3D;
  76901. pathArray: Vector3[][];
  76902. arc: number;
  76903. radius: number;
  76904. cap: number;
  76905. tessellation: number;
  76906. }
  76907. /**
  76908. * @hidden
  76909. **/
  76910. class _InstanceDataStorage {
  76911. visibleInstances: any;
  76912. batchCache: _InstancesBatch;
  76913. instancesBufferSize: number;
  76914. instancesBuffer: Nullable<Buffer>;
  76915. instancesData: Float32Array;
  76916. overridenInstanceCount: number;
  76917. isFrozen: boolean;
  76918. previousBatch: Nullable<_InstancesBatch>;
  76919. hardwareInstancedRendering: boolean;
  76920. sideOrientation: number;
  76921. }
  76922. /**
  76923. * @hidden
  76924. **/
  76925. export class _InstancesBatch {
  76926. mustReturn: boolean;
  76927. visibleInstances: Nullable<InstancedMesh[]>[];
  76928. renderSelf: boolean[];
  76929. hardwareInstancedRendering: boolean[];
  76930. }
  76931. /**
  76932. * Class used to represent renderable models
  76933. */
  76934. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  76935. /**
  76936. * Mesh side orientation : usually the external or front surface
  76937. */
  76938. static readonly FRONTSIDE: number;
  76939. /**
  76940. * Mesh side orientation : usually the internal or back surface
  76941. */
  76942. static readonly BACKSIDE: number;
  76943. /**
  76944. * Mesh side orientation : both internal and external or front and back surfaces
  76945. */
  76946. static readonly DOUBLESIDE: number;
  76947. /**
  76948. * Mesh side orientation : by default, `FRONTSIDE`
  76949. */
  76950. static readonly DEFAULTSIDE: number;
  76951. /**
  76952. * Mesh cap setting : no cap
  76953. */
  76954. static readonly NO_CAP: number;
  76955. /**
  76956. * Mesh cap setting : one cap at the beginning of the mesh
  76957. */
  76958. static readonly CAP_START: number;
  76959. /**
  76960. * Mesh cap setting : one cap at the end of the mesh
  76961. */
  76962. static readonly CAP_END: number;
  76963. /**
  76964. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  76965. */
  76966. static readonly CAP_ALL: number;
  76967. /**
  76968. * Mesh pattern setting : no flip or rotate
  76969. */
  76970. static readonly NO_FLIP: number;
  76971. /**
  76972. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  76973. */
  76974. static readonly FLIP_TILE: number;
  76975. /**
  76976. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  76977. */
  76978. static readonly ROTATE_TILE: number;
  76979. /**
  76980. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  76981. */
  76982. static readonly FLIP_ROW: number;
  76983. /**
  76984. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  76985. */
  76986. static readonly ROTATE_ROW: number;
  76987. /**
  76988. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  76989. */
  76990. static readonly FLIP_N_ROTATE_TILE: number;
  76991. /**
  76992. * Mesh pattern setting : rotate pattern and rotate
  76993. */
  76994. static readonly FLIP_N_ROTATE_ROW: number;
  76995. /**
  76996. * Mesh tile positioning : part tiles same on left/right or top/bottom
  76997. */
  76998. static readonly CENTER: number;
  76999. /**
  77000. * Mesh tile positioning : part tiles on left
  77001. */
  77002. static readonly LEFT: number;
  77003. /**
  77004. * Mesh tile positioning : part tiles on right
  77005. */
  77006. static readonly RIGHT: number;
  77007. /**
  77008. * Mesh tile positioning : part tiles on top
  77009. */
  77010. static readonly TOP: number;
  77011. /**
  77012. * Mesh tile positioning : part tiles on bottom
  77013. */
  77014. static readonly BOTTOM: number;
  77015. /**
  77016. * Gets the default side orientation.
  77017. * @param orientation the orientation to value to attempt to get
  77018. * @returns the default orientation
  77019. * @hidden
  77020. */
  77021. static _GetDefaultSideOrientation(orientation?: number): number;
  77022. private _internalMeshDataInfo;
  77023. /**
  77024. * An event triggered before rendering the mesh
  77025. */
  77026. readonly onBeforeRenderObservable: Observable<Mesh>;
  77027. /**
  77028. * An event triggered before binding the mesh
  77029. */
  77030. readonly onBeforeBindObservable: Observable<Mesh>;
  77031. /**
  77032. * An event triggered after rendering the mesh
  77033. */
  77034. readonly onAfterRenderObservable: Observable<Mesh>;
  77035. /**
  77036. * An event triggered before drawing the mesh
  77037. */
  77038. readonly onBeforeDrawObservable: Observable<Mesh>;
  77039. private _onBeforeDrawObserver;
  77040. /**
  77041. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  77042. */
  77043. onBeforeDraw: () => void;
  77044. /**
  77045. * Gets the delay loading state of the mesh (when delay loading is turned on)
  77046. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  77047. */
  77048. delayLoadState: number;
  77049. /**
  77050. * Gets the list of instances created from this mesh
  77051. * it is not supposed to be modified manually.
  77052. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  77053. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77054. */
  77055. instances: InstancedMesh[];
  77056. /**
  77057. * Gets the file containing delay loading data for this mesh
  77058. */
  77059. delayLoadingFile: string;
  77060. /** @hidden */
  77061. _binaryInfo: any;
  77062. /**
  77063. * User defined function used to change how LOD level selection is done
  77064. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  77065. */
  77066. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  77067. /**
  77068. * Gets or sets the morph target manager
  77069. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  77070. */
  77071. morphTargetManager: Nullable<MorphTargetManager>;
  77072. /** @hidden */
  77073. _creationDataStorage: Nullable<_CreationDataStorage>;
  77074. /** @hidden */
  77075. _geometry: Nullable<Geometry>;
  77076. /** @hidden */
  77077. _delayInfo: Array<string>;
  77078. /** @hidden */
  77079. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  77080. /** @hidden */
  77081. _instanceDataStorage: _InstanceDataStorage;
  77082. private _effectiveMaterial;
  77083. /** @hidden */
  77084. _shouldGenerateFlatShading: boolean;
  77085. /** @hidden */
  77086. _originalBuilderSideOrientation: number;
  77087. /**
  77088. * Use this property to change the original side orientation defined at construction time
  77089. */
  77090. overrideMaterialSideOrientation: Nullable<number>;
  77091. /**
  77092. * Gets the source mesh (the one used to clone this one from)
  77093. */
  77094. readonly source: Nullable<Mesh>;
  77095. /**
  77096. * Gets or sets a boolean indicating that this mesh does not use index buffer
  77097. */
  77098. isUnIndexed: boolean;
  77099. /**
  77100. * @constructor
  77101. * @param name The value used by scene.getMeshByName() to do a lookup.
  77102. * @param scene The scene to add this mesh to.
  77103. * @param parent The parent of this mesh, if it has one
  77104. * @param source An optional Mesh from which geometry is shared, cloned.
  77105. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  77106. * When false, achieved by calling a clone(), also passing False.
  77107. * This will make creation of children, recursive.
  77108. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  77109. */
  77110. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  77111. /**
  77112. * Gets the class name
  77113. * @returns the string "Mesh".
  77114. */
  77115. getClassName(): string;
  77116. /** @hidden */
  77117. readonly _isMesh: boolean;
  77118. /**
  77119. * Returns a description of this mesh
  77120. * @param fullDetails define if full details about this mesh must be used
  77121. * @returns a descriptive string representing this mesh
  77122. */
  77123. toString(fullDetails?: boolean): string;
  77124. /** @hidden */
  77125. _unBindEffect(): void;
  77126. /**
  77127. * Gets a boolean indicating if this mesh has LOD
  77128. */
  77129. readonly hasLODLevels: boolean;
  77130. /**
  77131. * Gets the list of MeshLODLevel associated with the current mesh
  77132. * @returns an array of MeshLODLevel
  77133. */
  77134. getLODLevels(): MeshLODLevel[];
  77135. private _sortLODLevels;
  77136. /**
  77137. * Add a mesh as LOD level triggered at the given distance.
  77138. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77139. * @param distance The distance from the center of the object to show this level
  77140. * @param mesh The mesh to be added as LOD level (can be null)
  77141. * @return This mesh (for chaining)
  77142. */
  77143. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  77144. /**
  77145. * Returns the LOD level mesh at the passed distance or null if not found.
  77146. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77147. * @param distance The distance from the center of the object to show this level
  77148. * @returns a Mesh or `null`
  77149. */
  77150. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  77151. /**
  77152. * Remove a mesh from the LOD array
  77153. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77154. * @param mesh defines the mesh to be removed
  77155. * @return This mesh (for chaining)
  77156. */
  77157. removeLODLevel(mesh: Mesh): Mesh;
  77158. /**
  77159. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  77160. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77161. * @param camera defines the camera to use to compute distance
  77162. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  77163. * @return This mesh (for chaining)
  77164. */
  77165. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  77166. /**
  77167. * Gets the mesh internal Geometry object
  77168. */
  77169. readonly geometry: Nullable<Geometry>;
  77170. /**
  77171. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  77172. * @returns the total number of vertices
  77173. */
  77174. getTotalVertices(): number;
  77175. /**
  77176. * Returns the content of an associated vertex buffer
  77177. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77178. * - VertexBuffer.PositionKind
  77179. * - VertexBuffer.UVKind
  77180. * - VertexBuffer.UV2Kind
  77181. * - VertexBuffer.UV3Kind
  77182. * - VertexBuffer.UV4Kind
  77183. * - VertexBuffer.UV5Kind
  77184. * - VertexBuffer.UV6Kind
  77185. * - VertexBuffer.ColorKind
  77186. * - VertexBuffer.MatricesIndicesKind
  77187. * - VertexBuffer.MatricesIndicesExtraKind
  77188. * - VertexBuffer.MatricesWeightsKind
  77189. * - VertexBuffer.MatricesWeightsExtraKind
  77190. * @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
  77191. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  77192. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  77193. */
  77194. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  77195. /**
  77196. * Returns the mesh VertexBuffer object from the requested `kind`
  77197. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77198. * - VertexBuffer.PositionKind
  77199. * - VertexBuffer.NormalKind
  77200. * - VertexBuffer.UVKind
  77201. * - VertexBuffer.UV2Kind
  77202. * - VertexBuffer.UV3Kind
  77203. * - VertexBuffer.UV4Kind
  77204. * - VertexBuffer.UV5Kind
  77205. * - VertexBuffer.UV6Kind
  77206. * - VertexBuffer.ColorKind
  77207. * - VertexBuffer.MatricesIndicesKind
  77208. * - VertexBuffer.MatricesIndicesExtraKind
  77209. * - VertexBuffer.MatricesWeightsKind
  77210. * - VertexBuffer.MatricesWeightsExtraKind
  77211. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  77212. */
  77213. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  77214. /**
  77215. * Tests if a specific vertex buffer is associated with this mesh
  77216. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77217. * - VertexBuffer.PositionKind
  77218. * - VertexBuffer.NormalKind
  77219. * - VertexBuffer.UVKind
  77220. * - VertexBuffer.UV2Kind
  77221. * - VertexBuffer.UV3Kind
  77222. * - VertexBuffer.UV4Kind
  77223. * - VertexBuffer.UV5Kind
  77224. * - VertexBuffer.UV6Kind
  77225. * - VertexBuffer.ColorKind
  77226. * - VertexBuffer.MatricesIndicesKind
  77227. * - VertexBuffer.MatricesIndicesExtraKind
  77228. * - VertexBuffer.MatricesWeightsKind
  77229. * - VertexBuffer.MatricesWeightsExtraKind
  77230. * @returns a boolean
  77231. */
  77232. isVerticesDataPresent(kind: string): boolean;
  77233. /**
  77234. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  77235. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77236. * - VertexBuffer.PositionKind
  77237. * - VertexBuffer.UVKind
  77238. * - VertexBuffer.UV2Kind
  77239. * - VertexBuffer.UV3Kind
  77240. * - VertexBuffer.UV4Kind
  77241. * - VertexBuffer.UV5Kind
  77242. * - VertexBuffer.UV6Kind
  77243. * - VertexBuffer.ColorKind
  77244. * - VertexBuffer.MatricesIndicesKind
  77245. * - VertexBuffer.MatricesIndicesExtraKind
  77246. * - VertexBuffer.MatricesWeightsKind
  77247. * - VertexBuffer.MatricesWeightsExtraKind
  77248. * @returns a boolean
  77249. */
  77250. isVertexBufferUpdatable(kind: string): boolean;
  77251. /**
  77252. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  77253. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77254. * - VertexBuffer.PositionKind
  77255. * - VertexBuffer.NormalKind
  77256. * - VertexBuffer.UVKind
  77257. * - VertexBuffer.UV2Kind
  77258. * - VertexBuffer.UV3Kind
  77259. * - VertexBuffer.UV4Kind
  77260. * - VertexBuffer.UV5Kind
  77261. * - VertexBuffer.UV6Kind
  77262. * - VertexBuffer.ColorKind
  77263. * - VertexBuffer.MatricesIndicesKind
  77264. * - VertexBuffer.MatricesIndicesExtraKind
  77265. * - VertexBuffer.MatricesWeightsKind
  77266. * - VertexBuffer.MatricesWeightsExtraKind
  77267. * @returns an array of strings
  77268. */
  77269. getVerticesDataKinds(): string[];
  77270. /**
  77271. * Returns a positive integer : the total number of indices in this mesh geometry.
  77272. * @returns the numner of indices or zero if the mesh has no geometry.
  77273. */
  77274. getTotalIndices(): number;
  77275. /**
  77276. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  77277. * @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.
  77278. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77279. * @returns the indices array or an empty array if the mesh has no geometry
  77280. */
  77281. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  77282. readonly isBlocked: boolean;
  77283. /**
  77284. * Determine if the current mesh is ready to be rendered
  77285. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  77286. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  77287. * @returns true if all associated assets are ready (material, textures, shaders)
  77288. */
  77289. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  77290. /**
  77291. * 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.
  77292. */
  77293. readonly areNormalsFrozen: boolean;
  77294. /**
  77295. * 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.
  77296. * @returns the current mesh
  77297. */
  77298. freezeNormals(): Mesh;
  77299. /**
  77300. * 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
  77301. * @returns the current mesh
  77302. */
  77303. unfreezeNormals(): Mesh;
  77304. /**
  77305. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  77306. */
  77307. overridenInstanceCount: number;
  77308. /** @hidden */
  77309. _preActivate(): Mesh;
  77310. /** @hidden */
  77311. _preActivateForIntermediateRendering(renderId: number): Mesh;
  77312. /** @hidden */
  77313. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  77314. /**
  77315. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  77316. * This means the mesh underlying bounding box and sphere are recomputed.
  77317. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  77318. * @returns the current mesh
  77319. */
  77320. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  77321. /** @hidden */
  77322. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  77323. /**
  77324. * This function will subdivide the mesh into multiple submeshes
  77325. * @param count defines the expected number of submeshes
  77326. */
  77327. subdivide(count: number): void;
  77328. /**
  77329. * Copy a FloatArray into a specific associated vertex buffer
  77330. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77331. * - VertexBuffer.PositionKind
  77332. * - VertexBuffer.UVKind
  77333. * - VertexBuffer.UV2Kind
  77334. * - VertexBuffer.UV3Kind
  77335. * - VertexBuffer.UV4Kind
  77336. * - VertexBuffer.UV5Kind
  77337. * - VertexBuffer.UV6Kind
  77338. * - VertexBuffer.ColorKind
  77339. * - VertexBuffer.MatricesIndicesKind
  77340. * - VertexBuffer.MatricesIndicesExtraKind
  77341. * - VertexBuffer.MatricesWeightsKind
  77342. * - VertexBuffer.MatricesWeightsExtraKind
  77343. * @param data defines the data source
  77344. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77345. * @param stride defines the data stride size (can be null)
  77346. * @returns the current mesh
  77347. */
  77348. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  77349. /**
  77350. * Flags an associated vertex buffer as updatable
  77351. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  77352. * - VertexBuffer.PositionKind
  77353. * - VertexBuffer.UVKind
  77354. * - VertexBuffer.UV2Kind
  77355. * - VertexBuffer.UV3Kind
  77356. * - VertexBuffer.UV4Kind
  77357. * - VertexBuffer.UV5Kind
  77358. * - VertexBuffer.UV6Kind
  77359. * - VertexBuffer.ColorKind
  77360. * - VertexBuffer.MatricesIndicesKind
  77361. * - VertexBuffer.MatricesIndicesExtraKind
  77362. * - VertexBuffer.MatricesWeightsKind
  77363. * - VertexBuffer.MatricesWeightsExtraKind
  77364. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77365. */
  77366. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  77367. /**
  77368. * Sets the mesh global Vertex Buffer
  77369. * @param buffer defines the buffer to use
  77370. * @returns the current mesh
  77371. */
  77372. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  77373. /**
  77374. * Update a specific associated vertex buffer
  77375. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77376. * - VertexBuffer.PositionKind
  77377. * - VertexBuffer.UVKind
  77378. * - VertexBuffer.UV2Kind
  77379. * - VertexBuffer.UV3Kind
  77380. * - VertexBuffer.UV4Kind
  77381. * - VertexBuffer.UV5Kind
  77382. * - VertexBuffer.UV6Kind
  77383. * - VertexBuffer.ColorKind
  77384. * - VertexBuffer.MatricesIndicesKind
  77385. * - VertexBuffer.MatricesIndicesExtraKind
  77386. * - VertexBuffer.MatricesWeightsKind
  77387. * - VertexBuffer.MatricesWeightsExtraKind
  77388. * @param data defines the data source
  77389. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  77390. * @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)
  77391. * @returns the current mesh
  77392. */
  77393. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  77394. /**
  77395. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  77396. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  77397. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  77398. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  77399. * @returns the current mesh
  77400. */
  77401. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  77402. /**
  77403. * Creates a un-shared specific occurence of the geometry for the mesh.
  77404. * @returns the current mesh
  77405. */
  77406. makeGeometryUnique(): Mesh;
  77407. /**
  77408. * Set the index buffer of this mesh
  77409. * @param indices defines the source data
  77410. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  77411. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  77412. * @returns the current mesh
  77413. */
  77414. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  77415. /**
  77416. * Update the current index buffer
  77417. * @param indices defines the source data
  77418. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  77419. * @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)
  77420. * @returns the current mesh
  77421. */
  77422. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  77423. /**
  77424. * Invert the geometry to move from a right handed system to a left handed one.
  77425. * @returns the current mesh
  77426. */
  77427. toLeftHanded(): Mesh;
  77428. /** @hidden */
  77429. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  77430. /** @hidden */
  77431. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  77432. /**
  77433. * Registers for this mesh a javascript function called just before the rendering process
  77434. * @param func defines the function to call before rendering this mesh
  77435. * @returns the current mesh
  77436. */
  77437. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77438. /**
  77439. * Disposes a previously registered javascript function called before the rendering
  77440. * @param func defines the function to remove
  77441. * @returns the current mesh
  77442. */
  77443. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77444. /**
  77445. * Registers for this mesh a javascript function called just after the rendering is complete
  77446. * @param func defines the function to call after rendering this mesh
  77447. * @returns the current mesh
  77448. */
  77449. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77450. /**
  77451. * Disposes a previously registered javascript function called after the rendering.
  77452. * @param func defines the function to remove
  77453. * @returns the current mesh
  77454. */
  77455. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77456. /** @hidden */
  77457. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  77458. /** @hidden */
  77459. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  77460. /** @hidden */
  77461. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  77462. /** @hidden */
  77463. _rebuild(): void;
  77464. /** @hidden */
  77465. _freeze(): void;
  77466. /** @hidden */
  77467. _unFreeze(): void;
  77468. /**
  77469. * 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
  77470. * @param subMesh defines the subMesh to render
  77471. * @param enableAlphaMode defines if alpha mode can be changed
  77472. * @returns the current mesh
  77473. */
  77474. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  77475. private _onBeforeDraw;
  77476. /**
  77477. * Renormalize the mesh and patch it up if there are no weights
  77478. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  77479. * However in the case of zero weights then we set just a single influence to 1.
  77480. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  77481. */
  77482. cleanMatrixWeights(): void;
  77483. private normalizeSkinFourWeights;
  77484. private normalizeSkinWeightsAndExtra;
  77485. /**
  77486. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  77487. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  77488. * the user know there was an issue with importing the mesh
  77489. * @returns a validation object with skinned, valid and report string
  77490. */
  77491. validateSkinning(): {
  77492. skinned: boolean;
  77493. valid: boolean;
  77494. report: string;
  77495. };
  77496. /** @hidden */
  77497. _checkDelayState(): Mesh;
  77498. private _queueLoad;
  77499. /**
  77500. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  77501. * A mesh is in the frustum if its bounding box intersects the frustum
  77502. * @param frustumPlanes defines the frustum to test
  77503. * @returns true if the mesh is in the frustum planes
  77504. */
  77505. isInFrustum(frustumPlanes: Plane[]): boolean;
  77506. /**
  77507. * Sets the mesh material by the material or multiMaterial `id` property
  77508. * @param id is a string identifying the material or the multiMaterial
  77509. * @returns the current mesh
  77510. */
  77511. setMaterialByID(id: string): Mesh;
  77512. /**
  77513. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  77514. * @returns an array of IAnimatable
  77515. */
  77516. getAnimatables(): IAnimatable[];
  77517. /**
  77518. * Modifies the mesh geometry according to the passed transformation matrix.
  77519. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  77520. * The mesh normals are modified using the same transformation.
  77521. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77522. * @param transform defines the transform matrix to use
  77523. * @see http://doc.babylonjs.com/resources/baking_transformations
  77524. * @returns the current mesh
  77525. */
  77526. bakeTransformIntoVertices(transform: Matrix): Mesh;
  77527. /**
  77528. * Modifies the mesh geometry according to its own current World Matrix.
  77529. * The mesh World Matrix is then reset.
  77530. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  77531. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77532. * @see http://doc.babylonjs.com/resources/baking_transformations
  77533. * @returns the current mesh
  77534. */
  77535. bakeCurrentTransformIntoVertices(): Mesh;
  77536. /** @hidden */
  77537. readonly _positions: Nullable<Vector3[]>;
  77538. /** @hidden */
  77539. _resetPointsArrayCache(): Mesh;
  77540. /** @hidden */
  77541. _generatePointsArray(): boolean;
  77542. /**
  77543. * Returns a new Mesh object generated from the current mesh properties.
  77544. * This method must not get confused with createInstance()
  77545. * @param name is a string, the name given to the new mesh
  77546. * @param newParent can be any Node object (default `null`)
  77547. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  77548. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  77549. * @returns a new mesh
  77550. */
  77551. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  77552. /**
  77553. * Releases resources associated with this mesh.
  77554. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77555. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77556. */
  77557. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77558. /**
  77559. * Modifies the mesh geometry according to a displacement map.
  77560. * 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.
  77561. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77562. * @param url is a string, the URL from the image file is to be downloaded.
  77563. * @param minHeight is the lower limit of the displacement.
  77564. * @param maxHeight is the upper limit of the displacement.
  77565. * @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.
  77566. * @param uvOffset is an optional vector2 used to offset UV.
  77567. * @param uvScale is an optional vector2 used to scale UV.
  77568. * @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.
  77569. * @returns the Mesh.
  77570. */
  77571. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77572. /**
  77573. * Modifies the mesh geometry according to a displacementMap buffer.
  77574. * 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.
  77575. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77576. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  77577. * @param heightMapWidth is the width of the buffer image.
  77578. * @param heightMapHeight is the height of the buffer image.
  77579. * @param minHeight is the lower limit of the displacement.
  77580. * @param maxHeight is the upper limit of the displacement.
  77581. * @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.
  77582. * @param uvOffset is an optional vector2 used to offset UV.
  77583. * @param uvScale is an optional vector2 used to scale UV.
  77584. * @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.
  77585. * @returns the Mesh.
  77586. */
  77587. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77588. /**
  77589. * Modify the mesh to get a flat shading rendering.
  77590. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  77591. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  77592. * @returns current mesh
  77593. */
  77594. convertToFlatShadedMesh(): Mesh;
  77595. /**
  77596. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  77597. * In other words, more vertices, no more indices and a single bigger VBO.
  77598. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  77599. * @returns current mesh
  77600. */
  77601. convertToUnIndexedMesh(): Mesh;
  77602. /**
  77603. * Inverses facet orientations.
  77604. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77605. * @param flipNormals will also inverts the normals
  77606. * @returns current mesh
  77607. */
  77608. flipFaces(flipNormals?: boolean): Mesh;
  77609. /**
  77610. * Increase the number of facets and hence vertices in a mesh
  77611. * Vertex normals are interpolated from existing vertex normals
  77612. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77613. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  77614. */
  77615. increaseVertices(numberPerEdge: number): void;
  77616. /**
  77617. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  77618. * This will undo any application of covertToFlatShadedMesh
  77619. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77620. */
  77621. forceSharedVertices(): void;
  77622. /** @hidden */
  77623. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  77624. /** @hidden */
  77625. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  77626. /**
  77627. * Creates a new InstancedMesh object from the mesh model.
  77628. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77629. * @param name defines the name of the new instance
  77630. * @returns a new InstancedMesh
  77631. */
  77632. createInstance(name: string): InstancedMesh;
  77633. /**
  77634. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  77635. * After this call, all the mesh instances have the same submeshes than the current mesh.
  77636. * @returns the current mesh
  77637. */
  77638. synchronizeInstances(): Mesh;
  77639. /**
  77640. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  77641. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  77642. * This should be used together with the simplification to avoid disappearing triangles.
  77643. * @param successCallback an optional success callback to be called after the optimization finished.
  77644. * @returns the current mesh
  77645. */
  77646. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  77647. /**
  77648. * Serialize current mesh
  77649. * @param serializationObject defines the object which will receive the serialization data
  77650. */
  77651. serialize(serializationObject: any): void;
  77652. /** @hidden */
  77653. _syncGeometryWithMorphTargetManager(): void;
  77654. /** @hidden */
  77655. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  77656. /**
  77657. * Returns a new Mesh object parsed from the source provided.
  77658. * @param parsedMesh is the source
  77659. * @param scene defines the hosting scene
  77660. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  77661. * @returns a new Mesh
  77662. */
  77663. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  77664. /**
  77665. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  77666. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77667. * @param name defines the name of the mesh to create
  77668. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  77669. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  77670. * @param closePath creates a seam between the first and the last points of each path of the path array
  77671. * @param offset is taken in account only if the `pathArray` is containing a single path
  77672. * @param scene defines the hosting scene
  77673. * @param updatable defines if the mesh must be flagged as updatable
  77674. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77675. * @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)
  77676. * @returns a new Mesh
  77677. */
  77678. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77679. /**
  77680. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  77681. * @param name defines the name of the mesh to create
  77682. * @param radius sets the radius size (float) of the polygon (default 0.5)
  77683. * @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
  77684. * @param scene defines the hosting scene
  77685. * @param updatable defines if the mesh must be flagged as updatable
  77686. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77687. * @returns a new Mesh
  77688. */
  77689. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77690. /**
  77691. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  77692. * @param name defines the name of the mesh to create
  77693. * @param size sets the size (float) of each box side (default 1)
  77694. * @param scene defines the hosting scene
  77695. * @param updatable defines if the mesh must be flagged as updatable
  77696. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77697. * @returns a new Mesh
  77698. */
  77699. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77700. /**
  77701. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  77702. * @param name defines the name of the mesh to create
  77703. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  77704. * @param diameter sets the diameter size (float) of the sphere (default 1)
  77705. * @param scene defines the hosting scene
  77706. * @param updatable defines if the mesh must be flagged as updatable
  77707. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77708. * @returns a new Mesh
  77709. */
  77710. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77711. /**
  77712. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  77713. * @param name defines the name of the mesh to create
  77714. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  77715. * @param diameter sets the diameter size (float) of the sphere (default 1)
  77716. * @param scene defines the hosting scene
  77717. * @returns a new Mesh
  77718. */
  77719. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  77720. /**
  77721. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  77722. * @param name defines the name of the mesh to create
  77723. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  77724. * @param diameterTop set the top cap diameter (floats, default 1)
  77725. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  77726. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  77727. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  77728. * @param scene defines the hosting scene
  77729. * @param updatable defines if the mesh must be flagged as updatable
  77730. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77731. * @returns a new Mesh
  77732. */
  77733. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  77734. /**
  77735. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  77736. * @param name defines the name of the mesh to create
  77737. * @param diameter sets the diameter size (float) of the torus (default 1)
  77738. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  77739. * @param tessellation sets the number of torus sides (postive integer, default 16)
  77740. * @param scene defines the hosting scene
  77741. * @param updatable defines if the mesh must be flagged as updatable
  77742. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77743. * @returns a new Mesh
  77744. */
  77745. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77746. /**
  77747. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  77748. * @param name defines the name of the mesh to create
  77749. * @param radius sets the global radius size (float) of the torus knot (default 2)
  77750. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  77751. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  77752. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  77753. * @param p the number of windings on X axis (positive integers, default 2)
  77754. * @param q the number of windings on Y axis (positive integers, default 3)
  77755. * @param scene defines the hosting scene
  77756. * @param updatable defines if the mesh must be flagged as updatable
  77757. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77758. * @returns a new Mesh
  77759. */
  77760. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77761. /**
  77762. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  77763. * @param name defines the name of the mesh to create
  77764. * @param points is an array successive Vector3
  77765. * @param scene defines the hosting scene
  77766. * @param updatable defines if the mesh must be flagged as updatable
  77767. * @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).
  77768. * @returns a new Mesh
  77769. */
  77770. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  77771. /**
  77772. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  77773. * @param name defines the name of the mesh to create
  77774. * @param points is an array successive Vector3
  77775. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  77776. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  77777. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  77778. * @param scene defines the hosting scene
  77779. * @param updatable defines if the mesh must be flagged as updatable
  77780. * @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)
  77781. * @returns a new Mesh
  77782. */
  77783. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  77784. /**
  77785. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  77786. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  77787. * 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.
  77788. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77789. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77790. * Remember you can only change the shape positions, not their number when updating a polygon.
  77791. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  77792. * @param name defines the name of the mesh to create
  77793. * @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
  77794. * @param scene defines the hosting scene
  77795. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  77796. * @param updatable defines if the mesh must be flagged as updatable
  77797. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77798. * @param earcutInjection can be used to inject your own earcut reference
  77799. * @returns a new Mesh
  77800. */
  77801. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  77802. /**
  77803. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  77804. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  77805. * @param name defines the name of the mesh to create
  77806. * @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
  77807. * @param depth defines the height of extrusion
  77808. * @param scene defines the hosting scene
  77809. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  77810. * @param updatable defines if the mesh must be flagged as updatable
  77811. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77812. * @param earcutInjection can be used to inject your own earcut reference
  77813. * @returns a new Mesh
  77814. */
  77815. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  77816. /**
  77817. * Creates an extruded shape mesh.
  77818. * 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
  77819. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77820. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77821. * @param name defines the name of the mesh to create
  77822. * @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
  77823. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  77824. * @param scale is the value to scale the shape
  77825. * @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
  77826. * @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
  77827. * @param scene defines the hosting scene
  77828. * @param updatable defines if the mesh must be flagged as updatable
  77829. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77830. * @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)
  77831. * @returns a new Mesh
  77832. */
  77833. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77834. /**
  77835. * Creates an custom extruded shape mesh.
  77836. * The custom extrusion is a parametric shape.
  77837. * It has no predefined shape. Its final shape will depend on the input parameters.
  77838. * Please consider using the same method from the MeshBuilder class instead
  77839. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77840. * @param name defines the name of the mesh to create
  77841. * @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
  77842. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  77843. * @param scaleFunction is a custom Javascript function called on each path point
  77844. * @param rotationFunction is a custom Javascript function called on each path point
  77845. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  77846. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  77847. * @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
  77848. * @param scene defines the hosting scene
  77849. * @param updatable defines if the mesh must be flagged as updatable
  77850. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77851. * @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)
  77852. * @returns a new Mesh
  77853. */
  77854. 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;
  77855. /**
  77856. * Creates lathe mesh.
  77857. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  77858. * Please consider using the same method from the MeshBuilder class instead
  77859. * @param name defines the name of the mesh to create
  77860. * @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
  77861. * @param radius is the radius value of the lathe
  77862. * @param tessellation is the side number of the lathe.
  77863. * @param scene defines the hosting scene
  77864. * @param updatable defines if the mesh must be flagged as updatable
  77865. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77866. * @returns a new Mesh
  77867. */
  77868. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77869. /**
  77870. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  77871. * @param name defines the name of the mesh to create
  77872. * @param size sets the size (float) of both sides of the plane at once (default 1)
  77873. * @param scene defines the hosting scene
  77874. * @param updatable defines if the mesh must be flagged as updatable
  77875. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77876. * @returns a new Mesh
  77877. */
  77878. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77879. /**
  77880. * Creates a ground mesh.
  77881. * Please consider using the same method from the MeshBuilder class instead
  77882. * @param name defines the name of the mesh to create
  77883. * @param width set the width of the ground
  77884. * @param height set the height of the ground
  77885. * @param subdivisions sets the number of subdivisions per side
  77886. * @param scene defines the hosting scene
  77887. * @param updatable defines if the mesh must be flagged as updatable
  77888. * @returns a new Mesh
  77889. */
  77890. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  77891. /**
  77892. * Creates a tiled ground mesh.
  77893. * Please consider using the same method from the MeshBuilder class instead
  77894. * @param name defines the name of the mesh to create
  77895. * @param xmin set the ground minimum X coordinate
  77896. * @param zmin set the ground minimum Y coordinate
  77897. * @param xmax set the ground maximum X coordinate
  77898. * @param zmax set the ground maximum Z coordinate
  77899. * @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
  77900. * @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
  77901. * @param scene defines the hosting scene
  77902. * @param updatable defines if the mesh must be flagged as updatable
  77903. * @returns a new Mesh
  77904. */
  77905. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  77906. w: number;
  77907. h: number;
  77908. }, precision: {
  77909. w: number;
  77910. h: number;
  77911. }, scene: Scene, updatable?: boolean): Mesh;
  77912. /**
  77913. * Creates a ground mesh from a height map.
  77914. * Please consider using the same method from the MeshBuilder class instead
  77915. * @see http://doc.babylonjs.com/babylon101/height_map
  77916. * @param name defines the name of the mesh to create
  77917. * @param url sets the URL of the height map image resource
  77918. * @param width set the ground width size
  77919. * @param height set the ground height size
  77920. * @param subdivisions sets the number of subdivision per side
  77921. * @param minHeight is the minimum altitude on the ground
  77922. * @param maxHeight is the maximum altitude on the ground
  77923. * @param scene defines the hosting scene
  77924. * @param updatable defines if the mesh must be flagged as updatable
  77925. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  77926. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  77927. * @returns a new Mesh
  77928. */
  77929. 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;
  77930. /**
  77931. * Creates a tube mesh.
  77932. * The tube is a parametric shape.
  77933. * It has no predefined shape. Its final shape will depend on the input parameters.
  77934. * Please consider using the same method from the MeshBuilder class instead
  77935. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77936. * @param name defines the name of the mesh to create
  77937. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  77938. * @param radius sets the tube radius size
  77939. * @param tessellation is the number of sides on the tubular surface
  77940. * @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
  77941. * @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
  77942. * @param scene defines the hosting scene
  77943. * @param updatable defines if the mesh must be flagged as updatable
  77944. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77945. * @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)
  77946. * @returns a new Mesh
  77947. */
  77948. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  77949. (i: number, distance: number): number;
  77950. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77951. /**
  77952. * Creates a polyhedron mesh.
  77953. * Please consider using the same method from the MeshBuilder class instead.
  77954. * * 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
  77955. * * The parameter `size` (positive float, default 1) sets the polygon size
  77956. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  77957. * * 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`
  77958. * * 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
  77959. * * 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)`)
  77960. * * 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
  77961. * * 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
  77962. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77963. * * If you create a double-sided mesh, you can choose what parts of 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
  77964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77965. * @param name defines the name of the mesh to create
  77966. * @param options defines the options used to create the mesh
  77967. * @param scene defines the hosting scene
  77968. * @returns a new Mesh
  77969. */
  77970. static CreatePolyhedron(name: string, options: {
  77971. type?: number;
  77972. size?: number;
  77973. sizeX?: number;
  77974. sizeY?: number;
  77975. sizeZ?: number;
  77976. custom?: any;
  77977. faceUV?: Vector4[];
  77978. faceColors?: Color4[];
  77979. updatable?: boolean;
  77980. sideOrientation?: number;
  77981. }, scene: Scene): Mesh;
  77982. /**
  77983. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  77984. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  77985. * * 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`)
  77986. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  77987. * * 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
  77988. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77989. * * If you create a double-sided mesh, you can choose what parts of 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
  77990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77991. * @param name defines the name of the mesh
  77992. * @param options defines the options used to create the mesh
  77993. * @param scene defines the hosting scene
  77994. * @returns a new Mesh
  77995. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  77996. */
  77997. static CreateIcoSphere(name: string, options: {
  77998. radius?: number;
  77999. flat?: boolean;
  78000. subdivisions?: number;
  78001. sideOrientation?: number;
  78002. updatable?: boolean;
  78003. }, scene: Scene): Mesh;
  78004. /**
  78005. * Creates a decal mesh.
  78006. * Please consider using the same method from the MeshBuilder class instead.
  78007. * A decal is a mesh usually applied as a model onto the surface of another mesh
  78008. * @param name defines the name of the mesh
  78009. * @param sourceMesh defines the mesh receiving the decal
  78010. * @param position sets the position of the decal in world coordinates
  78011. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  78012. * @param size sets the decal scaling
  78013. * @param angle sets the angle to rotate the decal
  78014. * @returns a new Mesh
  78015. */
  78016. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  78017. /**
  78018. * Prepare internal position array for software CPU skinning
  78019. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  78020. */
  78021. setPositionsForCPUSkinning(): Float32Array;
  78022. /**
  78023. * Prepare internal normal array for software CPU skinning
  78024. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  78025. */
  78026. setNormalsForCPUSkinning(): Float32Array;
  78027. /**
  78028. * Updates the vertex buffer by applying transformation from the bones
  78029. * @param skeleton defines the skeleton to apply to current mesh
  78030. * @returns the current mesh
  78031. */
  78032. applySkeleton(skeleton: Skeleton): Mesh;
  78033. /**
  78034. * 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
  78035. * @param meshes defines the list of meshes to scan
  78036. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  78037. */
  78038. static MinMax(meshes: AbstractMesh[]): {
  78039. min: Vector3;
  78040. max: Vector3;
  78041. };
  78042. /**
  78043. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  78044. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  78045. * @returns a vector3
  78046. */
  78047. static Center(meshesOrMinMaxVector: {
  78048. min: Vector3;
  78049. max: Vector3;
  78050. } | AbstractMesh[]): Vector3;
  78051. /**
  78052. * Merge the array of meshes into a single mesh for performance reasons.
  78053. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  78054. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  78055. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  78056. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  78057. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  78058. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  78059. * @returns a new mesh
  78060. */
  78061. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  78062. /** @hidden */
  78063. addInstance(instance: InstancedMesh): void;
  78064. /** @hidden */
  78065. removeInstance(instance: InstancedMesh): void;
  78066. }
  78067. }
  78068. declare module BABYLON {
  78069. /**
  78070. * Interface used to define Action
  78071. */
  78072. export interface IAction {
  78073. /**
  78074. * Trigger for the action
  78075. */
  78076. trigger: number;
  78077. /** Options of the trigger */
  78078. triggerOptions: any;
  78079. /**
  78080. * Gets the trigger parameters
  78081. * @returns the trigger parameters
  78082. */
  78083. getTriggerParameter(): any;
  78084. /**
  78085. * Internal only - executes current action event
  78086. * @hidden
  78087. */
  78088. _executeCurrent(evt?: ActionEvent): void;
  78089. /**
  78090. * Serialize placeholder for child classes
  78091. * @param parent of child
  78092. * @returns the serialized object
  78093. */
  78094. serialize(parent: any): any;
  78095. /**
  78096. * Internal only
  78097. * @hidden
  78098. */
  78099. _prepare(): void;
  78100. /**
  78101. * Internal only - manager for action
  78102. * @hidden
  78103. */
  78104. _actionManager: AbstractActionManager;
  78105. /**
  78106. * Adds action to chain of actions, may be a DoNothingAction
  78107. * @param action defines the next action to execute
  78108. * @returns The action passed in
  78109. * @see https://www.babylonjs-playground.com/#1T30HR#0
  78110. */
  78111. then(action: IAction): IAction;
  78112. }
  78113. /**
  78114. * The action to be carried out following a trigger
  78115. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  78116. */
  78117. export class Action implements IAction {
  78118. /** the trigger, with or without parameters, for the action */
  78119. triggerOptions: any;
  78120. /**
  78121. * Trigger for the action
  78122. */
  78123. trigger: number;
  78124. /**
  78125. * Internal only - manager for action
  78126. * @hidden
  78127. */
  78128. _actionManager: ActionManager;
  78129. private _nextActiveAction;
  78130. private _child;
  78131. private _condition?;
  78132. private _triggerParameter;
  78133. /**
  78134. * An event triggered prior to action being executed.
  78135. */
  78136. onBeforeExecuteObservable: Observable<Action>;
  78137. /**
  78138. * Creates a new Action
  78139. * @param triggerOptions the trigger, with or without parameters, for the action
  78140. * @param condition an optional determinant of action
  78141. */
  78142. constructor(
  78143. /** the trigger, with or without parameters, for the action */
  78144. triggerOptions: any, condition?: Condition);
  78145. /**
  78146. * Internal only
  78147. * @hidden
  78148. */
  78149. _prepare(): void;
  78150. /**
  78151. * Gets the trigger parameters
  78152. * @returns the trigger parameters
  78153. */
  78154. getTriggerParameter(): any;
  78155. /**
  78156. * Internal only - executes current action event
  78157. * @hidden
  78158. */
  78159. _executeCurrent(evt?: ActionEvent): void;
  78160. /**
  78161. * Execute placeholder for child classes
  78162. * @param evt optional action event
  78163. */
  78164. execute(evt?: ActionEvent): void;
  78165. /**
  78166. * Skips to next active action
  78167. */
  78168. skipToNextActiveAction(): void;
  78169. /**
  78170. * Adds action to chain of actions, may be a DoNothingAction
  78171. * @param action defines the next action to execute
  78172. * @returns The action passed in
  78173. * @see https://www.babylonjs-playground.com/#1T30HR#0
  78174. */
  78175. then(action: Action): Action;
  78176. /**
  78177. * Internal only
  78178. * @hidden
  78179. */
  78180. _getProperty(propertyPath: string): string;
  78181. /**
  78182. * Internal only
  78183. * @hidden
  78184. */
  78185. _getEffectiveTarget(target: any, propertyPath: string): any;
  78186. /**
  78187. * Serialize placeholder for child classes
  78188. * @param parent of child
  78189. * @returns the serialized object
  78190. */
  78191. serialize(parent: any): any;
  78192. /**
  78193. * Internal only called by serialize
  78194. * @hidden
  78195. */
  78196. protected _serialize(serializedAction: any, parent?: any): any;
  78197. /**
  78198. * Internal only
  78199. * @hidden
  78200. */
  78201. static _SerializeValueAsString: (value: any) => string;
  78202. /**
  78203. * Internal only
  78204. * @hidden
  78205. */
  78206. static _GetTargetProperty: (target: Scene | Node) => {
  78207. name: string;
  78208. targetType: string;
  78209. value: string;
  78210. };
  78211. }
  78212. }
  78213. declare module BABYLON {
  78214. /**
  78215. * A Condition applied to an Action
  78216. */
  78217. export class Condition {
  78218. /**
  78219. * Internal only - manager for action
  78220. * @hidden
  78221. */
  78222. _actionManager: ActionManager;
  78223. /**
  78224. * Internal only
  78225. * @hidden
  78226. */
  78227. _evaluationId: number;
  78228. /**
  78229. * Internal only
  78230. * @hidden
  78231. */
  78232. _currentResult: boolean;
  78233. /**
  78234. * Creates a new Condition
  78235. * @param actionManager the manager of the action the condition is applied to
  78236. */
  78237. constructor(actionManager: ActionManager);
  78238. /**
  78239. * Check if the current condition is valid
  78240. * @returns a boolean
  78241. */
  78242. isValid(): boolean;
  78243. /**
  78244. * Internal only
  78245. * @hidden
  78246. */
  78247. _getProperty(propertyPath: string): string;
  78248. /**
  78249. * Internal only
  78250. * @hidden
  78251. */
  78252. _getEffectiveTarget(target: any, propertyPath: string): any;
  78253. /**
  78254. * Serialize placeholder for child classes
  78255. * @returns the serialized object
  78256. */
  78257. serialize(): any;
  78258. /**
  78259. * Internal only
  78260. * @hidden
  78261. */
  78262. protected _serialize(serializedCondition: any): any;
  78263. }
  78264. /**
  78265. * Defines specific conditional operators as extensions of Condition
  78266. */
  78267. export class ValueCondition extends Condition {
  78268. /** path to specify the property of the target the conditional operator uses */
  78269. propertyPath: string;
  78270. /** the value compared by the conditional operator against the current value of the property */
  78271. value: any;
  78272. /** the conditional operator, default ValueCondition.IsEqual */
  78273. operator: number;
  78274. /**
  78275. * Internal only
  78276. * @hidden
  78277. */
  78278. private static _IsEqual;
  78279. /**
  78280. * Internal only
  78281. * @hidden
  78282. */
  78283. private static _IsDifferent;
  78284. /**
  78285. * Internal only
  78286. * @hidden
  78287. */
  78288. private static _IsGreater;
  78289. /**
  78290. * Internal only
  78291. * @hidden
  78292. */
  78293. private static _IsLesser;
  78294. /**
  78295. * returns the number for IsEqual
  78296. */
  78297. static readonly IsEqual: number;
  78298. /**
  78299. * Returns the number for IsDifferent
  78300. */
  78301. static readonly IsDifferent: number;
  78302. /**
  78303. * Returns the number for IsGreater
  78304. */
  78305. static readonly IsGreater: number;
  78306. /**
  78307. * Returns the number for IsLesser
  78308. */
  78309. static readonly IsLesser: number;
  78310. /**
  78311. * Internal only The action manager for the condition
  78312. * @hidden
  78313. */
  78314. _actionManager: ActionManager;
  78315. /**
  78316. * Internal only
  78317. * @hidden
  78318. */
  78319. private _target;
  78320. /**
  78321. * Internal only
  78322. * @hidden
  78323. */
  78324. private _effectiveTarget;
  78325. /**
  78326. * Internal only
  78327. * @hidden
  78328. */
  78329. private _property;
  78330. /**
  78331. * Creates a new ValueCondition
  78332. * @param actionManager manager for the action the condition applies to
  78333. * @param target for the action
  78334. * @param propertyPath path to specify the property of the target the conditional operator uses
  78335. * @param value the value compared by the conditional operator against the current value of the property
  78336. * @param operator the conditional operator, default ValueCondition.IsEqual
  78337. */
  78338. constructor(actionManager: ActionManager, target: any,
  78339. /** path to specify the property of the target the conditional operator uses */
  78340. propertyPath: string,
  78341. /** the value compared by the conditional operator against the current value of the property */
  78342. value: any,
  78343. /** the conditional operator, default ValueCondition.IsEqual */
  78344. operator?: number);
  78345. /**
  78346. * Compares the given value with the property value for the specified conditional operator
  78347. * @returns the result of the comparison
  78348. */
  78349. isValid(): boolean;
  78350. /**
  78351. * Serialize the ValueCondition into a JSON compatible object
  78352. * @returns serialization object
  78353. */
  78354. serialize(): any;
  78355. /**
  78356. * Gets the name of the conditional operator for the ValueCondition
  78357. * @param operator the conditional operator
  78358. * @returns the name
  78359. */
  78360. static GetOperatorName(operator: number): string;
  78361. }
  78362. /**
  78363. * Defines a predicate condition as an extension of Condition
  78364. */
  78365. export class PredicateCondition extends Condition {
  78366. /** defines the predicate function used to validate the condition */
  78367. predicate: () => boolean;
  78368. /**
  78369. * Internal only - manager for action
  78370. * @hidden
  78371. */
  78372. _actionManager: ActionManager;
  78373. /**
  78374. * Creates a new PredicateCondition
  78375. * @param actionManager manager for the action the condition applies to
  78376. * @param predicate defines the predicate function used to validate the condition
  78377. */
  78378. constructor(actionManager: ActionManager,
  78379. /** defines the predicate function used to validate the condition */
  78380. predicate: () => boolean);
  78381. /**
  78382. * @returns the validity of the predicate condition
  78383. */
  78384. isValid(): boolean;
  78385. }
  78386. /**
  78387. * Defines a state condition as an extension of Condition
  78388. */
  78389. export class StateCondition extends Condition {
  78390. /** Value to compare with target state */
  78391. value: string;
  78392. /**
  78393. * Internal only - manager for action
  78394. * @hidden
  78395. */
  78396. _actionManager: ActionManager;
  78397. /**
  78398. * Internal only
  78399. * @hidden
  78400. */
  78401. private _target;
  78402. /**
  78403. * Creates a new StateCondition
  78404. * @param actionManager manager for the action the condition applies to
  78405. * @param target of the condition
  78406. * @param value to compare with target state
  78407. */
  78408. constructor(actionManager: ActionManager, target: any,
  78409. /** Value to compare with target state */
  78410. value: string);
  78411. /**
  78412. * Gets a boolean indicating if the current condition is met
  78413. * @returns the validity of the state
  78414. */
  78415. isValid(): boolean;
  78416. /**
  78417. * Serialize the StateCondition into a JSON compatible object
  78418. * @returns serialization object
  78419. */
  78420. serialize(): any;
  78421. }
  78422. }
  78423. declare module BABYLON {
  78424. /**
  78425. * This defines an action responsible to toggle a boolean once triggered.
  78426. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78427. */
  78428. export class SwitchBooleanAction extends Action {
  78429. /**
  78430. * The path to the boolean property in the target object
  78431. */
  78432. propertyPath: string;
  78433. private _target;
  78434. private _effectiveTarget;
  78435. private _property;
  78436. /**
  78437. * Instantiate the action
  78438. * @param triggerOptions defines the trigger options
  78439. * @param target defines the object containing the boolean
  78440. * @param propertyPath defines the path to the boolean property in the target object
  78441. * @param condition defines the trigger related conditions
  78442. */
  78443. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  78444. /** @hidden */
  78445. _prepare(): void;
  78446. /**
  78447. * Execute the action toggle the boolean value.
  78448. */
  78449. execute(): void;
  78450. /**
  78451. * Serializes the actions and its related information.
  78452. * @param parent defines the object to serialize in
  78453. * @returns the serialized object
  78454. */
  78455. serialize(parent: any): any;
  78456. }
  78457. /**
  78458. * This defines an action responsible to set a the state field of the target
  78459. * to a desired value once triggered.
  78460. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78461. */
  78462. export class SetStateAction extends Action {
  78463. /**
  78464. * The value to store in the state field.
  78465. */
  78466. value: string;
  78467. private _target;
  78468. /**
  78469. * Instantiate the action
  78470. * @param triggerOptions defines the trigger options
  78471. * @param target defines the object containing the state property
  78472. * @param value defines the value to store in the state field
  78473. * @param condition defines the trigger related conditions
  78474. */
  78475. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  78476. /**
  78477. * Execute the action and store the value on the target state property.
  78478. */
  78479. execute(): void;
  78480. /**
  78481. * Serializes the actions and its related information.
  78482. * @param parent defines the object to serialize in
  78483. * @returns the serialized object
  78484. */
  78485. serialize(parent: any): any;
  78486. }
  78487. /**
  78488. * This defines an action responsible to set a property of the target
  78489. * to a desired value once triggered.
  78490. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78491. */
  78492. export class SetValueAction extends Action {
  78493. /**
  78494. * The path of the property to set in the target.
  78495. */
  78496. propertyPath: string;
  78497. /**
  78498. * The value to set in the property
  78499. */
  78500. value: any;
  78501. private _target;
  78502. private _effectiveTarget;
  78503. private _property;
  78504. /**
  78505. * Instantiate the action
  78506. * @param triggerOptions defines the trigger options
  78507. * @param target defines the object containing the property
  78508. * @param propertyPath defines the path of the property to set in the target
  78509. * @param value defines the value to set in the property
  78510. * @param condition defines the trigger related conditions
  78511. */
  78512. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78513. /** @hidden */
  78514. _prepare(): void;
  78515. /**
  78516. * Execute the action and set the targetted property to the desired value.
  78517. */
  78518. execute(): void;
  78519. /**
  78520. * Serializes the actions and its related information.
  78521. * @param parent defines the object to serialize in
  78522. * @returns the serialized object
  78523. */
  78524. serialize(parent: any): any;
  78525. }
  78526. /**
  78527. * This defines an action responsible to increment the target value
  78528. * to a desired value once triggered.
  78529. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78530. */
  78531. export class IncrementValueAction extends Action {
  78532. /**
  78533. * The path of the property to increment in the target.
  78534. */
  78535. propertyPath: string;
  78536. /**
  78537. * The value we should increment the property by.
  78538. */
  78539. value: any;
  78540. private _target;
  78541. private _effectiveTarget;
  78542. private _property;
  78543. /**
  78544. * Instantiate the action
  78545. * @param triggerOptions defines the trigger options
  78546. * @param target defines the object containing the property
  78547. * @param propertyPath defines the path of the property to increment in the target
  78548. * @param value defines the value value we should increment the property by
  78549. * @param condition defines the trigger related conditions
  78550. */
  78551. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78552. /** @hidden */
  78553. _prepare(): void;
  78554. /**
  78555. * Execute the action and increment the target of the value amount.
  78556. */
  78557. execute(): void;
  78558. /**
  78559. * Serializes the actions and its related information.
  78560. * @param parent defines the object to serialize in
  78561. * @returns the serialized object
  78562. */
  78563. serialize(parent: any): any;
  78564. }
  78565. /**
  78566. * This defines an action responsible to start an animation once triggered.
  78567. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78568. */
  78569. export class PlayAnimationAction extends Action {
  78570. /**
  78571. * Where the animation should start (animation frame)
  78572. */
  78573. from: number;
  78574. /**
  78575. * Where the animation should stop (animation frame)
  78576. */
  78577. to: number;
  78578. /**
  78579. * Define if the animation should loop or stop after the first play.
  78580. */
  78581. loop?: boolean;
  78582. private _target;
  78583. /**
  78584. * Instantiate the action
  78585. * @param triggerOptions defines the trigger options
  78586. * @param target defines the target animation or animation name
  78587. * @param from defines from where the animation should start (animation frame)
  78588. * @param end defines where the animation should stop (animation frame)
  78589. * @param loop defines if the animation should loop or stop after the first play
  78590. * @param condition defines the trigger related conditions
  78591. */
  78592. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  78593. /** @hidden */
  78594. _prepare(): void;
  78595. /**
  78596. * Execute the action and play the animation.
  78597. */
  78598. execute(): void;
  78599. /**
  78600. * Serializes the actions and its related information.
  78601. * @param parent defines the object to serialize in
  78602. * @returns the serialized object
  78603. */
  78604. serialize(parent: any): any;
  78605. }
  78606. /**
  78607. * This defines an action responsible to stop an animation once triggered.
  78608. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78609. */
  78610. export class StopAnimationAction extends Action {
  78611. private _target;
  78612. /**
  78613. * Instantiate the action
  78614. * @param triggerOptions defines the trigger options
  78615. * @param target defines the target animation or animation name
  78616. * @param condition defines the trigger related conditions
  78617. */
  78618. constructor(triggerOptions: any, target: any, condition?: Condition);
  78619. /** @hidden */
  78620. _prepare(): void;
  78621. /**
  78622. * Execute the action and stop the animation.
  78623. */
  78624. execute(): void;
  78625. /**
  78626. * Serializes the actions and its related information.
  78627. * @param parent defines the object to serialize in
  78628. * @returns the serialized object
  78629. */
  78630. serialize(parent: any): any;
  78631. }
  78632. /**
  78633. * This defines an action responsible that does nothing once triggered.
  78634. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78635. */
  78636. export class DoNothingAction extends Action {
  78637. /**
  78638. * Instantiate the action
  78639. * @param triggerOptions defines the trigger options
  78640. * @param condition defines the trigger related conditions
  78641. */
  78642. constructor(triggerOptions?: any, condition?: Condition);
  78643. /**
  78644. * Execute the action and do nothing.
  78645. */
  78646. execute(): void;
  78647. /**
  78648. * Serializes the actions and its related information.
  78649. * @param parent defines the object to serialize in
  78650. * @returns the serialized object
  78651. */
  78652. serialize(parent: any): any;
  78653. }
  78654. /**
  78655. * This defines an action responsible to trigger several actions once triggered.
  78656. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78657. */
  78658. export class CombineAction extends Action {
  78659. /**
  78660. * The list of aggregated animations to run.
  78661. */
  78662. children: Action[];
  78663. /**
  78664. * Instantiate the action
  78665. * @param triggerOptions defines the trigger options
  78666. * @param children defines the list of aggregated animations to run
  78667. * @param condition defines the trigger related conditions
  78668. */
  78669. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  78670. /** @hidden */
  78671. _prepare(): void;
  78672. /**
  78673. * Execute the action and executes all the aggregated actions.
  78674. */
  78675. execute(evt: ActionEvent): void;
  78676. /**
  78677. * Serializes the actions and its related information.
  78678. * @param parent defines the object to serialize in
  78679. * @returns the serialized object
  78680. */
  78681. serialize(parent: any): any;
  78682. }
  78683. /**
  78684. * This defines an action responsible to run code (external event) once triggered.
  78685. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78686. */
  78687. export class ExecuteCodeAction extends Action {
  78688. /**
  78689. * The callback function to run.
  78690. */
  78691. func: (evt: ActionEvent) => void;
  78692. /**
  78693. * Instantiate the action
  78694. * @param triggerOptions defines the trigger options
  78695. * @param func defines the callback function to run
  78696. * @param condition defines the trigger related conditions
  78697. */
  78698. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  78699. /**
  78700. * Execute the action and run the attached code.
  78701. */
  78702. execute(evt: ActionEvent): void;
  78703. }
  78704. /**
  78705. * This defines an action responsible to set the parent property of the target once triggered.
  78706. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78707. */
  78708. export class SetParentAction extends Action {
  78709. private _parent;
  78710. private _target;
  78711. /**
  78712. * Instantiate the action
  78713. * @param triggerOptions defines the trigger options
  78714. * @param target defines the target containing the parent property
  78715. * @param parent defines from where the animation should start (animation frame)
  78716. * @param condition defines the trigger related conditions
  78717. */
  78718. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  78719. /** @hidden */
  78720. _prepare(): void;
  78721. /**
  78722. * Execute the action and set the parent property.
  78723. */
  78724. execute(): void;
  78725. /**
  78726. * Serializes the actions and its related information.
  78727. * @param parent defines the object to serialize in
  78728. * @returns the serialized object
  78729. */
  78730. serialize(parent: any): any;
  78731. }
  78732. }
  78733. declare module BABYLON {
  78734. /**
  78735. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  78736. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  78737. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78738. */
  78739. export class ActionManager extends AbstractActionManager {
  78740. /**
  78741. * Nothing
  78742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78743. */
  78744. static readonly NothingTrigger: number;
  78745. /**
  78746. * On pick
  78747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78748. */
  78749. static readonly OnPickTrigger: number;
  78750. /**
  78751. * On left pick
  78752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78753. */
  78754. static readonly OnLeftPickTrigger: number;
  78755. /**
  78756. * On right pick
  78757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78758. */
  78759. static readonly OnRightPickTrigger: number;
  78760. /**
  78761. * On center pick
  78762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78763. */
  78764. static readonly OnCenterPickTrigger: number;
  78765. /**
  78766. * On pick down
  78767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78768. */
  78769. static readonly OnPickDownTrigger: number;
  78770. /**
  78771. * On double pick
  78772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78773. */
  78774. static readonly OnDoublePickTrigger: number;
  78775. /**
  78776. * On pick up
  78777. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78778. */
  78779. static readonly OnPickUpTrigger: number;
  78780. /**
  78781. * On pick out.
  78782. * This trigger will only be raised if you also declared a OnPickDown
  78783. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78784. */
  78785. static readonly OnPickOutTrigger: number;
  78786. /**
  78787. * On long press
  78788. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78789. */
  78790. static readonly OnLongPressTrigger: number;
  78791. /**
  78792. * On pointer over
  78793. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78794. */
  78795. static readonly OnPointerOverTrigger: number;
  78796. /**
  78797. * On pointer out
  78798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78799. */
  78800. static readonly OnPointerOutTrigger: number;
  78801. /**
  78802. * On every frame
  78803. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78804. */
  78805. static readonly OnEveryFrameTrigger: number;
  78806. /**
  78807. * On intersection enter
  78808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78809. */
  78810. static readonly OnIntersectionEnterTrigger: number;
  78811. /**
  78812. * On intersection exit
  78813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78814. */
  78815. static readonly OnIntersectionExitTrigger: number;
  78816. /**
  78817. * On key down
  78818. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78819. */
  78820. static readonly OnKeyDownTrigger: number;
  78821. /**
  78822. * On key up
  78823. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78824. */
  78825. static readonly OnKeyUpTrigger: number;
  78826. private _scene;
  78827. /**
  78828. * Creates a new action manager
  78829. * @param scene defines the hosting scene
  78830. */
  78831. constructor(scene: Scene);
  78832. /**
  78833. * Releases all associated resources
  78834. */
  78835. dispose(): void;
  78836. /**
  78837. * Gets hosting scene
  78838. * @returns the hosting scene
  78839. */
  78840. getScene(): Scene;
  78841. /**
  78842. * Does this action manager handles actions of any of the given triggers
  78843. * @param triggers defines the triggers to be tested
  78844. * @return a boolean indicating whether one (or more) of the triggers is handled
  78845. */
  78846. hasSpecificTriggers(triggers: number[]): boolean;
  78847. /**
  78848. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  78849. * speed.
  78850. * @param triggerA defines the trigger to be tested
  78851. * @param triggerB defines the trigger to be tested
  78852. * @return a boolean indicating whether one (or more) of the triggers is handled
  78853. */
  78854. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  78855. /**
  78856. * Does this action manager handles actions of a given trigger
  78857. * @param trigger defines the trigger to be tested
  78858. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  78859. * @return whether the trigger is handled
  78860. */
  78861. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  78862. /**
  78863. * Does this action manager has pointer triggers
  78864. */
  78865. readonly hasPointerTriggers: boolean;
  78866. /**
  78867. * Does this action manager has pick triggers
  78868. */
  78869. readonly hasPickTriggers: boolean;
  78870. /**
  78871. * Registers an action to this action manager
  78872. * @param action defines the action to be registered
  78873. * @return the action amended (prepared) after registration
  78874. */
  78875. registerAction(action: IAction): Nullable<IAction>;
  78876. /**
  78877. * Unregisters an action to this action manager
  78878. * @param action defines the action to be unregistered
  78879. * @return a boolean indicating whether the action has been unregistered
  78880. */
  78881. unregisterAction(action: IAction): Boolean;
  78882. /**
  78883. * Process a specific trigger
  78884. * @param trigger defines the trigger to process
  78885. * @param evt defines the event details to be processed
  78886. */
  78887. processTrigger(trigger: number, evt?: IActionEvent): void;
  78888. /** @hidden */
  78889. _getEffectiveTarget(target: any, propertyPath: string): any;
  78890. /** @hidden */
  78891. _getProperty(propertyPath: string): string;
  78892. /**
  78893. * Serialize this manager to a JSON object
  78894. * @param name defines the property name to store this manager
  78895. * @returns a JSON representation of this manager
  78896. */
  78897. serialize(name: string): any;
  78898. /**
  78899. * Creates a new ActionManager from a JSON data
  78900. * @param parsedActions defines the JSON data to read from
  78901. * @param object defines the hosting mesh
  78902. * @param scene defines the hosting scene
  78903. */
  78904. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  78905. /**
  78906. * Get a trigger name by index
  78907. * @param trigger defines the trigger index
  78908. * @returns a trigger name
  78909. */
  78910. static GetTriggerName(trigger: number): string;
  78911. }
  78912. }
  78913. declare module BABYLON {
  78914. /**
  78915. * Class representing a ray with position and direction
  78916. */
  78917. export class Ray {
  78918. /** origin point */
  78919. origin: Vector3;
  78920. /** direction */
  78921. direction: Vector3;
  78922. /** length of the ray */
  78923. length: number;
  78924. private static readonly TmpVector3;
  78925. private _tmpRay;
  78926. /**
  78927. * Creates a new ray
  78928. * @param origin origin point
  78929. * @param direction direction
  78930. * @param length length of the ray
  78931. */
  78932. constructor(
  78933. /** origin point */
  78934. origin: Vector3,
  78935. /** direction */
  78936. direction: Vector3,
  78937. /** length of the ray */
  78938. length?: number);
  78939. /**
  78940. * Checks if the ray intersects a box
  78941. * @param minimum bound of the box
  78942. * @param maximum bound of the box
  78943. * @param intersectionTreshold extra extend to be added to the box in all direction
  78944. * @returns if the box was hit
  78945. */
  78946. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  78947. /**
  78948. * Checks if the ray intersects a box
  78949. * @param box the bounding box to check
  78950. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  78951. * @returns if the box was hit
  78952. */
  78953. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  78954. /**
  78955. * If the ray hits a sphere
  78956. * @param sphere the bounding sphere to check
  78957. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  78958. * @returns true if it hits the sphere
  78959. */
  78960. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  78961. /**
  78962. * If the ray hits a triange
  78963. * @param vertex0 triangle vertex
  78964. * @param vertex1 triangle vertex
  78965. * @param vertex2 triangle vertex
  78966. * @returns intersection information if hit
  78967. */
  78968. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  78969. /**
  78970. * Checks if ray intersects a plane
  78971. * @param plane the plane to check
  78972. * @returns the distance away it was hit
  78973. */
  78974. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  78975. /**
  78976. * Checks if ray intersects a mesh
  78977. * @param mesh the mesh to check
  78978. * @param fastCheck if only the bounding box should checked
  78979. * @returns picking info of the intersecton
  78980. */
  78981. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  78982. /**
  78983. * Checks if ray intersects a mesh
  78984. * @param meshes the meshes to check
  78985. * @param fastCheck if only the bounding box should checked
  78986. * @param results array to store result in
  78987. * @returns Array of picking infos
  78988. */
  78989. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  78990. private _comparePickingInfo;
  78991. private static smallnum;
  78992. private static rayl;
  78993. /**
  78994. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  78995. * @param sega the first point of the segment to test the intersection against
  78996. * @param segb the second point of the segment to test the intersection against
  78997. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  78998. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  78999. */
  79000. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  79001. /**
  79002. * Update the ray from viewport position
  79003. * @param x position
  79004. * @param y y position
  79005. * @param viewportWidth viewport width
  79006. * @param viewportHeight viewport height
  79007. * @param world world matrix
  79008. * @param view view matrix
  79009. * @param projection projection matrix
  79010. * @returns this ray updated
  79011. */
  79012. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  79013. /**
  79014. * Creates a ray with origin and direction of 0,0,0
  79015. * @returns the new ray
  79016. */
  79017. static Zero(): Ray;
  79018. /**
  79019. * Creates a new ray from screen space and viewport
  79020. * @param x position
  79021. * @param y y position
  79022. * @param viewportWidth viewport width
  79023. * @param viewportHeight viewport height
  79024. * @param world world matrix
  79025. * @param view view matrix
  79026. * @param projection projection matrix
  79027. * @returns new ray
  79028. */
  79029. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  79030. /**
  79031. * 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
  79032. * transformed to the given world matrix.
  79033. * @param origin The origin point
  79034. * @param end The end point
  79035. * @param world a matrix to transform the ray to. Default is the identity matrix.
  79036. * @returns the new ray
  79037. */
  79038. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  79039. /**
  79040. * Transforms a ray by a matrix
  79041. * @param ray ray to transform
  79042. * @param matrix matrix to apply
  79043. * @returns the resulting new ray
  79044. */
  79045. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  79046. /**
  79047. * Transforms a ray by a matrix
  79048. * @param ray ray to transform
  79049. * @param matrix matrix to apply
  79050. * @param result ray to store result in
  79051. */
  79052. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  79053. /**
  79054. * Unproject a ray from screen space to object space
  79055. * @param sourceX defines the screen space x coordinate to use
  79056. * @param sourceY defines the screen space y coordinate to use
  79057. * @param viewportWidth defines the current width of the viewport
  79058. * @param viewportHeight defines the current height of the viewport
  79059. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  79060. * @param view defines the view matrix to use
  79061. * @param projection defines the projection matrix to use
  79062. */
  79063. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  79064. }
  79065. /**
  79066. * Type used to define predicate used to select faces when a mesh intersection is detected
  79067. */
  79068. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  79069. interface Scene {
  79070. /** @hidden */
  79071. _tempPickingRay: Nullable<Ray>;
  79072. /** @hidden */
  79073. _cachedRayForTransform: Ray;
  79074. /** @hidden */
  79075. _pickWithRayInverseMatrix: Matrix;
  79076. /** @hidden */
  79077. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  79078. /** @hidden */
  79079. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  79080. }
  79081. }
  79082. declare module BABYLON {
  79083. interface Scene {
  79084. /** @hidden */
  79085. _pointerOverSprite: Nullable<Sprite>;
  79086. /** @hidden */
  79087. _pickedDownSprite: Nullable<Sprite>;
  79088. /** @hidden */
  79089. _tempSpritePickingRay: Nullable<Ray>;
  79090. /**
  79091. * All of the sprite managers added to this scene
  79092. * @see http://doc.babylonjs.com/babylon101/sprites
  79093. */
  79094. spriteManagers: Array<ISpriteManager>;
  79095. /**
  79096. * An event triggered when sprites rendering is about to start
  79097. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  79098. */
  79099. onBeforeSpritesRenderingObservable: Observable<Scene>;
  79100. /**
  79101. * An event triggered when sprites rendering is done
  79102. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  79103. */
  79104. onAfterSpritesRenderingObservable: Observable<Scene>;
  79105. /** @hidden */
  79106. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79107. /** Launch a ray to try to pick a sprite in the scene
  79108. * @param x position on screen
  79109. * @param y position on screen
  79110. * @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
  79111. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  79112. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  79113. * @returns a PickingInfo
  79114. */
  79115. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79116. /** Use the given ray to pick a sprite in the scene
  79117. * @param ray The ray (in world space) to use to pick meshes
  79118. * @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
  79119. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  79120. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  79121. * @returns a PickingInfo
  79122. */
  79123. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79124. /**
  79125. * Force the sprite under the pointer
  79126. * @param sprite defines the sprite to use
  79127. */
  79128. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  79129. /**
  79130. * Gets the sprite under the pointer
  79131. * @returns a Sprite or null if no sprite is under the pointer
  79132. */
  79133. getPointerOverSprite(): Nullable<Sprite>;
  79134. }
  79135. /**
  79136. * Defines the sprite scene component responsible to manage sprites
  79137. * in a given scene.
  79138. */
  79139. export class SpriteSceneComponent implements ISceneComponent {
  79140. /**
  79141. * The component name helpfull to identify the component in the list of scene components.
  79142. */
  79143. readonly name: string;
  79144. /**
  79145. * The scene the component belongs to.
  79146. */
  79147. scene: Scene;
  79148. /** @hidden */
  79149. private _spritePredicate;
  79150. /**
  79151. * Creates a new instance of the component for the given scene
  79152. * @param scene Defines the scene to register the component in
  79153. */
  79154. constructor(scene: Scene);
  79155. /**
  79156. * Registers the component in a given scene
  79157. */
  79158. register(): void;
  79159. /**
  79160. * Rebuilds the elements related to this component in case of
  79161. * context lost for instance.
  79162. */
  79163. rebuild(): void;
  79164. /**
  79165. * Disposes the component and the associated ressources.
  79166. */
  79167. dispose(): void;
  79168. private _pickSpriteButKeepRay;
  79169. private _pointerMove;
  79170. private _pointerDown;
  79171. private _pointerUp;
  79172. }
  79173. }
  79174. declare module BABYLON {
  79175. /** @hidden */
  79176. export var fogFragmentDeclaration: {
  79177. name: string;
  79178. shader: string;
  79179. };
  79180. }
  79181. declare module BABYLON {
  79182. /** @hidden */
  79183. export var fogFragment: {
  79184. name: string;
  79185. shader: string;
  79186. };
  79187. }
  79188. declare module BABYLON {
  79189. /** @hidden */
  79190. export var spritesPixelShader: {
  79191. name: string;
  79192. shader: string;
  79193. };
  79194. }
  79195. declare module BABYLON {
  79196. /** @hidden */
  79197. export var fogVertexDeclaration: {
  79198. name: string;
  79199. shader: string;
  79200. };
  79201. }
  79202. declare module BABYLON {
  79203. /** @hidden */
  79204. export var spritesVertexShader: {
  79205. name: string;
  79206. shader: string;
  79207. };
  79208. }
  79209. declare module BABYLON {
  79210. /**
  79211. * Defines the minimum interface to fullfil in order to be a sprite manager.
  79212. */
  79213. export interface ISpriteManager extends IDisposable {
  79214. /**
  79215. * Restricts the camera to viewing objects with the same layerMask.
  79216. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  79217. */
  79218. layerMask: number;
  79219. /**
  79220. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  79221. */
  79222. isPickable: boolean;
  79223. /**
  79224. * Specifies the rendering group id for this mesh (0 by default)
  79225. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  79226. */
  79227. renderingGroupId: number;
  79228. /**
  79229. * Defines the list of sprites managed by the manager.
  79230. */
  79231. sprites: Array<Sprite>;
  79232. /**
  79233. * Tests the intersection of a sprite with a specific ray.
  79234. * @param ray The ray we are sending to test the collision
  79235. * @param camera The camera space we are sending rays in
  79236. * @param predicate A predicate allowing excluding sprites from the list of object to test
  79237. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  79238. * @returns picking info or null.
  79239. */
  79240. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79241. /**
  79242. * Renders the list of sprites on screen.
  79243. */
  79244. render(): void;
  79245. }
  79246. /**
  79247. * Class used to manage multiple sprites on the same spritesheet
  79248. * @see http://doc.babylonjs.com/babylon101/sprites
  79249. */
  79250. export class SpriteManager implements ISpriteManager {
  79251. /** defines the manager's name */
  79252. name: string;
  79253. /** Gets the list of sprites */
  79254. sprites: Sprite[];
  79255. /** Gets or sets the rendering group id (0 by default) */
  79256. renderingGroupId: number;
  79257. /** Gets or sets camera layer mask */
  79258. layerMask: number;
  79259. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  79260. fogEnabled: boolean;
  79261. /** Gets or sets a boolean indicating if the sprites are pickable */
  79262. isPickable: boolean;
  79263. /** Defines the default width of a cell in the spritesheet */
  79264. cellWidth: number;
  79265. /** Defines the default height of a cell in the spritesheet */
  79266. cellHeight: number;
  79267. /**
  79268. * An event triggered when the manager is disposed.
  79269. */
  79270. onDisposeObservable: Observable<SpriteManager>;
  79271. private _onDisposeObserver;
  79272. /**
  79273. * Callback called when the manager is disposed
  79274. */
  79275. onDispose: () => void;
  79276. private _capacity;
  79277. private _spriteTexture;
  79278. private _epsilon;
  79279. private _scene;
  79280. private _vertexData;
  79281. private _buffer;
  79282. private _vertexBuffers;
  79283. private _indexBuffer;
  79284. private _effectBase;
  79285. private _effectFog;
  79286. /**
  79287. * Gets or sets the spritesheet texture
  79288. */
  79289. texture: Texture;
  79290. /**
  79291. * Creates a new sprite manager
  79292. * @param name defines the manager's name
  79293. * @param imgUrl defines the sprite sheet url
  79294. * @param capacity defines the maximum allowed number of sprites
  79295. * @param cellSize defines the size of a sprite cell
  79296. * @param scene defines the hosting scene
  79297. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  79298. * @param samplingMode defines the smapling mode to use with spritesheet
  79299. */
  79300. constructor(
  79301. /** defines the manager's name */
  79302. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  79303. private _appendSpriteVertex;
  79304. /**
  79305. * Intersects the sprites with a ray
  79306. * @param ray defines the ray to intersect with
  79307. * @param camera defines the current active camera
  79308. * @param predicate defines a predicate used to select candidate sprites
  79309. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  79310. * @returns null if no hit or a PickingInfo
  79311. */
  79312. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79313. /**
  79314. * Render all child sprites
  79315. */
  79316. render(): void;
  79317. /**
  79318. * Release associated resources
  79319. */
  79320. dispose(): void;
  79321. }
  79322. }
  79323. declare module BABYLON {
  79324. /**
  79325. * Class used to represent a sprite
  79326. * @see http://doc.babylonjs.com/babylon101/sprites
  79327. */
  79328. export class Sprite {
  79329. /** defines the name */
  79330. name: string;
  79331. /** Gets or sets the current world position */
  79332. position: Vector3;
  79333. /** Gets or sets the main color */
  79334. color: Color4;
  79335. /** Gets or sets the width */
  79336. width: number;
  79337. /** Gets or sets the height */
  79338. height: number;
  79339. /** Gets or sets rotation angle */
  79340. angle: number;
  79341. /** Gets or sets the cell index in the sprite sheet */
  79342. cellIndex: number;
  79343. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  79344. invertU: number;
  79345. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  79346. invertV: number;
  79347. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  79348. disposeWhenFinishedAnimating: boolean;
  79349. /** Gets the list of attached animations */
  79350. animations: Animation[];
  79351. /** Gets or sets a boolean indicating if the sprite can be picked */
  79352. isPickable: boolean;
  79353. /**
  79354. * Gets or sets the associated action manager
  79355. */
  79356. actionManager: Nullable<ActionManager>;
  79357. private _animationStarted;
  79358. private _loopAnimation;
  79359. private _fromIndex;
  79360. private _toIndex;
  79361. private _delay;
  79362. private _direction;
  79363. private _manager;
  79364. private _time;
  79365. private _onAnimationEnd;
  79366. /**
  79367. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  79368. */
  79369. isVisible: boolean;
  79370. /**
  79371. * Gets or sets the sprite size
  79372. */
  79373. size: number;
  79374. /**
  79375. * Creates a new Sprite
  79376. * @param name defines the name
  79377. * @param manager defines the manager
  79378. */
  79379. constructor(
  79380. /** defines the name */
  79381. name: string, manager: ISpriteManager);
  79382. /**
  79383. * Starts an animation
  79384. * @param from defines the initial key
  79385. * @param to defines the end key
  79386. * @param loop defines if the animation must loop
  79387. * @param delay defines the start delay (in ms)
  79388. * @param onAnimationEnd defines a callback to call when animation ends
  79389. */
  79390. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  79391. /** Stops current animation (if any) */
  79392. stopAnimation(): void;
  79393. /** @hidden */
  79394. _animate(deltaTime: number): void;
  79395. /** Release associated resources */
  79396. dispose(): void;
  79397. }
  79398. }
  79399. declare module BABYLON {
  79400. /**
  79401. * Information about the result of picking within a scene
  79402. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  79403. */
  79404. export class PickingInfo {
  79405. /** @hidden */
  79406. _pickingUnavailable: boolean;
  79407. /**
  79408. * If the pick collided with an object
  79409. */
  79410. hit: boolean;
  79411. /**
  79412. * Distance away where the pick collided
  79413. */
  79414. distance: number;
  79415. /**
  79416. * The location of pick collision
  79417. */
  79418. pickedPoint: Nullable<Vector3>;
  79419. /**
  79420. * The mesh corresponding the the pick collision
  79421. */
  79422. pickedMesh: Nullable<AbstractMesh>;
  79423. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  79424. bu: number;
  79425. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  79426. bv: number;
  79427. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  79428. faceId: number;
  79429. /** Id of the the submesh that was picked */
  79430. subMeshId: number;
  79431. /** If a sprite was picked, this will be the sprite the pick collided with */
  79432. pickedSprite: Nullable<Sprite>;
  79433. /**
  79434. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  79435. */
  79436. originMesh: Nullable<AbstractMesh>;
  79437. /**
  79438. * The ray that was used to perform the picking.
  79439. */
  79440. ray: Nullable<Ray>;
  79441. /**
  79442. * Gets the normal correspodning to the face the pick collided with
  79443. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  79444. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  79445. * @returns The normal correspodning to the face the pick collided with
  79446. */
  79447. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  79448. /**
  79449. * Gets the texture coordinates of where the pick occured
  79450. * @returns the vector containing the coordnates of the texture
  79451. */
  79452. getTextureCoordinates(): Nullable<Vector2>;
  79453. }
  79454. }
  79455. declare module BABYLON {
  79456. /**
  79457. * Gather the list of pointer event types as constants.
  79458. */
  79459. export class PointerEventTypes {
  79460. /**
  79461. * 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.
  79462. */
  79463. static readonly POINTERDOWN: number;
  79464. /**
  79465. * The pointerup event is fired when a pointer is no longer active.
  79466. */
  79467. static readonly POINTERUP: number;
  79468. /**
  79469. * The pointermove event is fired when a pointer changes coordinates.
  79470. */
  79471. static readonly POINTERMOVE: number;
  79472. /**
  79473. * The pointerwheel event is fired when a mouse wheel has been rotated.
  79474. */
  79475. static readonly POINTERWHEEL: number;
  79476. /**
  79477. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  79478. */
  79479. static readonly POINTERPICK: number;
  79480. /**
  79481. * The pointertap event is fired when a the object has been touched and released without drag.
  79482. */
  79483. static readonly POINTERTAP: number;
  79484. /**
  79485. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  79486. */
  79487. static readonly POINTERDOUBLETAP: number;
  79488. }
  79489. /**
  79490. * Base class of pointer info types.
  79491. */
  79492. export class PointerInfoBase {
  79493. /**
  79494. * Defines the type of event (PointerEventTypes)
  79495. */
  79496. type: number;
  79497. /**
  79498. * Defines the related dom event
  79499. */
  79500. event: PointerEvent | MouseWheelEvent;
  79501. /**
  79502. * Instantiates the base class of pointers info.
  79503. * @param type Defines the type of event (PointerEventTypes)
  79504. * @param event Defines the related dom event
  79505. */
  79506. constructor(
  79507. /**
  79508. * Defines the type of event (PointerEventTypes)
  79509. */
  79510. type: number,
  79511. /**
  79512. * Defines the related dom event
  79513. */
  79514. event: PointerEvent | MouseWheelEvent);
  79515. }
  79516. /**
  79517. * This class is used to store pointer related info for the onPrePointerObservable event.
  79518. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  79519. */
  79520. export class PointerInfoPre extends PointerInfoBase {
  79521. /**
  79522. * Ray from a pointer if availible (eg. 6dof controller)
  79523. */
  79524. ray: Nullable<Ray>;
  79525. /**
  79526. * Defines the local position of the pointer on the canvas.
  79527. */
  79528. localPosition: Vector2;
  79529. /**
  79530. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  79531. */
  79532. skipOnPointerObservable: boolean;
  79533. /**
  79534. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  79535. * @param type Defines the type of event (PointerEventTypes)
  79536. * @param event Defines the related dom event
  79537. * @param localX Defines the local x coordinates of the pointer when the event occured
  79538. * @param localY Defines the local y coordinates of the pointer when the event occured
  79539. */
  79540. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  79541. }
  79542. /**
  79543. * This type contains all the data related to a pointer event in Babylon.js.
  79544. * 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.
  79545. */
  79546. export class PointerInfo extends PointerInfoBase {
  79547. /**
  79548. * Defines the picking info associated to the info (if any)\
  79549. */
  79550. pickInfo: Nullable<PickingInfo>;
  79551. /**
  79552. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  79553. * @param type Defines the type of event (PointerEventTypes)
  79554. * @param event Defines the related dom event
  79555. * @param pickInfo Defines the picking info associated to the info (if any)\
  79556. */
  79557. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  79558. /**
  79559. * Defines the picking info associated to the info (if any)\
  79560. */
  79561. pickInfo: Nullable<PickingInfo>);
  79562. }
  79563. /**
  79564. * Data relating to a touch event on the screen.
  79565. */
  79566. export interface PointerTouch {
  79567. /**
  79568. * X coordinate of touch.
  79569. */
  79570. x: number;
  79571. /**
  79572. * Y coordinate of touch.
  79573. */
  79574. y: number;
  79575. /**
  79576. * Id of touch. Unique for each finger.
  79577. */
  79578. pointerId: number;
  79579. /**
  79580. * Event type passed from DOM.
  79581. */
  79582. type: any;
  79583. }
  79584. }
  79585. declare module BABYLON {
  79586. /**
  79587. * Manage the mouse inputs to control the movement of a free camera.
  79588. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79589. */
  79590. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  79591. /**
  79592. * Define if touch is enabled in the mouse input
  79593. */
  79594. touchEnabled: boolean;
  79595. /**
  79596. * Defines the camera the input is attached to.
  79597. */
  79598. camera: FreeCamera;
  79599. /**
  79600. * Defines the buttons associated with the input to handle camera move.
  79601. */
  79602. buttons: number[];
  79603. /**
  79604. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  79605. */
  79606. angularSensibility: number;
  79607. private _pointerInput;
  79608. private _onMouseMove;
  79609. private _observer;
  79610. private previousPosition;
  79611. /**
  79612. * Observable for when a pointer move event occurs containing the move offset
  79613. */
  79614. onPointerMovedObservable: Observable<{
  79615. offsetX: number;
  79616. offsetY: number;
  79617. }>;
  79618. /**
  79619. * @hidden
  79620. * If the camera should be rotated automatically based on pointer movement
  79621. */
  79622. _allowCameraRotation: boolean;
  79623. /**
  79624. * Manage the mouse inputs to control the movement of a free camera.
  79625. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79626. * @param touchEnabled Defines if touch is enabled or not
  79627. */
  79628. constructor(
  79629. /**
  79630. * Define if touch is enabled in the mouse input
  79631. */
  79632. touchEnabled?: boolean);
  79633. /**
  79634. * Attach the input controls to a specific dom element to get the input from.
  79635. * @param element Defines the element the controls should be listened from
  79636. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79637. */
  79638. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79639. /**
  79640. * Called on JS contextmenu event.
  79641. * Override this method to provide functionality.
  79642. */
  79643. protected onContextMenu(evt: PointerEvent): void;
  79644. /**
  79645. * Detach the current controls from the specified dom element.
  79646. * @param element Defines the element to stop listening the inputs from
  79647. */
  79648. detachControl(element: Nullable<HTMLElement>): void;
  79649. /**
  79650. * Gets the class name of the current intput.
  79651. * @returns the class name
  79652. */
  79653. getClassName(): string;
  79654. /**
  79655. * Get the friendly name associated with the input class.
  79656. * @returns the input friendly name
  79657. */
  79658. getSimpleName(): string;
  79659. }
  79660. }
  79661. declare module BABYLON {
  79662. /**
  79663. * Manage the touch inputs to control the movement of a free camera.
  79664. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79665. */
  79666. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  79667. /**
  79668. * Defines the camera the input is attached to.
  79669. */
  79670. camera: FreeCamera;
  79671. /**
  79672. * Defines the touch sensibility for rotation.
  79673. * The higher the faster.
  79674. */
  79675. touchAngularSensibility: number;
  79676. /**
  79677. * Defines the touch sensibility for move.
  79678. * The higher the faster.
  79679. */
  79680. touchMoveSensibility: number;
  79681. private _offsetX;
  79682. private _offsetY;
  79683. private _pointerPressed;
  79684. private _pointerInput;
  79685. private _observer;
  79686. private _onLostFocus;
  79687. /**
  79688. * Attach the input controls to a specific dom element to get the input from.
  79689. * @param element Defines the element the controls should be listened from
  79690. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79691. */
  79692. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79693. /**
  79694. * Detach the current controls from the specified dom element.
  79695. * @param element Defines the element to stop listening the inputs from
  79696. */
  79697. detachControl(element: Nullable<HTMLElement>): void;
  79698. /**
  79699. * Update the current camera state depending on the inputs that have been used this frame.
  79700. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79701. */
  79702. checkInputs(): void;
  79703. /**
  79704. * Gets the class name of the current intput.
  79705. * @returns the class name
  79706. */
  79707. getClassName(): string;
  79708. /**
  79709. * Get the friendly name associated with the input class.
  79710. * @returns the input friendly name
  79711. */
  79712. getSimpleName(): string;
  79713. }
  79714. }
  79715. declare module BABYLON {
  79716. /**
  79717. * Default Inputs manager for the FreeCamera.
  79718. * It groups all the default supported inputs for ease of use.
  79719. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79720. */
  79721. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  79722. /**
  79723. * @hidden
  79724. */
  79725. _mouseInput: Nullable<FreeCameraMouseInput>;
  79726. /**
  79727. * Instantiates a new FreeCameraInputsManager.
  79728. * @param camera Defines the camera the inputs belong to
  79729. */
  79730. constructor(camera: FreeCamera);
  79731. /**
  79732. * Add keyboard input support to the input manager.
  79733. * @returns the current input manager
  79734. */
  79735. addKeyboard(): FreeCameraInputsManager;
  79736. /**
  79737. * Add mouse input support to the input manager.
  79738. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  79739. * @returns the current input manager
  79740. */
  79741. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  79742. /**
  79743. * Removes the mouse input support from the manager
  79744. * @returns the current input manager
  79745. */
  79746. removeMouse(): FreeCameraInputsManager;
  79747. /**
  79748. * Add touch input support to the input manager.
  79749. * @returns the current input manager
  79750. */
  79751. addTouch(): FreeCameraInputsManager;
  79752. /**
  79753. * Remove all attached input methods from a camera
  79754. */
  79755. clear(): void;
  79756. }
  79757. }
  79758. declare module BABYLON {
  79759. /**
  79760. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79761. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  79762. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79763. */
  79764. export class FreeCamera extends TargetCamera {
  79765. /**
  79766. * Define the collision ellipsoid of the camera.
  79767. * This is helpful to simulate a camera body like the player body around the camera
  79768. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  79769. */
  79770. ellipsoid: Vector3;
  79771. /**
  79772. * Define an offset for the position of the ellipsoid around the camera.
  79773. * This can be helpful to determine the center of the body near the gravity center of the body
  79774. * instead of its head.
  79775. */
  79776. ellipsoidOffset: Vector3;
  79777. /**
  79778. * Enable or disable collisions of the camera with the rest of the scene objects.
  79779. */
  79780. checkCollisions: boolean;
  79781. /**
  79782. * Enable or disable gravity on the camera.
  79783. */
  79784. applyGravity: boolean;
  79785. /**
  79786. * Define the input manager associated to the camera.
  79787. */
  79788. inputs: FreeCameraInputsManager;
  79789. /**
  79790. * Gets the input sensibility for a mouse input. (default is 2000.0)
  79791. * Higher values reduce sensitivity.
  79792. */
  79793. /**
  79794. * Sets the input sensibility for a mouse input. (default is 2000.0)
  79795. * Higher values reduce sensitivity.
  79796. */
  79797. angularSensibility: number;
  79798. /**
  79799. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  79800. */
  79801. keysUp: number[];
  79802. /**
  79803. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  79804. */
  79805. keysDown: number[];
  79806. /**
  79807. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  79808. */
  79809. keysLeft: number[];
  79810. /**
  79811. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  79812. */
  79813. keysRight: number[];
  79814. /**
  79815. * Event raised when the camera collide with a mesh in the scene.
  79816. */
  79817. onCollide: (collidedMesh: AbstractMesh) => void;
  79818. private _collider;
  79819. private _needMoveForGravity;
  79820. private _oldPosition;
  79821. private _diffPosition;
  79822. private _newPosition;
  79823. /** @hidden */
  79824. _localDirection: Vector3;
  79825. /** @hidden */
  79826. _transformedDirection: Vector3;
  79827. /**
  79828. * Instantiates a Free Camera.
  79829. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79830. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  79831. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79832. * @param name Define the name of the camera in the scene
  79833. * @param position Define the start position of the camera in the scene
  79834. * @param scene Define the scene the camera belongs to
  79835. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  79836. */
  79837. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  79838. /**
  79839. * Attached controls to the current camera.
  79840. * @param element Defines the element the controls should be listened from
  79841. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79842. */
  79843. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79844. /**
  79845. * Detach the current controls from the camera.
  79846. * The camera will stop reacting to inputs.
  79847. * @param element Defines the element to stop listening the inputs from
  79848. */
  79849. detachControl(element: HTMLElement): void;
  79850. private _collisionMask;
  79851. /**
  79852. * Define a collision mask to limit the list of object the camera can collide with
  79853. */
  79854. collisionMask: number;
  79855. /** @hidden */
  79856. _collideWithWorld(displacement: Vector3): void;
  79857. private _onCollisionPositionChange;
  79858. /** @hidden */
  79859. _checkInputs(): void;
  79860. /** @hidden */
  79861. _decideIfNeedsToMove(): boolean;
  79862. /** @hidden */
  79863. _updatePosition(): void;
  79864. /**
  79865. * Destroy the camera and release the current resources hold by it.
  79866. */
  79867. dispose(): void;
  79868. /**
  79869. * Gets the current object class name.
  79870. * @return the class name
  79871. */
  79872. getClassName(): string;
  79873. }
  79874. }
  79875. declare module BABYLON {
  79876. /**
  79877. * Represents a gamepad control stick position
  79878. */
  79879. export class StickValues {
  79880. /**
  79881. * The x component of the control stick
  79882. */
  79883. x: number;
  79884. /**
  79885. * The y component of the control stick
  79886. */
  79887. y: number;
  79888. /**
  79889. * Initializes the gamepad x and y control stick values
  79890. * @param x The x component of the gamepad control stick value
  79891. * @param y The y component of the gamepad control stick value
  79892. */
  79893. constructor(
  79894. /**
  79895. * The x component of the control stick
  79896. */
  79897. x: number,
  79898. /**
  79899. * The y component of the control stick
  79900. */
  79901. y: number);
  79902. }
  79903. /**
  79904. * An interface which manages callbacks for gamepad button changes
  79905. */
  79906. export interface GamepadButtonChanges {
  79907. /**
  79908. * Called when a gamepad has been changed
  79909. */
  79910. changed: boolean;
  79911. /**
  79912. * Called when a gamepad press event has been triggered
  79913. */
  79914. pressChanged: boolean;
  79915. /**
  79916. * Called when a touch event has been triggered
  79917. */
  79918. touchChanged: boolean;
  79919. /**
  79920. * Called when a value has changed
  79921. */
  79922. valueChanged: boolean;
  79923. }
  79924. /**
  79925. * Represents a gamepad
  79926. */
  79927. export class Gamepad {
  79928. /**
  79929. * The id of the gamepad
  79930. */
  79931. id: string;
  79932. /**
  79933. * The index of the gamepad
  79934. */
  79935. index: number;
  79936. /**
  79937. * The browser gamepad
  79938. */
  79939. browserGamepad: any;
  79940. /**
  79941. * Specifies what type of gamepad this represents
  79942. */
  79943. type: number;
  79944. private _leftStick;
  79945. private _rightStick;
  79946. /** @hidden */
  79947. _isConnected: boolean;
  79948. private _leftStickAxisX;
  79949. private _leftStickAxisY;
  79950. private _rightStickAxisX;
  79951. private _rightStickAxisY;
  79952. /**
  79953. * Triggered when the left control stick has been changed
  79954. */
  79955. private _onleftstickchanged;
  79956. /**
  79957. * Triggered when the right control stick has been changed
  79958. */
  79959. private _onrightstickchanged;
  79960. /**
  79961. * Represents a gamepad controller
  79962. */
  79963. static GAMEPAD: number;
  79964. /**
  79965. * Represents a generic controller
  79966. */
  79967. static GENERIC: number;
  79968. /**
  79969. * Represents an XBox controller
  79970. */
  79971. static XBOX: number;
  79972. /**
  79973. * Represents a pose-enabled controller
  79974. */
  79975. static POSE_ENABLED: number;
  79976. /**
  79977. * Specifies whether the left control stick should be Y-inverted
  79978. */
  79979. protected _invertLeftStickY: boolean;
  79980. /**
  79981. * Specifies if the gamepad has been connected
  79982. */
  79983. readonly isConnected: boolean;
  79984. /**
  79985. * Initializes the gamepad
  79986. * @param id The id of the gamepad
  79987. * @param index The index of the gamepad
  79988. * @param browserGamepad The browser gamepad
  79989. * @param leftStickX The x component of the left joystick
  79990. * @param leftStickY The y component of the left joystick
  79991. * @param rightStickX The x component of the right joystick
  79992. * @param rightStickY The y component of the right joystick
  79993. */
  79994. constructor(
  79995. /**
  79996. * The id of the gamepad
  79997. */
  79998. id: string,
  79999. /**
  80000. * The index of the gamepad
  80001. */
  80002. index: number,
  80003. /**
  80004. * The browser gamepad
  80005. */
  80006. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  80007. /**
  80008. * Callback triggered when the left joystick has changed
  80009. * @param callback
  80010. */
  80011. onleftstickchanged(callback: (values: StickValues) => void): void;
  80012. /**
  80013. * Callback triggered when the right joystick has changed
  80014. * @param callback
  80015. */
  80016. onrightstickchanged(callback: (values: StickValues) => void): void;
  80017. /**
  80018. * Gets the left joystick
  80019. */
  80020. /**
  80021. * Sets the left joystick values
  80022. */
  80023. leftStick: StickValues;
  80024. /**
  80025. * Gets the right joystick
  80026. */
  80027. /**
  80028. * Sets the right joystick value
  80029. */
  80030. rightStick: StickValues;
  80031. /**
  80032. * Updates the gamepad joystick positions
  80033. */
  80034. update(): void;
  80035. /**
  80036. * Disposes the gamepad
  80037. */
  80038. dispose(): void;
  80039. }
  80040. /**
  80041. * Represents a generic gamepad
  80042. */
  80043. export class GenericPad extends Gamepad {
  80044. private _buttons;
  80045. private _onbuttondown;
  80046. private _onbuttonup;
  80047. /**
  80048. * Observable triggered when a button has been pressed
  80049. */
  80050. onButtonDownObservable: Observable<number>;
  80051. /**
  80052. * Observable triggered when a button has been released
  80053. */
  80054. onButtonUpObservable: Observable<number>;
  80055. /**
  80056. * Callback triggered when a button has been pressed
  80057. * @param callback Called when a button has been pressed
  80058. */
  80059. onbuttondown(callback: (buttonPressed: number) => void): void;
  80060. /**
  80061. * Callback triggered when a button has been released
  80062. * @param callback Called when a button has been released
  80063. */
  80064. onbuttonup(callback: (buttonReleased: number) => void): void;
  80065. /**
  80066. * Initializes the generic gamepad
  80067. * @param id The id of the generic gamepad
  80068. * @param index The index of the generic gamepad
  80069. * @param browserGamepad The browser gamepad
  80070. */
  80071. constructor(id: string, index: number, browserGamepad: any);
  80072. private _setButtonValue;
  80073. /**
  80074. * Updates the generic gamepad
  80075. */
  80076. update(): void;
  80077. /**
  80078. * Disposes the generic gamepad
  80079. */
  80080. dispose(): void;
  80081. }
  80082. }
  80083. declare module BABYLON {
  80084. /**
  80085. * Defines the types of pose enabled controllers that are supported
  80086. */
  80087. export enum PoseEnabledControllerType {
  80088. /**
  80089. * HTC Vive
  80090. */
  80091. VIVE = 0,
  80092. /**
  80093. * Oculus Rift
  80094. */
  80095. OCULUS = 1,
  80096. /**
  80097. * Windows mixed reality
  80098. */
  80099. WINDOWS = 2,
  80100. /**
  80101. * Samsung gear VR
  80102. */
  80103. GEAR_VR = 3,
  80104. /**
  80105. * Google Daydream
  80106. */
  80107. DAYDREAM = 4,
  80108. /**
  80109. * Generic
  80110. */
  80111. GENERIC = 5
  80112. }
  80113. /**
  80114. * Defines the MutableGamepadButton interface for the state of a gamepad button
  80115. */
  80116. export interface MutableGamepadButton {
  80117. /**
  80118. * Value of the button/trigger
  80119. */
  80120. value: number;
  80121. /**
  80122. * If the button/trigger is currently touched
  80123. */
  80124. touched: boolean;
  80125. /**
  80126. * If the button/trigger is currently pressed
  80127. */
  80128. pressed: boolean;
  80129. }
  80130. /**
  80131. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  80132. * @hidden
  80133. */
  80134. export interface ExtendedGamepadButton extends GamepadButton {
  80135. /**
  80136. * If the button/trigger is currently pressed
  80137. */
  80138. readonly pressed: boolean;
  80139. /**
  80140. * If the button/trigger is currently touched
  80141. */
  80142. readonly touched: boolean;
  80143. /**
  80144. * Value of the button/trigger
  80145. */
  80146. readonly value: number;
  80147. }
  80148. /** @hidden */
  80149. export interface _GamePadFactory {
  80150. /**
  80151. * Returns wether or not the current gamepad can be created for this type of controller.
  80152. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  80153. * @returns true if it can be created, otherwise false
  80154. */
  80155. canCreate(gamepadInfo: any): boolean;
  80156. /**
  80157. * Creates a new instance of the Gamepad.
  80158. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  80159. * @returns the new gamepad instance
  80160. */
  80161. create(gamepadInfo: any): Gamepad;
  80162. }
  80163. /**
  80164. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80165. */
  80166. export class PoseEnabledControllerHelper {
  80167. /** @hidden */
  80168. static _ControllerFactories: _GamePadFactory[];
  80169. /** @hidden */
  80170. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  80171. /**
  80172. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80173. * @param vrGamepad the gamepad to initialized
  80174. * @returns a vr controller of the type the gamepad identified as
  80175. */
  80176. static InitiateController(vrGamepad: any): Gamepad;
  80177. }
  80178. /**
  80179. * Defines the PoseEnabledController object that contains state of a vr capable controller
  80180. */
  80181. export class PoseEnabledController extends Gamepad implements PoseControlled {
  80182. private _deviceRoomPosition;
  80183. private _deviceRoomRotationQuaternion;
  80184. /**
  80185. * The device position in babylon space
  80186. */
  80187. devicePosition: Vector3;
  80188. /**
  80189. * The device rotation in babylon space
  80190. */
  80191. deviceRotationQuaternion: Quaternion;
  80192. /**
  80193. * The scale factor of the device in babylon space
  80194. */
  80195. deviceScaleFactor: number;
  80196. /**
  80197. * (Likely devicePosition should be used instead) The device position in its room space
  80198. */
  80199. position: Vector3;
  80200. /**
  80201. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  80202. */
  80203. rotationQuaternion: Quaternion;
  80204. /**
  80205. * The type of controller (Eg. Windows mixed reality)
  80206. */
  80207. controllerType: PoseEnabledControllerType;
  80208. protected _calculatedPosition: Vector3;
  80209. private _calculatedRotation;
  80210. /**
  80211. * The raw pose from the device
  80212. */
  80213. rawPose: DevicePose;
  80214. private _trackPosition;
  80215. private _maxRotationDistFromHeadset;
  80216. private _draggedRoomRotation;
  80217. /**
  80218. * @hidden
  80219. */
  80220. _disableTrackPosition(fixedPosition: Vector3): void;
  80221. /**
  80222. * Internal, the mesh attached to the controller
  80223. * @hidden
  80224. */
  80225. _mesh: Nullable<AbstractMesh>;
  80226. private _poseControlledCamera;
  80227. private _leftHandSystemQuaternion;
  80228. /**
  80229. * Internal, matrix used to convert room space to babylon space
  80230. * @hidden
  80231. */
  80232. _deviceToWorld: Matrix;
  80233. /**
  80234. * Node to be used when casting a ray from the controller
  80235. * @hidden
  80236. */
  80237. _pointingPoseNode: Nullable<TransformNode>;
  80238. /**
  80239. * Name of the child mesh that can be used to cast a ray from the controller
  80240. */
  80241. static readonly POINTING_POSE: string;
  80242. /**
  80243. * Creates a new PoseEnabledController from a gamepad
  80244. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  80245. */
  80246. constructor(browserGamepad: any);
  80247. private _workingMatrix;
  80248. /**
  80249. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  80250. */
  80251. update(): void;
  80252. /**
  80253. * Updates only the pose device and mesh without doing any button event checking
  80254. */
  80255. protected _updatePoseAndMesh(): void;
  80256. /**
  80257. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  80258. * @param poseData raw pose fromthe device
  80259. */
  80260. updateFromDevice(poseData: DevicePose): void;
  80261. /**
  80262. * @hidden
  80263. */
  80264. _meshAttachedObservable: Observable<AbstractMesh>;
  80265. /**
  80266. * Attaches a mesh to the controller
  80267. * @param mesh the mesh to be attached
  80268. */
  80269. attachToMesh(mesh: AbstractMesh): void;
  80270. /**
  80271. * Attaches the controllers mesh to a camera
  80272. * @param camera the camera the mesh should be attached to
  80273. */
  80274. attachToPoseControlledCamera(camera: TargetCamera): void;
  80275. /**
  80276. * Disposes of the controller
  80277. */
  80278. dispose(): void;
  80279. /**
  80280. * The mesh that is attached to the controller
  80281. */
  80282. readonly mesh: Nullable<AbstractMesh>;
  80283. /**
  80284. * Gets the ray of the controller in the direction the controller is pointing
  80285. * @param length the length the resulting ray should be
  80286. * @returns a ray in the direction the controller is pointing
  80287. */
  80288. getForwardRay(length?: number): Ray;
  80289. }
  80290. }
  80291. declare module BABYLON {
  80292. /**
  80293. * Defines the WebVRController object that represents controllers tracked in 3D space
  80294. */
  80295. export abstract class WebVRController extends PoseEnabledController {
  80296. /**
  80297. * Internal, the default controller model for the controller
  80298. */
  80299. protected _defaultModel: AbstractMesh;
  80300. /**
  80301. * Fired when the trigger state has changed
  80302. */
  80303. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  80304. /**
  80305. * Fired when the main button state has changed
  80306. */
  80307. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80308. /**
  80309. * Fired when the secondary button state has changed
  80310. */
  80311. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80312. /**
  80313. * Fired when the pad state has changed
  80314. */
  80315. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  80316. /**
  80317. * Fired when controllers stick values have changed
  80318. */
  80319. onPadValuesChangedObservable: Observable<StickValues>;
  80320. /**
  80321. * Array of button availible on the controller
  80322. */
  80323. protected _buttons: Array<MutableGamepadButton>;
  80324. private _onButtonStateChange;
  80325. /**
  80326. * Fired when a controller button's state has changed
  80327. * @param callback the callback containing the button that was modified
  80328. */
  80329. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  80330. /**
  80331. * X and Y axis corresponding to the controllers joystick
  80332. */
  80333. pad: StickValues;
  80334. /**
  80335. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  80336. */
  80337. hand: string;
  80338. /**
  80339. * The default controller model for the controller
  80340. */
  80341. readonly defaultModel: AbstractMesh;
  80342. /**
  80343. * Creates a new WebVRController from a gamepad
  80344. * @param vrGamepad the gamepad that the WebVRController should be created from
  80345. */
  80346. constructor(vrGamepad: any);
  80347. /**
  80348. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  80349. */
  80350. update(): void;
  80351. /**
  80352. * Function to be called when a button is modified
  80353. */
  80354. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  80355. /**
  80356. * Loads a mesh and attaches it to the controller
  80357. * @param scene the scene the mesh should be added to
  80358. * @param meshLoaded callback for when the mesh has been loaded
  80359. */
  80360. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  80361. private _setButtonValue;
  80362. private _changes;
  80363. private _checkChanges;
  80364. /**
  80365. * Disposes of th webVRCOntroller
  80366. */
  80367. dispose(): void;
  80368. }
  80369. }
  80370. declare module BABYLON {
  80371. /**
  80372. * The HemisphericLight simulates the ambient environment light,
  80373. * so the passed direction is the light reflection direction, not the incoming direction.
  80374. */
  80375. export class HemisphericLight extends Light {
  80376. /**
  80377. * The groundColor is the light in the opposite direction to the one specified during creation.
  80378. * 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.
  80379. */
  80380. groundColor: Color3;
  80381. /**
  80382. * The light reflection direction, not the incoming direction.
  80383. */
  80384. direction: Vector3;
  80385. /**
  80386. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  80387. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  80388. * The HemisphericLight can't cast shadows.
  80389. * Documentation : https://doc.babylonjs.com/babylon101/lights
  80390. * @param name The friendly name of the light
  80391. * @param direction The direction of the light reflection
  80392. * @param scene The scene the light belongs to
  80393. */
  80394. constructor(name: string, direction: Vector3, scene: Scene);
  80395. protected _buildUniformLayout(): void;
  80396. /**
  80397. * Returns the string "HemisphericLight".
  80398. * @return The class name
  80399. */
  80400. getClassName(): string;
  80401. /**
  80402. * Sets the HemisphericLight direction towards the passed target (Vector3).
  80403. * Returns the updated direction.
  80404. * @param target The target the direction should point to
  80405. * @return The computed direction
  80406. */
  80407. setDirectionToTarget(target: Vector3): Vector3;
  80408. /**
  80409. * Returns the shadow generator associated to the light.
  80410. * @returns Always null for hemispheric lights because it does not support shadows.
  80411. */
  80412. getShadowGenerator(): Nullable<IShadowGenerator>;
  80413. /**
  80414. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  80415. * @param effect The effect to update
  80416. * @param lightIndex The index of the light in the effect to update
  80417. * @returns The hemispheric light
  80418. */
  80419. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  80420. /**
  80421. * Computes the world matrix of the node
  80422. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80423. * @param useWasUpdatedFlag defines a reserved property
  80424. * @returns the world matrix
  80425. */
  80426. computeWorldMatrix(): Matrix;
  80427. /**
  80428. * Returns the integer 3.
  80429. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  80430. */
  80431. getTypeID(): number;
  80432. /**
  80433. * Prepares the list of defines specific to the light type.
  80434. * @param defines the list of defines
  80435. * @param lightIndex defines the index of the light for the effect
  80436. */
  80437. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  80438. }
  80439. }
  80440. declare module BABYLON {
  80441. /** @hidden */
  80442. export var vrMultiviewToSingleviewPixelShader: {
  80443. name: string;
  80444. shader: string;
  80445. };
  80446. }
  80447. declare module BABYLON {
  80448. /**
  80449. * Renders to multiple views with a single draw call
  80450. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  80451. */
  80452. export class MultiviewRenderTarget extends RenderTargetTexture {
  80453. /**
  80454. * Creates a multiview render target
  80455. * @param scene scene used with the render target
  80456. * @param size the size of the render target (used for each view)
  80457. */
  80458. constructor(scene: Scene, size?: number | {
  80459. width: number;
  80460. height: number;
  80461. } | {
  80462. ratio: number;
  80463. });
  80464. /**
  80465. * @hidden
  80466. * @param faceIndex the face index, if its a cube texture
  80467. */
  80468. _bindFrameBuffer(faceIndex?: number): void;
  80469. /**
  80470. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  80471. * @returns the view count
  80472. */
  80473. getViewCount(): number;
  80474. }
  80475. }
  80476. declare module BABYLON {
  80477. interface Engine {
  80478. /**
  80479. * Creates a new multiview render target
  80480. * @param width defines the width of the texture
  80481. * @param height defines the height of the texture
  80482. * @returns the created multiview texture
  80483. */
  80484. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  80485. /**
  80486. * Binds a multiview framebuffer to be drawn to
  80487. * @param multiviewTexture texture to bind
  80488. */
  80489. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  80490. }
  80491. interface Camera {
  80492. /**
  80493. * @hidden
  80494. * 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)
  80495. */
  80496. _useMultiviewToSingleView: boolean;
  80497. /**
  80498. * @hidden
  80499. * 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)
  80500. */
  80501. _multiviewTexture: Nullable<RenderTargetTexture>;
  80502. /**
  80503. * @hidden
  80504. * ensures the multiview texture of the camera exists and has the specified width/height
  80505. * @param width height to set on the multiview texture
  80506. * @param height width to set on the multiview texture
  80507. */
  80508. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  80509. }
  80510. interface Scene {
  80511. /** @hidden */
  80512. _transformMatrixR: Matrix;
  80513. /** @hidden */
  80514. _multiviewSceneUbo: Nullable<UniformBuffer>;
  80515. /** @hidden */
  80516. _createMultiviewUbo(): void;
  80517. /** @hidden */
  80518. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  80519. /** @hidden */
  80520. _renderMultiviewToSingleView(camera: Camera): void;
  80521. }
  80522. }
  80523. declare module BABYLON {
  80524. /**
  80525. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  80526. * This will not be used for webXR as it supports displaying texture arrays directly
  80527. */
  80528. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  80529. /**
  80530. * Initializes a VRMultiviewToSingleview
  80531. * @param name name of the post process
  80532. * @param camera camera to be applied to
  80533. * @param scaleFactor scaling factor to the size of the output texture
  80534. */
  80535. constructor(name: string, camera: Camera, scaleFactor: number);
  80536. }
  80537. }
  80538. declare module BABYLON {
  80539. interface Engine {
  80540. /** @hidden */
  80541. _vrDisplay: any;
  80542. /** @hidden */
  80543. _vrSupported: boolean;
  80544. /** @hidden */
  80545. _oldSize: Size;
  80546. /** @hidden */
  80547. _oldHardwareScaleFactor: number;
  80548. /** @hidden */
  80549. _vrExclusivePointerMode: boolean;
  80550. /** @hidden */
  80551. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  80552. /** @hidden */
  80553. _onVRDisplayPointerRestricted: () => void;
  80554. /** @hidden */
  80555. _onVRDisplayPointerUnrestricted: () => void;
  80556. /** @hidden */
  80557. _onVrDisplayConnect: Nullable<(display: any) => void>;
  80558. /** @hidden */
  80559. _onVrDisplayDisconnect: Nullable<() => void>;
  80560. /** @hidden */
  80561. _onVrDisplayPresentChange: Nullable<() => void>;
  80562. /**
  80563. * Observable signaled when VR display mode changes
  80564. */
  80565. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  80566. /**
  80567. * Observable signaled when VR request present is complete
  80568. */
  80569. onVRRequestPresentComplete: Observable<boolean>;
  80570. /**
  80571. * Observable signaled when VR request present starts
  80572. */
  80573. onVRRequestPresentStart: Observable<Engine>;
  80574. /**
  80575. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  80576. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  80577. */
  80578. isInVRExclusivePointerMode: boolean;
  80579. /**
  80580. * Gets a boolean indicating if a webVR device was detected
  80581. * @returns true if a webVR device was detected
  80582. */
  80583. isVRDevicePresent(): boolean;
  80584. /**
  80585. * Gets the current webVR device
  80586. * @returns the current webVR device (or null)
  80587. */
  80588. getVRDevice(): any;
  80589. /**
  80590. * Initializes a webVR display and starts listening to display change events
  80591. * The onVRDisplayChangedObservable will be notified upon these changes
  80592. * @returns A promise containing a VRDisplay and if vr is supported
  80593. */
  80594. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  80595. /** @hidden */
  80596. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  80597. /**
  80598. * Call this function to switch to webVR mode
  80599. * Will do nothing if webVR is not supported or if there is no webVR device
  80600. * @see http://doc.babylonjs.com/how_to/webvr_camera
  80601. */
  80602. enableVR(): void;
  80603. /** @hidden */
  80604. _onVRFullScreenTriggered(): void;
  80605. }
  80606. }
  80607. declare module BABYLON {
  80608. /**
  80609. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  80610. * IMPORTANT!! The data is right-hand data.
  80611. * @export
  80612. * @interface DevicePose
  80613. */
  80614. export interface DevicePose {
  80615. /**
  80616. * The position of the device, values in array are [x,y,z].
  80617. */
  80618. readonly position: Nullable<Float32Array>;
  80619. /**
  80620. * The linearVelocity of the device, values in array are [x,y,z].
  80621. */
  80622. readonly linearVelocity: Nullable<Float32Array>;
  80623. /**
  80624. * The linearAcceleration of the device, values in array are [x,y,z].
  80625. */
  80626. readonly linearAcceleration: Nullable<Float32Array>;
  80627. /**
  80628. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  80629. */
  80630. readonly orientation: Nullable<Float32Array>;
  80631. /**
  80632. * The angularVelocity of the device, values in array are [x,y,z].
  80633. */
  80634. readonly angularVelocity: Nullable<Float32Array>;
  80635. /**
  80636. * The angularAcceleration of the device, values in array are [x,y,z].
  80637. */
  80638. readonly angularAcceleration: Nullable<Float32Array>;
  80639. }
  80640. /**
  80641. * Interface representing a pose controlled object in Babylon.
  80642. * A pose controlled object has both regular pose values as well as pose values
  80643. * from an external device such as a VR head mounted display
  80644. */
  80645. export interface PoseControlled {
  80646. /**
  80647. * The position of the object in babylon space.
  80648. */
  80649. position: Vector3;
  80650. /**
  80651. * The rotation quaternion of the object in babylon space.
  80652. */
  80653. rotationQuaternion: Quaternion;
  80654. /**
  80655. * The position of the device in babylon space.
  80656. */
  80657. devicePosition?: Vector3;
  80658. /**
  80659. * The rotation quaternion of the device in babylon space.
  80660. */
  80661. deviceRotationQuaternion: Quaternion;
  80662. /**
  80663. * The raw pose coming from the device.
  80664. */
  80665. rawPose: Nullable<DevicePose>;
  80666. /**
  80667. * The scale of the device to be used when translating from device space to babylon space.
  80668. */
  80669. deviceScaleFactor: number;
  80670. /**
  80671. * Updates the poseControlled values based on the input device pose.
  80672. * @param poseData the pose data to update the object with
  80673. */
  80674. updateFromDevice(poseData: DevicePose): void;
  80675. }
  80676. /**
  80677. * Set of options to customize the webVRCamera
  80678. */
  80679. export interface WebVROptions {
  80680. /**
  80681. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  80682. */
  80683. trackPosition?: boolean;
  80684. /**
  80685. * Sets the scale of the vrDevice in babylon space. (default: 1)
  80686. */
  80687. positionScale?: number;
  80688. /**
  80689. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  80690. */
  80691. displayName?: string;
  80692. /**
  80693. * Should the native controller meshes be initialized. (default: true)
  80694. */
  80695. controllerMeshes?: boolean;
  80696. /**
  80697. * Creating a default HemiLight only on controllers. (default: true)
  80698. */
  80699. defaultLightingOnControllers?: boolean;
  80700. /**
  80701. * If you don't want to use the default VR button of the helper. (default: false)
  80702. */
  80703. useCustomVRButton?: boolean;
  80704. /**
  80705. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  80706. */
  80707. customVRButton?: HTMLButtonElement;
  80708. /**
  80709. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  80710. */
  80711. rayLength?: number;
  80712. /**
  80713. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  80714. */
  80715. defaultHeight?: number;
  80716. /**
  80717. * If multiview should be used if availible (default: false)
  80718. */
  80719. useMultiview?: boolean;
  80720. }
  80721. /**
  80722. * This represents a WebVR camera.
  80723. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  80724. * @example http://doc.babylonjs.com/how_to/webvr_camera
  80725. */
  80726. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  80727. private webVROptions;
  80728. /**
  80729. * @hidden
  80730. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  80731. */
  80732. _vrDevice: any;
  80733. /**
  80734. * The rawPose of the vrDevice.
  80735. */
  80736. rawPose: Nullable<DevicePose>;
  80737. private _onVREnabled;
  80738. private _specsVersion;
  80739. private _attached;
  80740. private _frameData;
  80741. protected _descendants: Array<Node>;
  80742. private _deviceRoomPosition;
  80743. /** @hidden */
  80744. _deviceRoomRotationQuaternion: Quaternion;
  80745. private _standingMatrix;
  80746. /**
  80747. * Represents device position in babylon space.
  80748. */
  80749. devicePosition: Vector3;
  80750. /**
  80751. * Represents device rotation in babylon space.
  80752. */
  80753. deviceRotationQuaternion: Quaternion;
  80754. /**
  80755. * The scale of the device to be used when translating from device space to babylon space.
  80756. */
  80757. deviceScaleFactor: number;
  80758. private _deviceToWorld;
  80759. private _worldToDevice;
  80760. /**
  80761. * References to the webVR controllers for the vrDevice.
  80762. */
  80763. controllers: Array<WebVRController>;
  80764. /**
  80765. * Emits an event when a controller is attached.
  80766. */
  80767. onControllersAttachedObservable: Observable<WebVRController[]>;
  80768. /**
  80769. * Emits an event when a controller's mesh has been loaded;
  80770. */
  80771. onControllerMeshLoadedObservable: Observable<WebVRController>;
  80772. /**
  80773. * Emits an event when the HMD's pose has been updated.
  80774. */
  80775. onPoseUpdatedFromDeviceObservable: Observable<any>;
  80776. private _poseSet;
  80777. /**
  80778. * If the rig cameras be used as parent instead of this camera.
  80779. */
  80780. rigParenting: boolean;
  80781. private _lightOnControllers;
  80782. private _defaultHeight?;
  80783. /**
  80784. * Instantiates a WebVRFreeCamera.
  80785. * @param name The name of the WebVRFreeCamera
  80786. * @param position The starting anchor position for the camera
  80787. * @param scene The scene the camera belongs to
  80788. * @param webVROptions a set of customizable options for the webVRCamera
  80789. */
  80790. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  80791. /**
  80792. * Gets the device distance from the ground in meters.
  80793. * @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.
  80794. */
  80795. deviceDistanceToRoomGround(): number;
  80796. /**
  80797. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80798. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  80799. */
  80800. useStandingMatrix(callback?: (bool: boolean) => void): void;
  80801. /**
  80802. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80803. * @returns A promise with a boolean set to if the standing matrix is supported.
  80804. */
  80805. useStandingMatrixAsync(): Promise<boolean>;
  80806. /**
  80807. * Disposes the camera
  80808. */
  80809. dispose(): void;
  80810. /**
  80811. * Gets a vrController by name.
  80812. * @param name The name of the controller to retreive
  80813. * @returns the controller matching the name specified or null if not found
  80814. */
  80815. getControllerByName(name: string): Nullable<WebVRController>;
  80816. private _leftController;
  80817. /**
  80818. * The controller corresponding to the users left hand.
  80819. */
  80820. readonly leftController: Nullable<WebVRController>;
  80821. private _rightController;
  80822. /**
  80823. * The controller corresponding to the users right hand.
  80824. */
  80825. readonly rightController: Nullable<WebVRController>;
  80826. /**
  80827. * Casts a ray forward from the vrCamera's gaze.
  80828. * @param length Length of the ray (default: 100)
  80829. * @returns the ray corresponding to the gaze
  80830. */
  80831. getForwardRay(length?: number): Ray;
  80832. /**
  80833. * @hidden
  80834. * Updates the camera based on device's frame data
  80835. */
  80836. _checkInputs(): void;
  80837. /**
  80838. * Updates the poseControlled values based on the input device pose.
  80839. * @param poseData Pose coming from the device
  80840. */
  80841. updateFromDevice(poseData: DevicePose): void;
  80842. private _htmlElementAttached;
  80843. private _detachIfAttached;
  80844. /**
  80845. * WebVR's attach control will start broadcasting frames to the device.
  80846. * Note that in certain browsers (chrome for example) this function must be called
  80847. * within a user-interaction callback. Example:
  80848. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  80849. *
  80850. * @param element html element to attach the vrDevice to
  80851. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  80852. */
  80853. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80854. /**
  80855. * Detaches the camera from the html element and disables VR
  80856. *
  80857. * @param element html element to detach from
  80858. */
  80859. detachControl(element: HTMLElement): void;
  80860. /**
  80861. * @returns the name of this class
  80862. */
  80863. getClassName(): string;
  80864. /**
  80865. * Calls resetPose on the vrDisplay
  80866. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  80867. */
  80868. resetToCurrentRotation(): void;
  80869. /**
  80870. * @hidden
  80871. * Updates the rig cameras (left and right eye)
  80872. */
  80873. _updateRigCameras(): void;
  80874. private _workingVector;
  80875. private _oneVector;
  80876. private _workingMatrix;
  80877. private updateCacheCalled;
  80878. private _correctPositionIfNotTrackPosition;
  80879. /**
  80880. * @hidden
  80881. * Updates the cached values of the camera
  80882. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  80883. */
  80884. _updateCache(ignoreParentClass?: boolean): void;
  80885. /**
  80886. * @hidden
  80887. * Get current device position in babylon world
  80888. */
  80889. _computeDevicePosition(): void;
  80890. /**
  80891. * Updates the current device position and rotation in the babylon world
  80892. */
  80893. update(): void;
  80894. /**
  80895. * @hidden
  80896. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  80897. * @returns an identity matrix
  80898. */
  80899. _getViewMatrix(): Matrix;
  80900. private _tmpMatrix;
  80901. /**
  80902. * This function is called by the two RIG cameras.
  80903. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  80904. * @hidden
  80905. */
  80906. _getWebVRViewMatrix(): Matrix;
  80907. /** @hidden */
  80908. _getWebVRProjectionMatrix(): Matrix;
  80909. private _onGamepadConnectedObserver;
  80910. private _onGamepadDisconnectedObserver;
  80911. private _updateCacheWhenTrackingDisabledObserver;
  80912. /**
  80913. * Initializes the controllers and their meshes
  80914. */
  80915. initControllers(): void;
  80916. }
  80917. }
  80918. declare module BABYLON {
  80919. /**
  80920. * Size options for a post process
  80921. */
  80922. export type PostProcessOptions = {
  80923. width: number;
  80924. height: number;
  80925. };
  80926. /**
  80927. * PostProcess can be used to apply a shader to a texture after it has been rendered
  80928. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  80929. */
  80930. export class PostProcess {
  80931. /** Name of the PostProcess. */
  80932. name: string;
  80933. /**
  80934. * Gets or sets the unique id of the post process
  80935. */
  80936. uniqueId: number;
  80937. /**
  80938. * Width of the texture to apply the post process on
  80939. */
  80940. width: number;
  80941. /**
  80942. * Height of the texture to apply the post process on
  80943. */
  80944. height: number;
  80945. /**
  80946. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  80947. * @hidden
  80948. */
  80949. _outputTexture: Nullable<InternalTexture>;
  80950. /**
  80951. * Sampling mode used by the shader
  80952. * See https://doc.babylonjs.com/classes/3.1/texture
  80953. */
  80954. renderTargetSamplingMode: number;
  80955. /**
  80956. * Clear color to use when screen clearing
  80957. */
  80958. clearColor: Color4;
  80959. /**
  80960. * If the buffer needs to be cleared before applying the post process. (default: true)
  80961. * Should be set to false if shader will overwrite all previous pixels.
  80962. */
  80963. autoClear: boolean;
  80964. /**
  80965. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  80966. */
  80967. alphaMode: number;
  80968. /**
  80969. * Sets the setAlphaBlendConstants of the babylon engine
  80970. */
  80971. alphaConstants: Color4;
  80972. /**
  80973. * Animations to be used for the post processing
  80974. */
  80975. animations: Animation[];
  80976. /**
  80977. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  80978. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  80979. */
  80980. enablePixelPerfectMode: boolean;
  80981. /**
  80982. * Force the postprocess to be applied without taking in account viewport
  80983. */
  80984. forceFullscreenViewport: boolean;
  80985. /**
  80986. * List of inspectable custom properties (used by the Inspector)
  80987. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80988. */
  80989. inspectableCustomProperties: IInspectable[];
  80990. /**
  80991. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  80992. *
  80993. * | Value | Type | Description |
  80994. * | ----- | ----------------------------------- | ----------- |
  80995. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  80996. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  80997. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  80998. *
  80999. */
  81000. scaleMode: number;
  81001. /**
  81002. * Force textures to be a power of two (default: false)
  81003. */
  81004. alwaysForcePOT: boolean;
  81005. private _samples;
  81006. /**
  81007. * Number of sample textures (default: 1)
  81008. */
  81009. samples: number;
  81010. /**
  81011. * Modify the scale of the post process to be the same as the viewport (default: false)
  81012. */
  81013. adaptScaleToCurrentViewport: boolean;
  81014. private _camera;
  81015. private _scene;
  81016. private _engine;
  81017. private _options;
  81018. private _reusable;
  81019. private _textureType;
  81020. /**
  81021. * Smart array of input and output textures for the post process.
  81022. * @hidden
  81023. */
  81024. _textures: SmartArray<InternalTexture>;
  81025. /**
  81026. * The index in _textures that corresponds to the output texture.
  81027. * @hidden
  81028. */
  81029. _currentRenderTextureInd: number;
  81030. private _effect;
  81031. private _samplers;
  81032. private _fragmentUrl;
  81033. private _vertexUrl;
  81034. private _parameters;
  81035. private _scaleRatio;
  81036. protected _indexParameters: any;
  81037. private _shareOutputWithPostProcess;
  81038. private _texelSize;
  81039. private _forcedOutputTexture;
  81040. /**
  81041. * Returns the fragment url or shader name used in the post process.
  81042. * @returns the fragment url or name in the shader store.
  81043. */
  81044. getEffectName(): string;
  81045. /**
  81046. * An event triggered when the postprocess is activated.
  81047. */
  81048. onActivateObservable: Observable<Camera>;
  81049. private _onActivateObserver;
  81050. /**
  81051. * A function that is added to the onActivateObservable
  81052. */
  81053. onActivate: Nullable<(camera: Camera) => void>;
  81054. /**
  81055. * An event triggered when the postprocess changes its size.
  81056. */
  81057. onSizeChangedObservable: Observable<PostProcess>;
  81058. private _onSizeChangedObserver;
  81059. /**
  81060. * A function that is added to the onSizeChangedObservable
  81061. */
  81062. onSizeChanged: (postProcess: PostProcess) => void;
  81063. /**
  81064. * An event triggered when the postprocess applies its effect.
  81065. */
  81066. onApplyObservable: Observable<Effect>;
  81067. private _onApplyObserver;
  81068. /**
  81069. * A function that is added to the onApplyObservable
  81070. */
  81071. onApply: (effect: Effect) => void;
  81072. /**
  81073. * An event triggered before rendering the postprocess
  81074. */
  81075. onBeforeRenderObservable: Observable<Effect>;
  81076. private _onBeforeRenderObserver;
  81077. /**
  81078. * A function that is added to the onBeforeRenderObservable
  81079. */
  81080. onBeforeRender: (effect: Effect) => void;
  81081. /**
  81082. * An event triggered after rendering the postprocess
  81083. */
  81084. onAfterRenderObservable: Observable<Effect>;
  81085. private _onAfterRenderObserver;
  81086. /**
  81087. * A function that is added to the onAfterRenderObservable
  81088. */
  81089. onAfterRender: (efect: Effect) => void;
  81090. /**
  81091. * 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
  81092. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  81093. */
  81094. inputTexture: InternalTexture;
  81095. /**
  81096. * Gets the camera which post process is applied to.
  81097. * @returns The camera the post process is applied to.
  81098. */
  81099. getCamera(): Camera;
  81100. /**
  81101. * Gets the texel size of the postprocess.
  81102. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  81103. */
  81104. readonly texelSize: Vector2;
  81105. /**
  81106. * Creates a new instance PostProcess
  81107. * @param name The name of the PostProcess.
  81108. * @param fragmentUrl The url of the fragment shader to be used.
  81109. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  81110. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  81111. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81112. * @param camera The camera to apply the render pass to.
  81113. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81114. * @param engine The engine which the post process will be applied. (default: current engine)
  81115. * @param reusable If the post process can be reused on the same frame. (default: false)
  81116. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  81117. * @param textureType Type of textures used when performing the post process. (default: 0)
  81118. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  81119. * @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
  81120. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  81121. */
  81122. constructor(
  81123. /** Name of the PostProcess. */
  81124. 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);
  81125. /**
  81126. * Gets a string idenfifying the name of the class
  81127. * @returns "PostProcess" string
  81128. */
  81129. getClassName(): string;
  81130. /**
  81131. * Gets the engine which this post process belongs to.
  81132. * @returns The engine the post process was enabled with.
  81133. */
  81134. getEngine(): Engine;
  81135. /**
  81136. * The effect that is created when initializing the post process.
  81137. * @returns The created effect corresponding the the postprocess.
  81138. */
  81139. getEffect(): Effect;
  81140. /**
  81141. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  81142. * @param postProcess The post process to share the output with.
  81143. * @returns This post process.
  81144. */
  81145. shareOutputWith(postProcess: PostProcess): PostProcess;
  81146. /**
  81147. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  81148. * This should be called if the post process that shares output with this post process is disabled/disposed.
  81149. */
  81150. useOwnOutput(): void;
  81151. /**
  81152. * Updates the effect with the current post process compile time values and recompiles the shader.
  81153. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81154. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81155. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81156. * @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
  81157. * @param onCompiled Called when the shader has been compiled.
  81158. * @param onError Called if there is an error when compiling a shader.
  81159. */
  81160. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81161. /**
  81162. * The post process is reusable if it can be used multiple times within one frame.
  81163. * @returns If the post process is reusable
  81164. */
  81165. isReusable(): boolean;
  81166. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  81167. markTextureDirty(): void;
  81168. /**
  81169. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  81170. * 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.
  81171. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  81172. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  81173. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  81174. * @returns The target texture that was bound to be written to.
  81175. */
  81176. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  81177. /**
  81178. * If the post process is supported.
  81179. */
  81180. readonly isSupported: boolean;
  81181. /**
  81182. * The aspect ratio of the output texture.
  81183. */
  81184. readonly aspectRatio: number;
  81185. /**
  81186. * Get a value indicating if the post-process is ready to be used
  81187. * @returns true if the post-process is ready (shader is compiled)
  81188. */
  81189. isReady(): boolean;
  81190. /**
  81191. * Binds all textures and uniforms to the shader, this will be run on every pass.
  81192. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  81193. */
  81194. apply(): Nullable<Effect>;
  81195. private _disposeTextures;
  81196. /**
  81197. * Disposes the post process.
  81198. * @param camera The camera to dispose the post process on.
  81199. */
  81200. dispose(camera?: Camera): void;
  81201. }
  81202. }
  81203. declare module BABYLON {
  81204. /** @hidden */
  81205. export var kernelBlurVaryingDeclaration: {
  81206. name: string;
  81207. shader: string;
  81208. };
  81209. }
  81210. declare module BABYLON {
  81211. /** @hidden */
  81212. export var kernelBlurFragment: {
  81213. name: string;
  81214. shader: string;
  81215. };
  81216. }
  81217. declare module BABYLON {
  81218. /** @hidden */
  81219. export var kernelBlurFragment2: {
  81220. name: string;
  81221. shader: string;
  81222. };
  81223. }
  81224. declare module BABYLON {
  81225. /** @hidden */
  81226. export var kernelBlurPixelShader: {
  81227. name: string;
  81228. shader: string;
  81229. };
  81230. }
  81231. declare module BABYLON {
  81232. /** @hidden */
  81233. export var kernelBlurVertex: {
  81234. name: string;
  81235. shader: string;
  81236. };
  81237. }
  81238. declare module BABYLON {
  81239. /** @hidden */
  81240. export var kernelBlurVertexShader: {
  81241. name: string;
  81242. shader: string;
  81243. };
  81244. }
  81245. declare module BABYLON {
  81246. /**
  81247. * The Blur Post Process which blurs an image based on a kernel and direction.
  81248. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  81249. */
  81250. export class BlurPostProcess extends PostProcess {
  81251. /** The direction in which to blur the image. */
  81252. direction: Vector2;
  81253. private blockCompilation;
  81254. protected _kernel: number;
  81255. protected _idealKernel: number;
  81256. protected _packedFloat: boolean;
  81257. private _staticDefines;
  81258. /**
  81259. * Sets the length in pixels of the blur sample region
  81260. */
  81261. /**
  81262. * Gets the length in pixels of the blur sample region
  81263. */
  81264. kernel: number;
  81265. /**
  81266. * Sets wether or not the blur needs to unpack/repack floats
  81267. */
  81268. /**
  81269. * Gets wether or not the blur is unpacking/repacking floats
  81270. */
  81271. packedFloat: boolean;
  81272. /**
  81273. * Creates a new instance BlurPostProcess
  81274. * @param name The name of the effect.
  81275. * @param direction The direction in which to blur the image.
  81276. * @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.
  81277. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81278. * @param camera The camera to apply the render pass to.
  81279. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81280. * @param engine The engine which the post process will be applied. (default: current engine)
  81281. * @param reusable If the post process can be reused on the same frame. (default: false)
  81282. * @param textureType Type of textures used when performing the post process. (default: 0)
  81283. * @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)
  81284. */
  81285. constructor(name: string,
  81286. /** The direction in which to blur the image. */
  81287. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  81288. /**
  81289. * Updates the effect with the current post process compile time values and recompiles the shader.
  81290. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81291. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81292. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81293. * @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
  81294. * @param onCompiled Called when the shader has been compiled.
  81295. * @param onError Called if there is an error when compiling a shader.
  81296. */
  81297. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81298. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81299. /**
  81300. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  81301. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  81302. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  81303. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  81304. * The gaps between physical kernels are compensated for in the weighting of the samples
  81305. * @param idealKernel Ideal blur kernel.
  81306. * @return Nearest best kernel.
  81307. */
  81308. protected _nearestBestKernel(idealKernel: number): number;
  81309. /**
  81310. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  81311. * @param x The point on the Gaussian distribution to sample.
  81312. * @return the value of the Gaussian function at x.
  81313. */
  81314. protected _gaussianWeight(x: number): number;
  81315. /**
  81316. * Generates a string that can be used as a floating point number in GLSL.
  81317. * @param x Value to print.
  81318. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  81319. * @return GLSL float string.
  81320. */
  81321. protected _glslFloat(x: number, decimalFigures?: number): string;
  81322. }
  81323. }
  81324. declare module BABYLON {
  81325. /**
  81326. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81327. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81328. * You can then easily use it as a reflectionTexture on a flat surface.
  81329. * In case the surface is not a plane, please consider relying on reflection probes.
  81330. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81331. */
  81332. export class MirrorTexture extends RenderTargetTexture {
  81333. private scene;
  81334. /**
  81335. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  81336. * 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.
  81337. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81338. */
  81339. mirrorPlane: Plane;
  81340. /**
  81341. * Define the blur ratio used to blur the reflection if needed.
  81342. */
  81343. blurRatio: number;
  81344. /**
  81345. * Define the adaptive blur kernel used to blur the reflection if needed.
  81346. * This will autocompute the closest best match for the `blurKernel`
  81347. */
  81348. adaptiveBlurKernel: number;
  81349. /**
  81350. * Define the blur kernel used to blur the reflection if needed.
  81351. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81352. */
  81353. blurKernel: number;
  81354. /**
  81355. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  81356. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81357. */
  81358. blurKernelX: number;
  81359. /**
  81360. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  81361. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81362. */
  81363. blurKernelY: number;
  81364. private _autoComputeBlurKernel;
  81365. protected _onRatioRescale(): void;
  81366. private _updateGammaSpace;
  81367. private _imageProcessingConfigChangeObserver;
  81368. private _transformMatrix;
  81369. private _mirrorMatrix;
  81370. private _savedViewMatrix;
  81371. private _blurX;
  81372. private _blurY;
  81373. private _adaptiveBlurKernel;
  81374. private _blurKernelX;
  81375. private _blurKernelY;
  81376. private _blurRatio;
  81377. /**
  81378. * Instantiates a Mirror Texture.
  81379. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81380. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81381. * You can then easily use it as a reflectionTexture on a flat surface.
  81382. * In case the surface is not a plane, please consider relying on reflection probes.
  81383. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81384. * @param name
  81385. * @param size
  81386. * @param scene
  81387. * @param generateMipMaps
  81388. * @param type
  81389. * @param samplingMode
  81390. * @param generateDepthBuffer
  81391. */
  81392. constructor(name: string, size: number | {
  81393. width: number;
  81394. height: number;
  81395. } | {
  81396. ratio: number;
  81397. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  81398. private _preparePostProcesses;
  81399. /**
  81400. * Clone the mirror texture.
  81401. * @returns the cloned texture
  81402. */
  81403. clone(): MirrorTexture;
  81404. /**
  81405. * Serialize the texture to a JSON representation you could use in Parse later on
  81406. * @returns the serialized JSON representation
  81407. */
  81408. serialize(): any;
  81409. /**
  81410. * Dispose the texture and release its associated resources.
  81411. */
  81412. dispose(): void;
  81413. }
  81414. }
  81415. declare module BABYLON {
  81416. /**
  81417. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81418. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81419. */
  81420. export class Texture extends BaseTexture {
  81421. /** @hidden */
  81422. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  81423. /** @hidden */
  81424. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  81425. /** @hidden */
  81426. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  81427. /** nearest is mag = nearest and min = nearest and mip = linear */
  81428. static readonly NEAREST_SAMPLINGMODE: number;
  81429. /** nearest is mag = nearest and min = nearest and mip = linear */
  81430. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  81431. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81432. static readonly BILINEAR_SAMPLINGMODE: number;
  81433. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81434. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  81435. /** Trilinear is mag = linear and min = linear and mip = linear */
  81436. static readonly TRILINEAR_SAMPLINGMODE: number;
  81437. /** Trilinear is mag = linear and min = linear and mip = linear */
  81438. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  81439. /** mag = nearest and min = nearest and mip = nearest */
  81440. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  81441. /** mag = nearest and min = linear and mip = nearest */
  81442. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  81443. /** mag = nearest and min = linear and mip = linear */
  81444. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  81445. /** mag = nearest and min = linear and mip = none */
  81446. static readonly NEAREST_LINEAR: number;
  81447. /** mag = nearest and min = nearest and mip = none */
  81448. static readonly NEAREST_NEAREST: number;
  81449. /** mag = linear and min = nearest and mip = nearest */
  81450. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  81451. /** mag = linear and min = nearest and mip = linear */
  81452. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  81453. /** mag = linear and min = linear and mip = none */
  81454. static readonly LINEAR_LINEAR: number;
  81455. /** mag = linear and min = nearest and mip = none */
  81456. static readonly LINEAR_NEAREST: number;
  81457. /** Explicit coordinates mode */
  81458. static readonly EXPLICIT_MODE: number;
  81459. /** Spherical coordinates mode */
  81460. static readonly SPHERICAL_MODE: number;
  81461. /** Planar coordinates mode */
  81462. static readonly PLANAR_MODE: number;
  81463. /** Cubic coordinates mode */
  81464. static readonly CUBIC_MODE: number;
  81465. /** Projection coordinates mode */
  81466. static readonly PROJECTION_MODE: number;
  81467. /** Inverse Cubic coordinates mode */
  81468. static readonly SKYBOX_MODE: number;
  81469. /** Inverse Cubic coordinates mode */
  81470. static readonly INVCUBIC_MODE: number;
  81471. /** Equirectangular coordinates mode */
  81472. static readonly EQUIRECTANGULAR_MODE: number;
  81473. /** Equirectangular Fixed coordinates mode */
  81474. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  81475. /** Equirectangular Fixed Mirrored coordinates mode */
  81476. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81477. /** Texture is not repeating outside of 0..1 UVs */
  81478. static readonly CLAMP_ADDRESSMODE: number;
  81479. /** Texture is repeating outside of 0..1 UVs */
  81480. static readonly WRAP_ADDRESSMODE: number;
  81481. /** Texture is repeating and mirrored */
  81482. static readonly MIRROR_ADDRESSMODE: number;
  81483. /**
  81484. * 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
  81485. */
  81486. static UseSerializedUrlIfAny: boolean;
  81487. /**
  81488. * Define the url of the texture.
  81489. */
  81490. url: Nullable<string>;
  81491. /**
  81492. * Define an offset on the texture to offset the u coordinates of the UVs
  81493. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81494. */
  81495. uOffset: number;
  81496. /**
  81497. * Define an offset on the texture to offset the v coordinates of the UVs
  81498. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81499. */
  81500. vOffset: number;
  81501. /**
  81502. * Define an offset on the texture to scale the u coordinates of the UVs
  81503. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81504. */
  81505. uScale: number;
  81506. /**
  81507. * Define an offset on the texture to scale the v coordinates of the UVs
  81508. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81509. */
  81510. vScale: number;
  81511. /**
  81512. * Define an offset on the texture to rotate around the u coordinates of the UVs
  81513. * @see http://doc.babylonjs.com/how_to/more_materials
  81514. */
  81515. uAng: number;
  81516. /**
  81517. * Define an offset on the texture to rotate around the v coordinates of the UVs
  81518. * @see http://doc.babylonjs.com/how_to/more_materials
  81519. */
  81520. vAng: number;
  81521. /**
  81522. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  81523. * @see http://doc.babylonjs.com/how_to/more_materials
  81524. */
  81525. wAng: number;
  81526. /**
  81527. * Defines the center of rotation (U)
  81528. */
  81529. uRotationCenter: number;
  81530. /**
  81531. * Defines the center of rotation (V)
  81532. */
  81533. vRotationCenter: number;
  81534. /**
  81535. * Defines the center of rotation (W)
  81536. */
  81537. wRotationCenter: number;
  81538. /**
  81539. * Are mip maps generated for this texture or not.
  81540. */
  81541. readonly noMipmap: boolean;
  81542. /**
  81543. * List of inspectable custom properties (used by the Inspector)
  81544. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81545. */
  81546. inspectableCustomProperties: Nullable<IInspectable[]>;
  81547. private _noMipmap;
  81548. /** @hidden */
  81549. _invertY: boolean;
  81550. private _rowGenerationMatrix;
  81551. private _cachedTextureMatrix;
  81552. private _projectionModeMatrix;
  81553. private _t0;
  81554. private _t1;
  81555. private _t2;
  81556. private _cachedUOffset;
  81557. private _cachedVOffset;
  81558. private _cachedUScale;
  81559. private _cachedVScale;
  81560. private _cachedUAng;
  81561. private _cachedVAng;
  81562. private _cachedWAng;
  81563. private _cachedProjectionMatrixId;
  81564. private _cachedCoordinatesMode;
  81565. /** @hidden */
  81566. protected _initialSamplingMode: number;
  81567. /** @hidden */
  81568. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  81569. private _deleteBuffer;
  81570. protected _format: Nullable<number>;
  81571. private _delayedOnLoad;
  81572. private _delayedOnError;
  81573. /**
  81574. * Observable triggered once the texture has been loaded.
  81575. */
  81576. onLoadObservable: Observable<Texture>;
  81577. protected _isBlocking: boolean;
  81578. /**
  81579. * Is the texture preventing material to render while loading.
  81580. * If false, a default texture will be used instead of the loading one during the preparation step.
  81581. */
  81582. isBlocking: boolean;
  81583. /**
  81584. * Get the current sampling mode associated with the texture.
  81585. */
  81586. readonly samplingMode: number;
  81587. /**
  81588. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  81589. */
  81590. readonly invertY: boolean;
  81591. /**
  81592. * Instantiates a new texture.
  81593. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81594. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81595. * @param url define the url of the picture to load as a texture
  81596. * @param scene define the scene the texture will belong to
  81597. * @param noMipmap define if the texture will require mip maps or not
  81598. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81599. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81600. * @param onLoad define a callback triggered when the texture has been loaded
  81601. * @param onError define a callback triggered when an error occurred during the loading session
  81602. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81603. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81604. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81605. */
  81606. 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);
  81607. /**
  81608. * Update the url (and optional buffer) of this texture if url was null during construction.
  81609. * @param url the url of the texture
  81610. * @param buffer the buffer of the texture (defaults to null)
  81611. * @param onLoad callback called when the texture is loaded (defaults to null)
  81612. */
  81613. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  81614. /**
  81615. * Finish the loading sequence of a texture flagged as delayed load.
  81616. * @hidden
  81617. */
  81618. delayLoad(): void;
  81619. private _prepareRowForTextureGeneration;
  81620. /**
  81621. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  81622. * @returns the transform matrix of the texture.
  81623. */
  81624. getTextureMatrix(): Matrix;
  81625. /**
  81626. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  81627. * @returns The reflection texture transform
  81628. */
  81629. getReflectionTextureMatrix(): Matrix;
  81630. /**
  81631. * Clones the texture.
  81632. * @returns the cloned texture
  81633. */
  81634. clone(): Texture;
  81635. /**
  81636. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  81637. * @returns The JSON representation of the texture
  81638. */
  81639. serialize(): any;
  81640. /**
  81641. * Get the current class name of the texture useful for serialization or dynamic coding.
  81642. * @returns "Texture"
  81643. */
  81644. getClassName(): string;
  81645. /**
  81646. * Dispose the texture and release its associated resources.
  81647. */
  81648. dispose(): void;
  81649. /**
  81650. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  81651. * @param parsedTexture Define the JSON representation of the texture
  81652. * @param scene Define the scene the parsed texture should be instantiated in
  81653. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  81654. * @returns The parsed texture if successful
  81655. */
  81656. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  81657. /**
  81658. * Creates a texture from its base 64 representation.
  81659. * @param data Define the base64 payload without the data: prefix
  81660. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81661. * @param scene Define the scene the texture should belong to
  81662. * @param noMipmap Forces the texture to not create mip map information if true
  81663. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81664. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81665. * @param onLoad define a callback triggered when the texture has been loaded
  81666. * @param onError define a callback triggered when an error occurred during the loading session
  81667. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81668. * @returns the created texture
  81669. */
  81670. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  81671. /**
  81672. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  81673. * @param data Define the base64 payload without the data: prefix
  81674. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81675. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81676. * @param scene Define the scene the texture should belong to
  81677. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81678. * @param noMipmap Forces the texture to not create mip map information if true
  81679. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81680. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81681. * @param onLoad define a callback triggered when the texture has been loaded
  81682. * @param onError define a callback triggered when an error occurred during the loading session
  81683. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81684. * @returns the created texture
  81685. */
  81686. 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;
  81687. }
  81688. }
  81689. declare module BABYLON {
  81690. /**
  81691. * PostProcessManager is used to manage one or more post processes or post process pipelines
  81692. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81693. */
  81694. export class PostProcessManager {
  81695. private _scene;
  81696. private _indexBuffer;
  81697. private _vertexBuffers;
  81698. /**
  81699. * Creates a new instance PostProcess
  81700. * @param scene The scene that the post process is associated with.
  81701. */
  81702. constructor(scene: Scene);
  81703. private _prepareBuffers;
  81704. private _buildIndexBuffer;
  81705. /**
  81706. * Rebuilds the vertex buffers of the manager.
  81707. * @hidden
  81708. */
  81709. _rebuild(): void;
  81710. /**
  81711. * Prepares a frame to be run through a post process.
  81712. * @param sourceTexture The input texture to the post procesess. (default: null)
  81713. * @param postProcesses An array of post processes to be run. (default: null)
  81714. * @returns True if the post processes were able to be run.
  81715. * @hidden
  81716. */
  81717. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  81718. /**
  81719. * Manually render a set of post processes to a texture.
  81720. * @param postProcesses An array of post processes to be run.
  81721. * @param targetTexture The target texture to render to.
  81722. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  81723. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  81724. * @param lodLevel defines which lod of the texture to render to
  81725. */
  81726. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  81727. /**
  81728. * Finalize the result of the output of the postprocesses.
  81729. * @param doNotPresent If true the result will not be displayed to the screen.
  81730. * @param targetTexture The target texture to render to.
  81731. * @param faceIndex The index of the face to bind the target texture to.
  81732. * @param postProcesses The array of post processes to render.
  81733. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  81734. * @hidden
  81735. */
  81736. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  81737. /**
  81738. * Disposes of the post process manager.
  81739. */
  81740. dispose(): void;
  81741. }
  81742. }
  81743. declare module BABYLON {
  81744. interface AbstractScene {
  81745. /**
  81746. * The list of procedural textures added to the scene
  81747. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81748. */
  81749. proceduralTextures: Array<ProceduralTexture>;
  81750. }
  81751. /**
  81752. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  81753. * in a given scene.
  81754. */
  81755. export class ProceduralTextureSceneComponent implements ISceneComponent {
  81756. /**
  81757. * The component name helpfull to identify the component in the list of scene components.
  81758. */
  81759. readonly name: string;
  81760. /**
  81761. * The scene the component belongs to.
  81762. */
  81763. scene: Scene;
  81764. /**
  81765. * Creates a new instance of the component for the given scene
  81766. * @param scene Defines the scene to register the component in
  81767. */
  81768. constructor(scene: Scene);
  81769. /**
  81770. * Registers the component in a given scene
  81771. */
  81772. register(): void;
  81773. /**
  81774. * Rebuilds the elements related to this component in case of
  81775. * context lost for instance.
  81776. */
  81777. rebuild(): void;
  81778. /**
  81779. * Disposes the component and the associated ressources.
  81780. */
  81781. dispose(): void;
  81782. private _beforeClear;
  81783. }
  81784. }
  81785. declare module BABYLON {
  81786. interface Engine {
  81787. /**
  81788. * Creates a new render target cube texture
  81789. * @param size defines the size of the texture
  81790. * @param options defines the options used to create the texture
  81791. * @returns a new render target cube texture stored in an InternalTexture
  81792. */
  81793. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  81794. }
  81795. }
  81796. declare module BABYLON {
  81797. /** @hidden */
  81798. export var proceduralVertexShader: {
  81799. name: string;
  81800. shader: string;
  81801. };
  81802. }
  81803. declare module BABYLON {
  81804. /**
  81805. * 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.
  81806. * This is the base class of any Procedural texture and contains most of the shareable code.
  81807. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81808. */
  81809. export class ProceduralTexture extends Texture {
  81810. isCube: boolean;
  81811. /**
  81812. * Define if the texture is enabled or not (disabled texture will not render)
  81813. */
  81814. isEnabled: boolean;
  81815. /**
  81816. * Define if the texture must be cleared before rendering (default is true)
  81817. */
  81818. autoClear: boolean;
  81819. /**
  81820. * Callback called when the texture is generated
  81821. */
  81822. onGenerated: () => void;
  81823. /**
  81824. * Event raised when the texture is generated
  81825. */
  81826. onGeneratedObservable: Observable<ProceduralTexture>;
  81827. /** @hidden */
  81828. _generateMipMaps: boolean;
  81829. /** @hidden **/
  81830. _effect: Effect;
  81831. /** @hidden */
  81832. _textures: {
  81833. [key: string]: Texture;
  81834. };
  81835. private _size;
  81836. private _currentRefreshId;
  81837. private _refreshRate;
  81838. private _vertexBuffers;
  81839. private _indexBuffer;
  81840. private _uniforms;
  81841. private _samplers;
  81842. private _fragment;
  81843. private _floats;
  81844. private _ints;
  81845. private _floatsArrays;
  81846. private _colors3;
  81847. private _colors4;
  81848. private _vectors2;
  81849. private _vectors3;
  81850. private _matrices;
  81851. private _fallbackTexture;
  81852. private _fallbackTextureUsed;
  81853. private _engine;
  81854. private _cachedDefines;
  81855. private _contentUpdateId;
  81856. private _contentData;
  81857. /**
  81858. * Instantiates a new procedural texture.
  81859. * 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.
  81860. * This is the base class of any Procedural texture and contains most of the shareable code.
  81861. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81862. * @param name Define the name of the texture
  81863. * @param size Define the size of the texture to create
  81864. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  81865. * @param scene Define the scene the texture belongs to
  81866. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  81867. * @param generateMipMaps Define if the texture should creates mip maps or not
  81868. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  81869. */
  81870. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  81871. /**
  81872. * The effect that is created when initializing the post process.
  81873. * @returns The created effect corresponding the the postprocess.
  81874. */
  81875. getEffect(): Effect;
  81876. /**
  81877. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  81878. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  81879. */
  81880. getContent(): Nullable<ArrayBufferView>;
  81881. private _createIndexBuffer;
  81882. /** @hidden */
  81883. _rebuild(): void;
  81884. /**
  81885. * Resets the texture in order to recreate its associated resources.
  81886. * This can be called in case of context loss
  81887. */
  81888. reset(): void;
  81889. protected _getDefines(): string;
  81890. /**
  81891. * Is the texture ready to be used ? (rendered at least once)
  81892. * @returns true if ready, otherwise, false.
  81893. */
  81894. isReady(): boolean;
  81895. /**
  81896. * Resets the refresh counter of the texture and start bak from scratch.
  81897. * Could be useful to regenerate the texture if it is setup to render only once.
  81898. */
  81899. resetRefreshCounter(): void;
  81900. /**
  81901. * Set the fragment shader to use in order to render the texture.
  81902. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  81903. */
  81904. setFragment(fragment: any): void;
  81905. /**
  81906. * Define the refresh rate of the texture or the rendering frequency.
  81907. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  81908. */
  81909. refreshRate: number;
  81910. /** @hidden */
  81911. _shouldRender(): boolean;
  81912. /**
  81913. * Get the size the texture is rendering at.
  81914. * @returns the size (texture is always squared)
  81915. */
  81916. getRenderSize(): number;
  81917. /**
  81918. * Resize the texture to new value.
  81919. * @param size Define the new size the texture should have
  81920. * @param generateMipMaps Define whether the new texture should create mip maps
  81921. */
  81922. resize(size: number, generateMipMaps: boolean): void;
  81923. private _checkUniform;
  81924. /**
  81925. * Set a texture in the shader program used to render.
  81926. * @param name Define the name of the uniform samplers as defined in the shader
  81927. * @param texture Define the texture to bind to this sampler
  81928. * @return the texture itself allowing "fluent" like uniform updates
  81929. */
  81930. setTexture(name: string, texture: Texture): ProceduralTexture;
  81931. /**
  81932. * Set a float in the shader.
  81933. * @param name Define the name of the uniform as defined in the shader
  81934. * @param value Define the value to give to the uniform
  81935. * @return the texture itself allowing "fluent" like uniform updates
  81936. */
  81937. setFloat(name: string, value: number): ProceduralTexture;
  81938. /**
  81939. * Set a int in the shader.
  81940. * @param name Define the name of the uniform as defined in the shader
  81941. * @param value Define the value to give to the uniform
  81942. * @return the texture itself allowing "fluent" like uniform updates
  81943. */
  81944. setInt(name: string, value: number): ProceduralTexture;
  81945. /**
  81946. * Set an array of floats in the shader.
  81947. * @param name Define the name of the uniform as defined in the shader
  81948. * @param value Define the value to give to the uniform
  81949. * @return the texture itself allowing "fluent" like uniform updates
  81950. */
  81951. setFloats(name: string, value: number[]): ProceduralTexture;
  81952. /**
  81953. * Set a vec3 in the shader from a Color3.
  81954. * @param name Define the name of the uniform as defined in the shader
  81955. * @param value Define the value to give to the uniform
  81956. * @return the texture itself allowing "fluent" like uniform updates
  81957. */
  81958. setColor3(name: string, value: Color3): ProceduralTexture;
  81959. /**
  81960. * Set a vec4 in the shader from a Color4.
  81961. * @param name Define the name of the uniform as defined in the shader
  81962. * @param value Define the value to give to the uniform
  81963. * @return the texture itself allowing "fluent" like uniform updates
  81964. */
  81965. setColor4(name: string, value: Color4): ProceduralTexture;
  81966. /**
  81967. * Set a vec2 in the shader from a Vector2.
  81968. * @param name Define the name of the uniform as defined in the shader
  81969. * @param value Define the value to give to the uniform
  81970. * @return the texture itself allowing "fluent" like uniform updates
  81971. */
  81972. setVector2(name: string, value: Vector2): ProceduralTexture;
  81973. /**
  81974. * Set a vec3 in the shader from a Vector3.
  81975. * @param name Define the name of the uniform as defined in the shader
  81976. * @param value Define the value to give to the uniform
  81977. * @return the texture itself allowing "fluent" like uniform updates
  81978. */
  81979. setVector3(name: string, value: Vector3): ProceduralTexture;
  81980. /**
  81981. * Set a mat4 in the shader from a MAtrix.
  81982. * @param name Define the name of the uniform as defined in the shader
  81983. * @param value Define the value to give to the uniform
  81984. * @return the texture itself allowing "fluent" like uniform updates
  81985. */
  81986. setMatrix(name: string, value: Matrix): ProceduralTexture;
  81987. /**
  81988. * Render the texture to its associated render target.
  81989. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  81990. */
  81991. render(useCameraPostProcess?: boolean): void;
  81992. /**
  81993. * Clone the texture.
  81994. * @returns the cloned texture
  81995. */
  81996. clone(): ProceduralTexture;
  81997. /**
  81998. * Dispose the texture and release its asoociated resources.
  81999. */
  82000. dispose(): void;
  82001. }
  82002. }
  82003. declare module BABYLON {
  82004. /**
  82005. * This represents the base class for particle system in Babylon.
  82006. * 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.
  82007. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82008. * @example https://doc.babylonjs.com/babylon101/particles
  82009. */
  82010. export class BaseParticleSystem {
  82011. /**
  82012. * Source color is added to the destination color without alpha affecting the result
  82013. */
  82014. static BLENDMODE_ONEONE: number;
  82015. /**
  82016. * Blend current color and particle color using particle’s alpha
  82017. */
  82018. static BLENDMODE_STANDARD: number;
  82019. /**
  82020. * Add current color and particle color multiplied by particle’s alpha
  82021. */
  82022. static BLENDMODE_ADD: number;
  82023. /**
  82024. * Multiply current color with particle color
  82025. */
  82026. static BLENDMODE_MULTIPLY: number;
  82027. /**
  82028. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  82029. */
  82030. static BLENDMODE_MULTIPLYADD: number;
  82031. /**
  82032. * List of animations used by the particle system.
  82033. */
  82034. animations: Animation[];
  82035. /**
  82036. * The id of the Particle system.
  82037. */
  82038. id: string;
  82039. /**
  82040. * The friendly name of the Particle system.
  82041. */
  82042. name: string;
  82043. /**
  82044. * The rendering group used by the Particle system to chose when to render.
  82045. */
  82046. renderingGroupId: number;
  82047. /**
  82048. * The emitter represents the Mesh or position we are attaching the particle system to.
  82049. */
  82050. emitter: Nullable<AbstractMesh | Vector3>;
  82051. /**
  82052. * The maximum number of particles to emit per frame
  82053. */
  82054. emitRate: number;
  82055. /**
  82056. * If you want to launch only a few particles at once, that can be done, as well.
  82057. */
  82058. manualEmitCount: number;
  82059. /**
  82060. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  82061. */
  82062. updateSpeed: number;
  82063. /**
  82064. * The amount of time the particle system is running (depends of the overall update speed).
  82065. */
  82066. targetStopDuration: number;
  82067. /**
  82068. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  82069. */
  82070. disposeOnStop: boolean;
  82071. /**
  82072. * Minimum power of emitting particles.
  82073. */
  82074. minEmitPower: number;
  82075. /**
  82076. * Maximum power of emitting particles.
  82077. */
  82078. maxEmitPower: number;
  82079. /**
  82080. * Minimum life time of emitting particles.
  82081. */
  82082. minLifeTime: number;
  82083. /**
  82084. * Maximum life time of emitting particles.
  82085. */
  82086. maxLifeTime: number;
  82087. /**
  82088. * Minimum Size of emitting particles.
  82089. */
  82090. minSize: number;
  82091. /**
  82092. * Maximum Size of emitting particles.
  82093. */
  82094. maxSize: number;
  82095. /**
  82096. * Minimum scale of emitting particles on X axis.
  82097. */
  82098. minScaleX: number;
  82099. /**
  82100. * Maximum scale of emitting particles on X axis.
  82101. */
  82102. maxScaleX: number;
  82103. /**
  82104. * Minimum scale of emitting particles on Y axis.
  82105. */
  82106. minScaleY: number;
  82107. /**
  82108. * Maximum scale of emitting particles on Y axis.
  82109. */
  82110. maxScaleY: number;
  82111. /**
  82112. * Gets or sets the minimal initial rotation in radians.
  82113. */
  82114. minInitialRotation: number;
  82115. /**
  82116. * Gets or sets the maximal initial rotation in radians.
  82117. */
  82118. maxInitialRotation: number;
  82119. /**
  82120. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  82121. */
  82122. minAngularSpeed: number;
  82123. /**
  82124. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  82125. */
  82126. maxAngularSpeed: number;
  82127. /**
  82128. * The texture used to render each particle. (this can be a spritesheet)
  82129. */
  82130. particleTexture: Nullable<Texture>;
  82131. /**
  82132. * The layer mask we are rendering the particles through.
  82133. */
  82134. layerMask: number;
  82135. /**
  82136. * This can help using your own shader to render the particle system.
  82137. * The according effect will be created
  82138. */
  82139. customShader: any;
  82140. /**
  82141. * By default particle system starts as soon as they are created. This prevents the
  82142. * automatic start to happen and let you decide when to start emitting particles.
  82143. */
  82144. preventAutoStart: boolean;
  82145. private _noiseTexture;
  82146. /**
  82147. * Gets or sets a texture used to add random noise to particle positions
  82148. */
  82149. noiseTexture: Nullable<ProceduralTexture>;
  82150. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  82151. noiseStrength: Vector3;
  82152. /**
  82153. * Callback triggered when the particle animation is ending.
  82154. */
  82155. onAnimationEnd: Nullable<() => void>;
  82156. /**
  82157. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  82158. */
  82159. blendMode: number;
  82160. /**
  82161. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  82162. * to override the particles.
  82163. */
  82164. forceDepthWrite: boolean;
  82165. /** 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 */
  82166. preWarmCycles: number;
  82167. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  82168. preWarmStepOffset: number;
  82169. /**
  82170. * 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)
  82171. */
  82172. spriteCellChangeSpeed: number;
  82173. /**
  82174. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  82175. */
  82176. startSpriteCellID: number;
  82177. /**
  82178. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  82179. */
  82180. endSpriteCellID: number;
  82181. /**
  82182. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  82183. */
  82184. spriteCellWidth: number;
  82185. /**
  82186. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  82187. */
  82188. spriteCellHeight: number;
  82189. /**
  82190. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  82191. */
  82192. spriteRandomStartCell: boolean;
  82193. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  82194. translationPivot: Vector2;
  82195. /** @hidden */
  82196. protected _isAnimationSheetEnabled: boolean;
  82197. /**
  82198. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  82199. */
  82200. beginAnimationOnStart: boolean;
  82201. /**
  82202. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  82203. */
  82204. beginAnimationFrom: number;
  82205. /**
  82206. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  82207. */
  82208. beginAnimationTo: number;
  82209. /**
  82210. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  82211. */
  82212. beginAnimationLoop: boolean;
  82213. /**
  82214. * Gets or sets a world offset applied to all particles
  82215. */
  82216. worldOffset: Vector3;
  82217. /**
  82218. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  82219. */
  82220. isAnimationSheetEnabled: boolean;
  82221. /**
  82222. * Get hosting scene
  82223. * @returns the scene
  82224. */
  82225. getScene(): Scene;
  82226. /**
  82227. * You can use gravity if you want to give an orientation to your particles.
  82228. */
  82229. gravity: Vector3;
  82230. protected _colorGradients: Nullable<Array<ColorGradient>>;
  82231. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  82232. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  82233. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  82234. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  82235. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  82236. protected _dragGradients: Nullable<Array<FactorGradient>>;
  82237. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  82238. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  82239. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  82240. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  82241. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  82242. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  82243. /**
  82244. * Defines the delay in milliseconds before starting the system (0 by default)
  82245. */
  82246. startDelay: number;
  82247. /**
  82248. * Gets the current list of drag gradients.
  82249. * You must use addDragGradient and removeDragGradient to udpate this list
  82250. * @returns the list of drag gradients
  82251. */
  82252. getDragGradients(): Nullable<Array<FactorGradient>>;
  82253. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  82254. limitVelocityDamping: number;
  82255. /**
  82256. * Gets the current list of limit velocity gradients.
  82257. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  82258. * @returns the list of limit velocity gradients
  82259. */
  82260. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  82261. /**
  82262. * Gets the current list of color gradients.
  82263. * You must use addColorGradient and removeColorGradient to udpate this list
  82264. * @returns the list of color gradients
  82265. */
  82266. getColorGradients(): Nullable<Array<ColorGradient>>;
  82267. /**
  82268. * Gets the current list of size gradients.
  82269. * You must use addSizeGradient and removeSizeGradient to udpate this list
  82270. * @returns the list of size gradients
  82271. */
  82272. getSizeGradients(): Nullable<Array<FactorGradient>>;
  82273. /**
  82274. * Gets the current list of color remap gradients.
  82275. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  82276. * @returns the list of color remap gradients
  82277. */
  82278. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  82279. /**
  82280. * Gets the current list of alpha remap gradients.
  82281. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  82282. * @returns the list of alpha remap gradients
  82283. */
  82284. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  82285. /**
  82286. * Gets the current list of life time gradients.
  82287. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  82288. * @returns the list of life time gradients
  82289. */
  82290. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  82291. /**
  82292. * Gets the current list of angular speed gradients.
  82293. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  82294. * @returns the list of angular speed gradients
  82295. */
  82296. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  82297. /**
  82298. * Gets the current list of velocity gradients.
  82299. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  82300. * @returns the list of velocity gradients
  82301. */
  82302. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  82303. /**
  82304. * Gets the current list of start size gradients.
  82305. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  82306. * @returns the list of start size gradients
  82307. */
  82308. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  82309. /**
  82310. * Gets the current list of emit rate gradients.
  82311. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  82312. * @returns the list of emit rate gradients
  82313. */
  82314. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  82315. /**
  82316. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82317. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82318. */
  82319. direction1: Vector3;
  82320. /**
  82321. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82322. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82323. */
  82324. direction2: Vector3;
  82325. /**
  82326. * 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.
  82327. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82328. */
  82329. minEmitBox: Vector3;
  82330. /**
  82331. * 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.
  82332. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82333. */
  82334. maxEmitBox: Vector3;
  82335. /**
  82336. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82337. */
  82338. color1: Color4;
  82339. /**
  82340. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82341. */
  82342. color2: Color4;
  82343. /**
  82344. * Color the particle will have at the end of its lifetime
  82345. */
  82346. colorDead: Color4;
  82347. /**
  82348. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  82349. */
  82350. textureMask: Color4;
  82351. /**
  82352. * The particle emitter type defines the emitter used by the particle system.
  82353. * It can be for example box, sphere, or cone...
  82354. */
  82355. particleEmitterType: IParticleEmitterType;
  82356. /** @hidden */
  82357. _isSubEmitter: boolean;
  82358. /**
  82359. * Gets or sets the billboard mode to use when isBillboardBased = true.
  82360. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  82361. */
  82362. billboardMode: number;
  82363. protected _isBillboardBased: boolean;
  82364. /**
  82365. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  82366. */
  82367. isBillboardBased: boolean;
  82368. /**
  82369. * The scene the particle system belongs to.
  82370. */
  82371. protected _scene: Scene;
  82372. /**
  82373. * Local cache of defines for image processing.
  82374. */
  82375. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  82376. /**
  82377. * Default configuration related to image processing available in the standard Material.
  82378. */
  82379. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  82380. /**
  82381. * Gets the image processing configuration used either in this material.
  82382. */
  82383. /**
  82384. * Sets the Default image processing configuration used either in the this material.
  82385. *
  82386. * If sets to null, the scene one is in use.
  82387. */
  82388. imageProcessingConfiguration: ImageProcessingConfiguration;
  82389. /**
  82390. * Attaches a new image processing configuration to the Standard Material.
  82391. * @param configuration
  82392. */
  82393. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  82394. /** @hidden */
  82395. protected _reset(): void;
  82396. /** @hidden */
  82397. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  82398. /**
  82399. * Instantiates a particle system.
  82400. * 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.
  82401. * @param name The name of the particle system
  82402. */
  82403. constructor(name: string);
  82404. /**
  82405. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  82406. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82407. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82408. * @returns the emitter
  82409. */
  82410. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  82411. /**
  82412. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  82413. * @param radius The radius of the hemisphere to emit from
  82414. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82415. * @returns the emitter
  82416. */
  82417. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  82418. /**
  82419. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  82420. * @param radius The radius of the sphere to emit from
  82421. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82422. * @returns the emitter
  82423. */
  82424. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  82425. /**
  82426. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  82427. * @param radius The radius of the sphere to emit from
  82428. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  82429. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  82430. * @returns the emitter
  82431. */
  82432. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  82433. /**
  82434. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  82435. * @param radius The radius of the emission cylinder
  82436. * @param height The height of the emission cylinder
  82437. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  82438. * @param directionRandomizer How much to randomize the particle direction [0-1]
  82439. * @returns the emitter
  82440. */
  82441. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  82442. /**
  82443. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  82444. * @param radius The radius of the cylinder to emit from
  82445. * @param height The height of the emission cylinder
  82446. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82447. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  82448. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  82449. * @returns the emitter
  82450. */
  82451. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  82452. /**
  82453. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  82454. * @param radius The radius of the cone to emit from
  82455. * @param angle The base angle of the cone
  82456. * @returns the emitter
  82457. */
  82458. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  82459. /**
  82460. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  82461. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82462. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82463. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82464. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82465. * @returns the emitter
  82466. */
  82467. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  82468. }
  82469. }
  82470. declare module BABYLON {
  82471. /**
  82472. * Type of sub emitter
  82473. */
  82474. export enum SubEmitterType {
  82475. /**
  82476. * Attached to the particle over it's lifetime
  82477. */
  82478. ATTACHED = 0,
  82479. /**
  82480. * Created when the particle dies
  82481. */
  82482. END = 1
  82483. }
  82484. /**
  82485. * Sub emitter class used to emit particles from an existing particle
  82486. */
  82487. export class SubEmitter {
  82488. /**
  82489. * the particle system to be used by the sub emitter
  82490. */
  82491. particleSystem: ParticleSystem;
  82492. /**
  82493. * Type of the submitter (Default: END)
  82494. */
  82495. type: SubEmitterType;
  82496. /**
  82497. * 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)
  82498. * Note: This only is supported when using an emitter of type Mesh
  82499. */
  82500. inheritDirection: boolean;
  82501. /**
  82502. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  82503. */
  82504. inheritedVelocityAmount: number;
  82505. /**
  82506. * Creates a sub emitter
  82507. * @param particleSystem the particle system to be used by the sub emitter
  82508. */
  82509. constructor(
  82510. /**
  82511. * the particle system to be used by the sub emitter
  82512. */
  82513. particleSystem: ParticleSystem);
  82514. /**
  82515. * Clones the sub emitter
  82516. * @returns the cloned sub emitter
  82517. */
  82518. clone(): SubEmitter;
  82519. /**
  82520. * Serialize current object to a JSON object
  82521. * @returns the serialized object
  82522. */
  82523. serialize(): any;
  82524. /** @hidden */
  82525. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  82526. /**
  82527. * Creates a new SubEmitter from a serialized JSON version
  82528. * @param serializationObject defines the JSON object to read from
  82529. * @param scene defines the hosting scene
  82530. * @param rootUrl defines the rootUrl for data loading
  82531. * @returns a new SubEmitter
  82532. */
  82533. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  82534. /** Release associated resources */
  82535. dispose(): void;
  82536. }
  82537. }
  82538. declare module BABYLON {
  82539. /** @hidden */
  82540. export var imageProcessingDeclaration: {
  82541. name: string;
  82542. shader: string;
  82543. };
  82544. }
  82545. declare module BABYLON {
  82546. /** @hidden */
  82547. export var imageProcessingFunctions: {
  82548. name: string;
  82549. shader: string;
  82550. };
  82551. }
  82552. declare module BABYLON {
  82553. /** @hidden */
  82554. export var particlesPixelShader: {
  82555. name: string;
  82556. shader: string;
  82557. };
  82558. }
  82559. declare module BABYLON {
  82560. /** @hidden */
  82561. export var particlesVertexShader: {
  82562. name: string;
  82563. shader: string;
  82564. };
  82565. }
  82566. declare module BABYLON {
  82567. /**
  82568. * This represents a particle system in Babylon.
  82569. * 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.
  82570. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82571. * @example https://doc.babylonjs.com/babylon101/particles
  82572. */
  82573. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  82574. /**
  82575. * Billboard mode will only apply to Y axis
  82576. */
  82577. static readonly BILLBOARDMODE_Y: number;
  82578. /**
  82579. * Billboard mode will apply to all axes
  82580. */
  82581. static readonly BILLBOARDMODE_ALL: number;
  82582. /**
  82583. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  82584. */
  82585. static readonly BILLBOARDMODE_STRETCHED: number;
  82586. /**
  82587. * This function can be defined to provide custom update for active particles.
  82588. * This function will be called instead of regular update (age, position, color, etc.).
  82589. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  82590. */
  82591. updateFunction: (particles: Particle[]) => void;
  82592. private _emitterWorldMatrix;
  82593. /**
  82594. * This function can be defined to specify initial direction for every new particle.
  82595. * It by default use the emitterType defined function
  82596. */
  82597. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  82598. /**
  82599. * This function can be defined to specify initial position for every new particle.
  82600. * It by default use the emitterType defined function
  82601. */
  82602. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  82603. /**
  82604. * @hidden
  82605. */
  82606. _inheritedVelocityOffset: Vector3;
  82607. /**
  82608. * An event triggered when the system is disposed
  82609. */
  82610. onDisposeObservable: Observable<ParticleSystem>;
  82611. private _onDisposeObserver;
  82612. /**
  82613. * Sets a callback that will be triggered when the system is disposed
  82614. */
  82615. onDispose: () => void;
  82616. private _particles;
  82617. private _epsilon;
  82618. private _capacity;
  82619. private _stockParticles;
  82620. private _newPartsExcess;
  82621. private _vertexData;
  82622. private _vertexBuffer;
  82623. private _vertexBuffers;
  82624. private _spriteBuffer;
  82625. private _indexBuffer;
  82626. private _effect;
  82627. private _customEffect;
  82628. private _cachedDefines;
  82629. private _scaledColorStep;
  82630. private _colorDiff;
  82631. private _scaledDirection;
  82632. private _scaledGravity;
  82633. private _currentRenderId;
  82634. private _alive;
  82635. private _useInstancing;
  82636. private _started;
  82637. private _stopped;
  82638. private _actualFrame;
  82639. private _scaledUpdateSpeed;
  82640. private _vertexBufferSize;
  82641. /** @hidden */
  82642. _currentEmitRateGradient: Nullable<FactorGradient>;
  82643. /** @hidden */
  82644. _currentEmitRate1: number;
  82645. /** @hidden */
  82646. _currentEmitRate2: number;
  82647. /** @hidden */
  82648. _currentStartSizeGradient: Nullable<FactorGradient>;
  82649. /** @hidden */
  82650. _currentStartSize1: number;
  82651. /** @hidden */
  82652. _currentStartSize2: number;
  82653. private readonly _rawTextureWidth;
  82654. private _rampGradientsTexture;
  82655. private _useRampGradients;
  82656. /** Gets or sets a boolean indicating that ramp gradients must be used
  82657. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82658. */
  82659. useRampGradients: boolean;
  82660. /**
  82661. * 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.
  82662. * 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: [])
  82663. */
  82664. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  82665. private _subEmitters;
  82666. /**
  82667. * @hidden
  82668. * If the particle systems emitter should be disposed when the particle system is disposed
  82669. */
  82670. _disposeEmitterOnDispose: boolean;
  82671. /**
  82672. * The current active Sub-systems, this property is used by the root particle system only.
  82673. */
  82674. activeSubSystems: Array<ParticleSystem>;
  82675. private _rootParticleSystem;
  82676. /**
  82677. * Gets the current list of active particles
  82678. */
  82679. readonly particles: Particle[];
  82680. /**
  82681. * Returns the string "ParticleSystem"
  82682. * @returns a string containing the class name
  82683. */
  82684. getClassName(): string;
  82685. /**
  82686. * Instantiates a particle system.
  82687. * 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.
  82688. * @param name The name of the particle system
  82689. * @param capacity The max number of particles alive at the same time
  82690. * @param scene The scene the particle system belongs to
  82691. * @param customEffect a custom effect used to change the way particles are rendered by default
  82692. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  82693. * @param epsilon Offset used to render the particles
  82694. */
  82695. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  82696. private _addFactorGradient;
  82697. private _removeFactorGradient;
  82698. /**
  82699. * Adds a new life time gradient
  82700. * @param gradient defines the gradient to use (between 0 and 1)
  82701. * @param factor defines the life time factor to affect to the specified gradient
  82702. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82703. * @returns the current particle system
  82704. */
  82705. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82706. /**
  82707. * Remove a specific life time gradient
  82708. * @param gradient defines the gradient to remove
  82709. * @returns the current particle system
  82710. */
  82711. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82712. /**
  82713. * Adds a new size gradient
  82714. * @param gradient defines the gradient to use (between 0 and 1)
  82715. * @param factor defines the size factor to affect to the specified gradient
  82716. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82717. * @returns the current particle system
  82718. */
  82719. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82720. /**
  82721. * Remove a specific size gradient
  82722. * @param gradient defines the gradient to remove
  82723. * @returns the current particle system
  82724. */
  82725. removeSizeGradient(gradient: number): IParticleSystem;
  82726. /**
  82727. * Adds a new color remap gradient
  82728. * @param gradient defines the gradient to use (between 0 and 1)
  82729. * @param min defines the color remap minimal range
  82730. * @param max defines the color remap maximal range
  82731. * @returns the current particle system
  82732. */
  82733. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82734. /**
  82735. * Remove a specific color remap gradient
  82736. * @param gradient defines the gradient to remove
  82737. * @returns the current particle system
  82738. */
  82739. removeColorRemapGradient(gradient: number): IParticleSystem;
  82740. /**
  82741. * Adds a new alpha remap gradient
  82742. * @param gradient defines the gradient to use (between 0 and 1)
  82743. * @param min defines the alpha remap minimal range
  82744. * @param max defines the alpha remap maximal range
  82745. * @returns the current particle system
  82746. */
  82747. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82748. /**
  82749. * Remove a specific alpha remap gradient
  82750. * @param gradient defines the gradient to remove
  82751. * @returns the current particle system
  82752. */
  82753. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  82754. /**
  82755. * Adds a new angular speed gradient
  82756. * @param gradient defines the gradient to use (between 0 and 1)
  82757. * @param factor defines the angular speed to affect to the specified gradient
  82758. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82759. * @returns the current particle system
  82760. */
  82761. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82762. /**
  82763. * Remove a specific angular speed gradient
  82764. * @param gradient defines the gradient to remove
  82765. * @returns the current particle system
  82766. */
  82767. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  82768. /**
  82769. * Adds a new velocity gradient
  82770. * @param gradient defines the gradient to use (between 0 and 1)
  82771. * @param factor defines the velocity to affect to the specified gradient
  82772. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82773. * @returns the current particle system
  82774. */
  82775. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82776. /**
  82777. * Remove a specific velocity gradient
  82778. * @param gradient defines the gradient to remove
  82779. * @returns the current particle system
  82780. */
  82781. removeVelocityGradient(gradient: number): IParticleSystem;
  82782. /**
  82783. * Adds a new limit velocity gradient
  82784. * @param gradient defines the gradient to use (between 0 and 1)
  82785. * @param factor defines the limit velocity value to affect to the specified gradient
  82786. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82787. * @returns the current particle system
  82788. */
  82789. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82790. /**
  82791. * Remove a specific limit velocity gradient
  82792. * @param gradient defines the gradient to remove
  82793. * @returns the current particle system
  82794. */
  82795. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  82796. /**
  82797. * Adds a new drag gradient
  82798. * @param gradient defines the gradient to use (between 0 and 1)
  82799. * @param factor defines the drag value to affect to the specified gradient
  82800. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82801. * @returns the current particle system
  82802. */
  82803. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82804. /**
  82805. * Remove a specific drag gradient
  82806. * @param gradient defines the gradient to remove
  82807. * @returns the current particle system
  82808. */
  82809. removeDragGradient(gradient: number): IParticleSystem;
  82810. /**
  82811. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  82812. * @param gradient defines the gradient to use (between 0 and 1)
  82813. * @param factor defines the emit rate value to affect to the specified gradient
  82814. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82815. * @returns the current particle system
  82816. */
  82817. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82818. /**
  82819. * Remove a specific emit rate gradient
  82820. * @param gradient defines the gradient to remove
  82821. * @returns the current particle system
  82822. */
  82823. removeEmitRateGradient(gradient: number): IParticleSystem;
  82824. /**
  82825. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  82826. * @param gradient defines the gradient to use (between 0 and 1)
  82827. * @param factor defines the start size value to affect to the specified gradient
  82828. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82829. * @returns the current particle system
  82830. */
  82831. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82832. /**
  82833. * Remove a specific start size gradient
  82834. * @param gradient defines the gradient to remove
  82835. * @returns the current particle system
  82836. */
  82837. removeStartSizeGradient(gradient: number): IParticleSystem;
  82838. private _createRampGradientTexture;
  82839. /**
  82840. * Gets the current list of ramp gradients.
  82841. * You must use addRampGradient and removeRampGradient to udpate this list
  82842. * @returns the list of ramp gradients
  82843. */
  82844. getRampGradients(): Nullable<Array<Color3Gradient>>;
  82845. /**
  82846. * Adds a new ramp gradient used to remap particle colors
  82847. * @param gradient defines the gradient to use (between 0 and 1)
  82848. * @param color defines the color to affect to the specified gradient
  82849. * @returns the current particle system
  82850. */
  82851. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  82852. /**
  82853. * Remove a specific ramp gradient
  82854. * @param gradient defines the gradient to remove
  82855. * @returns the current particle system
  82856. */
  82857. removeRampGradient(gradient: number): ParticleSystem;
  82858. /**
  82859. * Adds a new color gradient
  82860. * @param gradient defines the gradient to use (between 0 and 1)
  82861. * @param color1 defines the color to affect to the specified gradient
  82862. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  82863. * @returns this particle system
  82864. */
  82865. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  82866. /**
  82867. * Remove a specific color gradient
  82868. * @param gradient defines the gradient to remove
  82869. * @returns this particle system
  82870. */
  82871. removeColorGradient(gradient: number): IParticleSystem;
  82872. private _fetchR;
  82873. protected _reset(): void;
  82874. private _resetEffect;
  82875. private _createVertexBuffers;
  82876. private _createIndexBuffer;
  82877. /**
  82878. * Gets the maximum number of particles active at the same time.
  82879. * @returns The max number of active particles.
  82880. */
  82881. getCapacity(): number;
  82882. /**
  82883. * Gets whether there are still active particles in the system.
  82884. * @returns True if it is alive, otherwise false.
  82885. */
  82886. isAlive(): boolean;
  82887. /**
  82888. * Gets if the system has been started. (Note: this will still be true after stop is called)
  82889. * @returns True if it has been started, otherwise false.
  82890. */
  82891. isStarted(): boolean;
  82892. private _prepareSubEmitterInternalArray;
  82893. /**
  82894. * Starts the particle system and begins to emit
  82895. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  82896. */
  82897. start(delay?: number): void;
  82898. /**
  82899. * Stops the particle system.
  82900. * @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.
  82901. */
  82902. stop(stopSubEmitters?: boolean): void;
  82903. /**
  82904. * Remove all active particles
  82905. */
  82906. reset(): void;
  82907. /**
  82908. * @hidden (for internal use only)
  82909. */
  82910. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  82911. /**
  82912. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  82913. * Its lifetime will start back at 0.
  82914. */
  82915. recycleParticle: (particle: Particle) => void;
  82916. private _stopSubEmitters;
  82917. private _createParticle;
  82918. private _removeFromRoot;
  82919. private _emitFromParticle;
  82920. private _update;
  82921. /** @hidden */
  82922. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  82923. /** @hidden */
  82924. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  82925. /** @hidden */
  82926. private _getEffect;
  82927. /**
  82928. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  82929. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  82930. */
  82931. animate(preWarmOnly?: boolean): void;
  82932. private _appendParticleVertices;
  82933. /**
  82934. * Rebuilds the particle system.
  82935. */
  82936. rebuild(): void;
  82937. /**
  82938. * Is this system ready to be used/rendered
  82939. * @return true if the system is ready
  82940. */
  82941. isReady(): boolean;
  82942. private _render;
  82943. /**
  82944. * Renders the particle system in its current state.
  82945. * @returns the current number of particles
  82946. */
  82947. render(): number;
  82948. /**
  82949. * Disposes the particle system and free the associated resources
  82950. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  82951. */
  82952. dispose(disposeTexture?: boolean): void;
  82953. /**
  82954. * Clones the particle system.
  82955. * @param name The name of the cloned object
  82956. * @param newEmitter The new emitter to use
  82957. * @returns the cloned particle system
  82958. */
  82959. clone(name: string, newEmitter: any): ParticleSystem;
  82960. /**
  82961. * Serializes the particle system to a JSON object.
  82962. * @returns the JSON object
  82963. */
  82964. serialize(): any;
  82965. /** @hidden */
  82966. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  82967. /** @hidden */
  82968. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  82969. /**
  82970. * Parses a JSON object to create a particle system.
  82971. * @param parsedParticleSystem The JSON object to parse
  82972. * @param scene The scene to create the particle system in
  82973. * @param rootUrl The root url to use to load external dependencies like texture
  82974. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  82975. * @returns the Parsed particle system
  82976. */
  82977. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  82978. }
  82979. }
  82980. declare module BABYLON {
  82981. /**
  82982. * A particle represents one of the element emitted by a particle system.
  82983. * This is mainly define by its coordinates, direction, velocity and age.
  82984. */
  82985. export class Particle {
  82986. /**
  82987. * The particle system the particle belongs to.
  82988. */
  82989. particleSystem: ParticleSystem;
  82990. private static _Count;
  82991. /**
  82992. * Unique ID of the particle
  82993. */
  82994. id: number;
  82995. /**
  82996. * The world position of the particle in the scene.
  82997. */
  82998. position: Vector3;
  82999. /**
  83000. * The world direction of the particle in the scene.
  83001. */
  83002. direction: Vector3;
  83003. /**
  83004. * The color of the particle.
  83005. */
  83006. color: Color4;
  83007. /**
  83008. * The color change of the particle per step.
  83009. */
  83010. colorStep: Color4;
  83011. /**
  83012. * Defines how long will the life of the particle be.
  83013. */
  83014. lifeTime: number;
  83015. /**
  83016. * The current age of the particle.
  83017. */
  83018. age: number;
  83019. /**
  83020. * The current size of the particle.
  83021. */
  83022. size: number;
  83023. /**
  83024. * The current scale of the particle.
  83025. */
  83026. scale: Vector2;
  83027. /**
  83028. * The current angle of the particle.
  83029. */
  83030. angle: number;
  83031. /**
  83032. * Defines how fast is the angle changing.
  83033. */
  83034. angularSpeed: number;
  83035. /**
  83036. * Defines the cell index used by the particle to be rendered from a sprite.
  83037. */
  83038. cellIndex: number;
  83039. /**
  83040. * The information required to support color remapping
  83041. */
  83042. remapData: Vector4;
  83043. /** @hidden */
  83044. _randomCellOffset?: number;
  83045. /** @hidden */
  83046. _initialDirection: Nullable<Vector3>;
  83047. /** @hidden */
  83048. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  83049. /** @hidden */
  83050. _initialStartSpriteCellID: number;
  83051. /** @hidden */
  83052. _initialEndSpriteCellID: number;
  83053. /** @hidden */
  83054. _currentColorGradient: Nullable<ColorGradient>;
  83055. /** @hidden */
  83056. _currentColor1: Color4;
  83057. /** @hidden */
  83058. _currentColor2: Color4;
  83059. /** @hidden */
  83060. _currentSizeGradient: Nullable<FactorGradient>;
  83061. /** @hidden */
  83062. _currentSize1: number;
  83063. /** @hidden */
  83064. _currentSize2: number;
  83065. /** @hidden */
  83066. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  83067. /** @hidden */
  83068. _currentAngularSpeed1: number;
  83069. /** @hidden */
  83070. _currentAngularSpeed2: number;
  83071. /** @hidden */
  83072. _currentVelocityGradient: Nullable<FactorGradient>;
  83073. /** @hidden */
  83074. _currentVelocity1: number;
  83075. /** @hidden */
  83076. _currentVelocity2: number;
  83077. /** @hidden */
  83078. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  83079. /** @hidden */
  83080. _currentLimitVelocity1: number;
  83081. /** @hidden */
  83082. _currentLimitVelocity2: number;
  83083. /** @hidden */
  83084. _currentDragGradient: Nullable<FactorGradient>;
  83085. /** @hidden */
  83086. _currentDrag1: number;
  83087. /** @hidden */
  83088. _currentDrag2: number;
  83089. /** @hidden */
  83090. _randomNoiseCoordinates1: Vector3;
  83091. /** @hidden */
  83092. _randomNoiseCoordinates2: Vector3;
  83093. /**
  83094. * Creates a new instance Particle
  83095. * @param particleSystem the particle system the particle belongs to
  83096. */
  83097. constructor(
  83098. /**
  83099. * The particle system the particle belongs to.
  83100. */
  83101. particleSystem: ParticleSystem);
  83102. private updateCellInfoFromSystem;
  83103. /**
  83104. * Defines how the sprite cell index is updated for the particle
  83105. */
  83106. updateCellIndex(): void;
  83107. /** @hidden */
  83108. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  83109. /** @hidden */
  83110. _inheritParticleInfoToSubEmitters(): void;
  83111. /** @hidden */
  83112. _reset(): void;
  83113. /**
  83114. * Copy the properties of particle to another one.
  83115. * @param other the particle to copy the information to.
  83116. */
  83117. copyTo(other: Particle): void;
  83118. }
  83119. }
  83120. declare module BABYLON {
  83121. /**
  83122. * Particle emitter represents a volume emitting particles.
  83123. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  83124. */
  83125. export interface IParticleEmitterType {
  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(): IParticleEmitterType;
  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 the effect defines string
  83153. */
  83154. getEffectDefines(): string;
  83155. /**
  83156. * Returns a string representing the class name
  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 box.
  83175. * It emits the particles randomly between 2 given directions.
  83176. */
  83177. export class BoxParticleEmitter implements IParticleEmitterType {
  83178. /**
  83179. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83180. */
  83181. direction1: Vector3;
  83182. /**
  83183. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83184. */
  83185. direction2: Vector3;
  83186. /**
  83187. * 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.
  83188. */
  83189. minEmitBox: Vector3;
  83190. /**
  83191. * 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.
  83192. */
  83193. maxEmitBox: Vector3;
  83194. /**
  83195. * Creates a new instance BoxParticleEmitter
  83196. */
  83197. constructor();
  83198. /**
  83199. * Called by the particle System when the direction is computed for the created particle.
  83200. * @param worldMatrix is the world matrix of the particle system
  83201. * @param directionToUpdate is the direction vector to update with the result
  83202. * @param particle is the particle we are computed the direction for
  83203. */
  83204. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83205. /**
  83206. * Called by the particle System when the position is computed for the created particle.
  83207. * @param worldMatrix is the world matrix of the particle system
  83208. * @param positionToUpdate is the position vector to update with the result
  83209. * @param particle is the particle we are computed the position for
  83210. */
  83211. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83212. /**
  83213. * Clones the current emitter and returns a copy of it
  83214. * @returns the new emitter
  83215. */
  83216. clone(): BoxParticleEmitter;
  83217. /**
  83218. * Called by the GPUParticleSystem to setup the update shader
  83219. * @param effect defines the update shader
  83220. */
  83221. applyToShader(effect: Effect): void;
  83222. /**
  83223. * Returns a string to use to update the GPU particles update shader
  83224. * @returns a string containng the defines string
  83225. */
  83226. getEffectDefines(): string;
  83227. /**
  83228. * Returns the string "BoxParticleEmitter"
  83229. * @returns a string containing the class name
  83230. */
  83231. getClassName(): string;
  83232. /**
  83233. * Serializes the particle system to a JSON object.
  83234. * @returns the JSON object
  83235. */
  83236. serialize(): any;
  83237. /**
  83238. * Parse properties from a JSON object
  83239. * @param serializationObject defines the JSON object
  83240. */
  83241. parse(serializationObject: any): void;
  83242. }
  83243. }
  83244. declare module BABYLON {
  83245. /**
  83246. * Particle emitter emitting particles from the inside of a cone.
  83247. * It emits the particles alongside the cone volume from the base to the particle.
  83248. * The emission direction might be randomized.
  83249. */
  83250. export class ConeParticleEmitter implements IParticleEmitterType {
  83251. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83252. directionRandomizer: number;
  83253. private _radius;
  83254. private _angle;
  83255. private _height;
  83256. /**
  83257. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  83258. */
  83259. radiusRange: number;
  83260. /**
  83261. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  83262. */
  83263. heightRange: number;
  83264. /**
  83265. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  83266. */
  83267. emitFromSpawnPointOnly: boolean;
  83268. /**
  83269. * Gets or sets the radius of the emission cone
  83270. */
  83271. radius: number;
  83272. /**
  83273. * Gets or sets the angle of the emission cone
  83274. */
  83275. angle: number;
  83276. private _buildHeight;
  83277. /**
  83278. * Creates a new instance ConeParticleEmitter
  83279. * @param radius the radius of the emission cone (1 by default)
  83280. * @param angle the cone base angle (PI by default)
  83281. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  83282. */
  83283. constructor(radius?: number, angle?: number,
  83284. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83285. directionRandomizer?: number);
  83286. /**
  83287. * Called by the particle System when the direction is computed for the created particle.
  83288. * @param worldMatrix is the world matrix of the particle system
  83289. * @param directionToUpdate is the direction vector to update with the result
  83290. * @param particle is the particle we are computed the direction for
  83291. */
  83292. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83293. /**
  83294. * Called by the particle System when the position is computed for the created particle.
  83295. * @param worldMatrix is the world matrix of the particle system
  83296. * @param positionToUpdate is the position vector to update with the result
  83297. * @param particle is the particle we are computed the position for
  83298. */
  83299. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83300. /**
  83301. * Clones the current emitter and returns a copy of it
  83302. * @returns the new emitter
  83303. */
  83304. clone(): ConeParticleEmitter;
  83305. /**
  83306. * Called by the GPUParticleSystem to setup the update shader
  83307. * @param effect defines the update shader
  83308. */
  83309. applyToShader(effect: Effect): void;
  83310. /**
  83311. * Returns a string to use to update the GPU particles update shader
  83312. * @returns a string containng the defines string
  83313. */
  83314. getEffectDefines(): string;
  83315. /**
  83316. * Returns the string "ConeParticleEmitter"
  83317. * @returns a string containing the class name
  83318. */
  83319. getClassName(): string;
  83320. /**
  83321. * Serializes the particle system to a JSON object.
  83322. * @returns the JSON object
  83323. */
  83324. serialize(): any;
  83325. /**
  83326. * Parse properties from a JSON object
  83327. * @param serializationObject defines the JSON object
  83328. */
  83329. parse(serializationObject: any): void;
  83330. }
  83331. }
  83332. declare module BABYLON {
  83333. /**
  83334. * Particle emitter emitting particles from the inside of a cylinder.
  83335. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  83336. */
  83337. export class CylinderParticleEmitter implements IParticleEmitterType {
  83338. /**
  83339. * The radius of the emission cylinder.
  83340. */
  83341. radius: number;
  83342. /**
  83343. * The height of the emission cylinder.
  83344. */
  83345. height: number;
  83346. /**
  83347. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83348. */
  83349. radiusRange: number;
  83350. /**
  83351. * How much to randomize the particle direction [0-1].
  83352. */
  83353. directionRandomizer: number;
  83354. /**
  83355. * Creates a new instance CylinderParticleEmitter
  83356. * @param radius the radius of the emission cylinder (1 by default)
  83357. * @param height the height of the emission cylinder (1 by default)
  83358. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83359. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83360. */
  83361. constructor(
  83362. /**
  83363. * The radius of the emission cylinder.
  83364. */
  83365. radius?: number,
  83366. /**
  83367. * The height of the emission cylinder.
  83368. */
  83369. height?: number,
  83370. /**
  83371. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83372. */
  83373. radiusRange?: number,
  83374. /**
  83375. * How much to randomize the particle direction [0-1].
  83376. */
  83377. directionRandomizer?: number);
  83378. /**
  83379. * Called by the particle System when the direction is computed for the created particle.
  83380. * @param worldMatrix is the world matrix of the particle system
  83381. * @param directionToUpdate is the direction vector to update with the result
  83382. * @param particle is the particle we are computed the direction for
  83383. */
  83384. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83385. /**
  83386. * Called by the particle System when the position is computed for the created particle.
  83387. * @param worldMatrix is the world matrix of the particle system
  83388. * @param positionToUpdate is the position vector to update with the result
  83389. * @param particle is the particle we are computed the position for
  83390. */
  83391. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83392. /**
  83393. * Clones the current emitter and returns a copy of it
  83394. * @returns the new emitter
  83395. */
  83396. clone(): CylinderParticleEmitter;
  83397. /**
  83398. * Called by the GPUParticleSystem to setup the update shader
  83399. * @param effect defines the update shader
  83400. */
  83401. applyToShader(effect: Effect): void;
  83402. /**
  83403. * Returns a string to use to update the GPU particles update shader
  83404. * @returns a string containng the defines string
  83405. */
  83406. getEffectDefines(): string;
  83407. /**
  83408. * Returns the string "CylinderParticleEmitter"
  83409. * @returns a string containing the class name
  83410. */
  83411. getClassName(): string;
  83412. /**
  83413. * Serializes the particle system to a JSON object.
  83414. * @returns the JSON object
  83415. */
  83416. serialize(): any;
  83417. /**
  83418. * Parse properties from a JSON object
  83419. * @param serializationObject defines the JSON object
  83420. */
  83421. parse(serializationObject: any): void;
  83422. }
  83423. /**
  83424. * Particle emitter emitting particles from the inside of a cylinder.
  83425. * It emits the particles randomly between two vectors.
  83426. */
  83427. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  83428. /**
  83429. * The min limit of the emission direction.
  83430. */
  83431. direction1: Vector3;
  83432. /**
  83433. * The max limit of the emission direction.
  83434. */
  83435. direction2: Vector3;
  83436. /**
  83437. * Creates a new instance CylinderDirectedParticleEmitter
  83438. * @param radius the radius of the emission cylinder (1 by default)
  83439. * @param height the height of the emission cylinder (1 by default)
  83440. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83441. * @param direction1 the min limit of the emission direction (up vector by default)
  83442. * @param direction2 the max limit of the emission direction (up vector by default)
  83443. */
  83444. constructor(radius?: number, height?: number, radiusRange?: number,
  83445. /**
  83446. * The min limit of the emission direction.
  83447. */
  83448. direction1?: Vector3,
  83449. /**
  83450. * The max limit of the emission direction.
  83451. */
  83452. direction2?: Vector3);
  83453. /**
  83454. * Called by the particle System when the direction is computed for the created particle.
  83455. * @param worldMatrix is the world matrix of the particle system
  83456. * @param directionToUpdate is the direction vector to update with the result
  83457. * @param particle is the particle we are computed the direction for
  83458. */
  83459. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83460. /**
  83461. * Clones the current emitter and returns a copy of it
  83462. * @returns the new emitter
  83463. */
  83464. clone(): CylinderDirectedParticleEmitter;
  83465. /**
  83466. * Called by the GPUParticleSystem to setup the update shader
  83467. * @param effect defines the update shader
  83468. */
  83469. applyToShader(effect: Effect): void;
  83470. /**
  83471. * Returns a string to use to update the GPU particles update shader
  83472. * @returns a string containng the defines string
  83473. */
  83474. getEffectDefines(): string;
  83475. /**
  83476. * Returns the string "CylinderDirectedParticleEmitter"
  83477. * @returns a string containing the class name
  83478. */
  83479. getClassName(): string;
  83480. /**
  83481. * Serializes the particle system to a JSON object.
  83482. * @returns the JSON object
  83483. */
  83484. serialize(): any;
  83485. /**
  83486. * Parse properties from a JSON object
  83487. * @param serializationObject defines the JSON object
  83488. */
  83489. parse(serializationObject: any): void;
  83490. }
  83491. }
  83492. declare module BABYLON {
  83493. /**
  83494. * Particle emitter emitting particles from the inside of a hemisphere.
  83495. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  83496. */
  83497. export class HemisphericParticleEmitter implements IParticleEmitterType {
  83498. /**
  83499. * The radius of the emission hemisphere.
  83500. */
  83501. radius: number;
  83502. /**
  83503. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83504. */
  83505. radiusRange: number;
  83506. /**
  83507. * How much to randomize the particle direction [0-1].
  83508. */
  83509. directionRandomizer: number;
  83510. /**
  83511. * Creates a new instance HemisphericParticleEmitter
  83512. * @param radius the radius of the emission hemisphere (1 by default)
  83513. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83514. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83515. */
  83516. constructor(
  83517. /**
  83518. * The radius of the emission hemisphere.
  83519. */
  83520. radius?: number,
  83521. /**
  83522. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83523. */
  83524. radiusRange?: number,
  83525. /**
  83526. * How much to randomize the particle direction [0-1].
  83527. */
  83528. directionRandomizer?: number);
  83529. /**
  83530. * Called by the particle System when the direction is computed for the created particle.
  83531. * @param worldMatrix is the world matrix of the particle system
  83532. * @param directionToUpdate is the direction vector to update with the result
  83533. * @param particle is the particle we are computed the direction for
  83534. */
  83535. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83536. /**
  83537. * Called by the particle System when the position is computed for the created particle.
  83538. * @param worldMatrix is the world matrix of the particle system
  83539. * @param positionToUpdate is the position vector to update with the result
  83540. * @param particle is the particle we are computed the position for
  83541. */
  83542. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83543. /**
  83544. * Clones the current emitter and returns a copy of it
  83545. * @returns the new emitter
  83546. */
  83547. clone(): HemisphericParticleEmitter;
  83548. /**
  83549. * Called by the GPUParticleSystem to setup the update shader
  83550. * @param effect defines the update shader
  83551. */
  83552. applyToShader(effect: Effect): void;
  83553. /**
  83554. * Returns a string to use to update the GPU particles update shader
  83555. * @returns a string containng the defines string
  83556. */
  83557. getEffectDefines(): string;
  83558. /**
  83559. * Returns the string "HemisphericParticleEmitter"
  83560. * @returns a string containing the class name
  83561. */
  83562. getClassName(): string;
  83563. /**
  83564. * Serializes the particle system to a JSON object.
  83565. * @returns the JSON object
  83566. */
  83567. serialize(): any;
  83568. /**
  83569. * Parse properties from a JSON object
  83570. * @param serializationObject defines the JSON object
  83571. */
  83572. parse(serializationObject: any): void;
  83573. }
  83574. }
  83575. declare module BABYLON {
  83576. /**
  83577. * Particle emitter emitting particles from a point.
  83578. * It emits the particles randomly between 2 given directions.
  83579. */
  83580. export class PointParticleEmitter implements IParticleEmitterType {
  83581. /**
  83582. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83583. */
  83584. direction1: Vector3;
  83585. /**
  83586. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83587. */
  83588. direction2: Vector3;
  83589. /**
  83590. * Creates a new instance PointParticleEmitter
  83591. */
  83592. constructor();
  83593. /**
  83594. * Called by the particle System when the direction is computed for the created particle.
  83595. * @param worldMatrix is the world matrix of the particle system
  83596. * @param directionToUpdate is the direction vector to update with the result
  83597. * @param particle is the particle we are computed the direction for
  83598. */
  83599. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83600. /**
  83601. * Called by the particle System when the position is computed for the created particle.
  83602. * @param worldMatrix is the world matrix of the particle system
  83603. * @param positionToUpdate is the position vector to update with the result
  83604. * @param particle is the particle we are computed the position for
  83605. */
  83606. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83607. /**
  83608. * Clones the current emitter and returns a copy of it
  83609. * @returns the new emitter
  83610. */
  83611. clone(): PointParticleEmitter;
  83612. /**
  83613. * Called by the GPUParticleSystem to setup the update shader
  83614. * @param effect defines the update shader
  83615. */
  83616. applyToShader(effect: Effect): void;
  83617. /**
  83618. * Returns a string to use to update the GPU particles update shader
  83619. * @returns a string containng the defines string
  83620. */
  83621. getEffectDefines(): string;
  83622. /**
  83623. * Returns the string "PointParticleEmitter"
  83624. * @returns a string containing the class name
  83625. */
  83626. getClassName(): string;
  83627. /**
  83628. * Serializes the particle system to a JSON object.
  83629. * @returns the JSON object
  83630. */
  83631. serialize(): any;
  83632. /**
  83633. * Parse properties from a JSON object
  83634. * @param serializationObject defines the JSON object
  83635. */
  83636. parse(serializationObject: any): void;
  83637. }
  83638. }
  83639. declare module BABYLON {
  83640. /**
  83641. * Particle emitter emitting particles from the inside of a sphere.
  83642. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  83643. */
  83644. export class SphereParticleEmitter implements IParticleEmitterType {
  83645. /**
  83646. * The radius of the emission sphere.
  83647. */
  83648. radius: number;
  83649. /**
  83650. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83651. */
  83652. radiusRange: number;
  83653. /**
  83654. * How much to randomize the particle direction [0-1].
  83655. */
  83656. directionRandomizer: number;
  83657. /**
  83658. * Creates a new instance SphereParticleEmitter
  83659. * @param radius the radius of the emission sphere (1 by default)
  83660. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83661. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83662. */
  83663. constructor(
  83664. /**
  83665. * The radius of the emission sphere.
  83666. */
  83667. radius?: number,
  83668. /**
  83669. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83670. */
  83671. radiusRange?: number,
  83672. /**
  83673. * How much to randomize the particle direction [0-1].
  83674. */
  83675. directionRandomizer?: number);
  83676. /**
  83677. * Called by the particle System when the direction is computed for the created particle.
  83678. * @param worldMatrix is the world matrix of the particle system
  83679. * @param directionToUpdate is the direction vector to update with the result
  83680. * @param particle is the particle we are computed the direction for
  83681. */
  83682. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83683. /**
  83684. * Called by the particle System when the position is computed for the created particle.
  83685. * @param worldMatrix is the world matrix of the particle system
  83686. * @param positionToUpdate is the position vector to update with the result
  83687. * @param particle is the particle we are computed the position for
  83688. */
  83689. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83690. /**
  83691. * Clones the current emitter and returns a copy of it
  83692. * @returns the new emitter
  83693. */
  83694. clone(): SphereParticleEmitter;
  83695. /**
  83696. * Called by the GPUParticleSystem to setup the update shader
  83697. * @param effect defines the update shader
  83698. */
  83699. applyToShader(effect: Effect): void;
  83700. /**
  83701. * Returns a string to use to update the GPU particles update shader
  83702. * @returns a string containng the defines string
  83703. */
  83704. getEffectDefines(): string;
  83705. /**
  83706. * Returns the string "SphereParticleEmitter"
  83707. * @returns a string containing the class name
  83708. */
  83709. getClassName(): string;
  83710. /**
  83711. * Serializes the particle system to a JSON object.
  83712. * @returns the JSON object
  83713. */
  83714. serialize(): any;
  83715. /**
  83716. * Parse properties from a JSON object
  83717. * @param serializationObject defines the JSON object
  83718. */
  83719. parse(serializationObject: any): void;
  83720. }
  83721. /**
  83722. * Particle emitter emitting particles from the inside of a sphere.
  83723. * It emits the particles randomly between two vectors.
  83724. */
  83725. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  83726. /**
  83727. * The min limit of the emission direction.
  83728. */
  83729. direction1: Vector3;
  83730. /**
  83731. * The max limit of the emission direction.
  83732. */
  83733. direction2: Vector3;
  83734. /**
  83735. * Creates a new instance SphereDirectedParticleEmitter
  83736. * @param radius the radius of the emission sphere (1 by default)
  83737. * @param direction1 the min limit of the emission direction (up vector by default)
  83738. * @param direction2 the max limit of the emission direction (up vector by default)
  83739. */
  83740. constructor(radius?: number,
  83741. /**
  83742. * The min limit of the emission direction.
  83743. */
  83744. direction1?: Vector3,
  83745. /**
  83746. * The max limit of the emission direction.
  83747. */
  83748. direction2?: Vector3);
  83749. /**
  83750. * Called by the particle System when the direction is computed for the created particle.
  83751. * @param worldMatrix is the world matrix of the particle system
  83752. * @param directionToUpdate is the direction vector to update with the result
  83753. * @param particle is the particle we are computed the direction for
  83754. */
  83755. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83756. /**
  83757. * Clones the current emitter and returns a copy of it
  83758. * @returns the new emitter
  83759. */
  83760. clone(): SphereDirectedParticleEmitter;
  83761. /**
  83762. * Called by the GPUParticleSystem to setup the update shader
  83763. * @param effect defines the update shader
  83764. */
  83765. applyToShader(effect: Effect): void;
  83766. /**
  83767. * Returns a string to use to update the GPU particles update shader
  83768. * @returns a string containng the defines string
  83769. */
  83770. getEffectDefines(): string;
  83771. /**
  83772. * Returns the string "SphereDirectedParticleEmitter"
  83773. * @returns a string containing the class name
  83774. */
  83775. getClassName(): string;
  83776. /**
  83777. * Serializes the particle system to a JSON object.
  83778. * @returns the JSON object
  83779. */
  83780. serialize(): any;
  83781. /**
  83782. * Parse properties from a JSON object
  83783. * @param serializationObject defines the JSON object
  83784. */
  83785. parse(serializationObject: any): void;
  83786. }
  83787. }
  83788. declare module BABYLON {
  83789. /**
  83790. * Interface representing a particle system in Babylon.js.
  83791. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  83792. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  83793. */
  83794. export interface IParticleSystem {
  83795. /**
  83796. * List of animations used by the particle system.
  83797. */
  83798. animations: Animation[];
  83799. /**
  83800. * The id of the Particle system.
  83801. */
  83802. id: string;
  83803. /**
  83804. * The name of the Particle system.
  83805. */
  83806. name: string;
  83807. /**
  83808. * The emitter represents the Mesh or position we are attaching the particle system to.
  83809. */
  83810. emitter: Nullable<AbstractMesh | Vector3>;
  83811. /**
  83812. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83813. */
  83814. isBillboardBased: boolean;
  83815. /**
  83816. * The rendering group used by the Particle system to chose when to render.
  83817. */
  83818. renderingGroupId: number;
  83819. /**
  83820. * The layer mask we are rendering the particles through.
  83821. */
  83822. layerMask: number;
  83823. /**
  83824. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83825. */
  83826. updateSpeed: number;
  83827. /**
  83828. * The amount of time the particle system is running (depends of the overall update speed).
  83829. */
  83830. targetStopDuration: number;
  83831. /**
  83832. * The texture used to render each particle. (this can be a spritesheet)
  83833. */
  83834. particleTexture: Nullable<Texture>;
  83835. /**
  83836. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  83837. */
  83838. blendMode: number;
  83839. /**
  83840. * Minimum life time of emitting particles.
  83841. */
  83842. minLifeTime: number;
  83843. /**
  83844. * Maximum life time of emitting particles.
  83845. */
  83846. maxLifeTime: number;
  83847. /**
  83848. * Minimum Size of emitting particles.
  83849. */
  83850. minSize: number;
  83851. /**
  83852. * Maximum Size of emitting particles.
  83853. */
  83854. maxSize: number;
  83855. /**
  83856. * Minimum scale of emitting particles on X axis.
  83857. */
  83858. minScaleX: number;
  83859. /**
  83860. * Maximum scale of emitting particles on X axis.
  83861. */
  83862. maxScaleX: number;
  83863. /**
  83864. * Minimum scale of emitting particles on Y axis.
  83865. */
  83866. minScaleY: number;
  83867. /**
  83868. * Maximum scale of emitting particles on Y axis.
  83869. */
  83870. maxScaleY: number;
  83871. /**
  83872. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83873. */
  83874. color1: Color4;
  83875. /**
  83876. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83877. */
  83878. color2: Color4;
  83879. /**
  83880. * Color the particle will have at the end of its lifetime.
  83881. */
  83882. colorDead: Color4;
  83883. /**
  83884. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  83885. */
  83886. emitRate: number;
  83887. /**
  83888. * You can use gravity if you want to give an orientation to your particles.
  83889. */
  83890. gravity: Vector3;
  83891. /**
  83892. * Minimum power of emitting particles.
  83893. */
  83894. minEmitPower: number;
  83895. /**
  83896. * Maximum power of emitting particles.
  83897. */
  83898. maxEmitPower: number;
  83899. /**
  83900. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83901. */
  83902. minAngularSpeed: number;
  83903. /**
  83904. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83905. */
  83906. maxAngularSpeed: number;
  83907. /**
  83908. * Gets or sets the minimal initial rotation in radians.
  83909. */
  83910. minInitialRotation: number;
  83911. /**
  83912. * Gets or sets the maximal initial rotation in radians.
  83913. */
  83914. maxInitialRotation: number;
  83915. /**
  83916. * The particle emitter type defines the emitter used by the particle system.
  83917. * It can be for example box, sphere, or cone...
  83918. */
  83919. particleEmitterType: Nullable<IParticleEmitterType>;
  83920. /**
  83921. * Defines the delay in milliseconds before starting the system (0 by default)
  83922. */
  83923. startDelay: number;
  83924. /**
  83925. * 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
  83926. */
  83927. preWarmCycles: number;
  83928. /**
  83929. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  83930. */
  83931. preWarmStepOffset: number;
  83932. /**
  83933. * 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)
  83934. */
  83935. spriteCellChangeSpeed: number;
  83936. /**
  83937. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83938. */
  83939. startSpriteCellID: number;
  83940. /**
  83941. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83942. */
  83943. endSpriteCellID: number;
  83944. /**
  83945. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83946. */
  83947. spriteCellWidth: number;
  83948. /**
  83949. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83950. */
  83951. spriteCellHeight: number;
  83952. /**
  83953. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83954. */
  83955. spriteRandomStartCell: boolean;
  83956. /**
  83957. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  83958. */
  83959. isAnimationSheetEnabled: boolean;
  83960. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83961. translationPivot: Vector2;
  83962. /**
  83963. * Gets or sets a texture used to add random noise to particle positions
  83964. */
  83965. noiseTexture: Nullable<BaseTexture>;
  83966. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83967. noiseStrength: Vector3;
  83968. /**
  83969. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83970. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83971. */
  83972. billboardMode: number;
  83973. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83974. limitVelocityDamping: number;
  83975. /**
  83976. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83977. */
  83978. beginAnimationOnStart: boolean;
  83979. /**
  83980. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83981. */
  83982. beginAnimationFrom: number;
  83983. /**
  83984. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83985. */
  83986. beginAnimationTo: number;
  83987. /**
  83988. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83989. */
  83990. beginAnimationLoop: boolean;
  83991. /**
  83992. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83993. */
  83994. disposeOnStop: boolean;
  83995. /**
  83996. * Gets the maximum number of particles active at the same time.
  83997. * @returns The max number of active particles.
  83998. */
  83999. getCapacity(): number;
  84000. /**
  84001. * Gets if the system has been started. (Note: this will still be true after stop is called)
  84002. * @returns True if it has been started, otherwise false.
  84003. */
  84004. isStarted(): boolean;
  84005. /**
  84006. * Animates the particle system for this frame.
  84007. */
  84008. animate(): void;
  84009. /**
  84010. * Renders the particle system in its current state.
  84011. * @returns the current number of particles
  84012. */
  84013. render(): number;
  84014. /**
  84015. * Dispose the particle system and frees its associated resources.
  84016. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  84017. */
  84018. dispose(disposeTexture?: boolean): void;
  84019. /**
  84020. * Clones the particle system.
  84021. * @param name The name of the cloned object
  84022. * @param newEmitter The new emitter to use
  84023. * @returns the cloned particle system
  84024. */
  84025. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  84026. /**
  84027. * Serializes the particle system to a JSON object.
  84028. * @returns the JSON object
  84029. */
  84030. serialize(): any;
  84031. /**
  84032. * Rebuild the particle system
  84033. */
  84034. rebuild(): void;
  84035. /**
  84036. * Starts the particle system and begins to emit
  84037. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  84038. */
  84039. start(delay?: number): void;
  84040. /**
  84041. * Stops the particle system.
  84042. */
  84043. stop(): void;
  84044. /**
  84045. * Remove all active particles
  84046. */
  84047. reset(): void;
  84048. /**
  84049. * Is this system ready to be used/rendered
  84050. * @return true if the system is ready
  84051. */
  84052. isReady(): boolean;
  84053. /**
  84054. * Adds a new color gradient
  84055. * @param gradient defines the gradient to use (between 0 and 1)
  84056. * @param color1 defines the color to affect to the specified gradient
  84057. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  84058. * @returns the current particle system
  84059. */
  84060. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  84061. /**
  84062. * Remove a specific color gradient
  84063. * @param gradient defines the gradient to remove
  84064. * @returns the current particle system
  84065. */
  84066. removeColorGradient(gradient: number): IParticleSystem;
  84067. /**
  84068. * Adds a new size gradient
  84069. * @param gradient defines the gradient to use (between 0 and 1)
  84070. * @param factor defines the size factor to affect to the specified gradient
  84071. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84072. * @returns the current particle system
  84073. */
  84074. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84075. /**
  84076. * Remove a specific size gradient
  84077. * @param gradient defines the gradient to remove
  84078. * @returns the current particle system
  84079. */
  84080. removeSizeGradient(gradient: number): IParticleSystem;
  84081. /**
  84082. * Gets the current list of color gradients.
  84083. * You must use addColorGradient and removeColorGradient to udpate this list
  84084. * @returns the list of color gradients
  84085. */
  84086. getColorGradients(): Nullable<Array<ColorGradient>>;
  84087. /**
  84088. * Gets the current list of size gradients.
  84089. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84090. * @returns the list of size gradients
  84091. */
  84092. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84093. /**
  84094. * Gets the current list of angular speed gradients.
  84095. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84096. * @returns the list of angular speed gradients
  84097. */
  84098. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84099. /**
  84100. * Adds a new angular speed gradient
  84101. * @param gradient defines the gradient to use (between 0 and 1)
  84102. * @param factor defines the angular speed to affect to the specified gradient
  84103. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84104. * @returns the current particle system
  84105. */
  84106. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84107. /**
  84108. * Remove a specific angular speed gradient
  84109. * @param gradient defines the gradient to remove
  84110. * @returns the current particle system
  84111. */
  84112. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84113. /**
  84114. * Gets the current list of velocity gradients.
  84115. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84116. * @returns the list of velocity gradients
  84117. */
  84118. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84119. /**
  84120. * Adds a new velocity gradient
  84121. * @param gradient defines the gradient to use (between 0 and 1)
  84122. * @param factor defines the velocity to affect to the specified gradient
  84123. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84124. * @returns the current particle system
  84125. */
  84126. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84127. /**
  84128. * Remove a specific velocity gradient
  84129. * @param gradient defines the gradient to remove
  84130. * @returns the current particle system
  84131. */
  84132. removeVelocityGradient(gradient: number): IParticleSystem;
  84133. /**
  84134. * Gets the current list of limit velocity gradients.
  84135. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84136. * @returns the list of limit velocity gradients
  84137. */
  84138. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84139. /**
  84140. * Adds a new limit velocity gradient
  84141. * @param gradient defines the gradient to use (between 0 and 1)
  84142. * @param factor defines the limit velocity to affect to the specified gradient
  84143. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84144. * @returns the current particle system
  84145. */
  84146. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84147. /**
  84148. * Remove a specific limit velocity gradient
  84149. * @param gradient defines the gradient to remove
  84150. * @returns the current particle system
  84151. */
  84152. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  84153. /**
  84154. * Adds a new drag gradient
  84155. * @param gradient defines the gradient to use (between 0 and 1)
  84156. * @param factor defines the drag to affect to the specified gradient
  84157. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84158. * @returns the current particle system
  84159. */
  84160. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84161. /**
  84162. * Remove a specific drag gradient
  84163. * @param gradient defines the gradient to remove
  84164. * @returns the current particle system
  84165. */
  84166. removeDragGradient(gradient: number): IParticleSystem;
  84167. /**
  84168. * Gets the current list of drag gradients.
  84169. * You must use addDragGradient and removeDragGradient to udpate this list
  84170. * @returns the list of drag gradients
  84171. */
  84172. getDragGradients(): Nullable<Array<FactorGradient>>;
  84173. /**
  84174. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84175. * @param gradient defines the gradient to use (between 0 and 1)
  84176. * @param factor defines the emit rate to affect to the specified gradient
  84177. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84178. * @returns the current particle system
  84179. */
  84180. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84181. /**
  84182. * Remove a specific emit rate gradient
  84183. * @param gradient defines the gradient to remove
  84184. * @returns the current particle system
  84185. */
  84186. removeEmitRateGradient(gradient: number): IParticleSystem;
  84187. /**
  84188. * Gets the current list of emit rate gradients.
  84189. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84190. * @returns the list of emit rate gradients
  84191. */
  84192. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84193. /**
  84194. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84195. * @param gradient defines the gradient to use (between 0 and 1)
  84196. * @param factor defines the start size to affect to the specified gradient
  84197. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84198. * @returns the current particle system
  84199. */
  84200. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84201. /**
  84202. * Remove a specific start size gradient
  84203. * @param gradient defines the gradient to remove
  84204. * @returns the current particle system
  84205. */
  84206. removeStartSizeGradient(gradient: number): IParticleSystem;
  84207. /**
  84208. * Gets the current list of start size gradients.
  84209. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84210. * @returns the list of start size gradients
  84211. */
  84212. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84213. /**
  84214. * Adds a new life time gradient
  84215. * @param gradient defines the gradient to use (between 0 and 1)
  84216. * @param factor defines the life time factor to affect to the specified gradient
  84217. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84218. * @returns the current particle system
  84219. */
  84220. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84221. /**
  84222. * Remove a specific life time gradient
  84223. * @param gradient defines the gradient to remove
  84224. * @returns the current particle system
  84225. */
  84226. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84227. /**
  84228. * Gets the current list of life time gradients.
  84229. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84230. * @returns the list of life time gradients
  84231. */
  84232. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84233. /**
  84234. * Gets the current list of color gradients.
  84235. * You must use addColorGradient and removeColorGradient to udpate this list
  84236. * @returns the list of color gradients
  84237. */
  84238. getColorGradients(): Nullable<Array<ColorGradient>>;
  84239. /**
  84240. * Adds a new ramp gradient used to remap particle colors
  84241. * @param gradient defines the gradient to use (between 0 and 1)
  84242. * @param color defines the color to affect to the specified gradient
  84243. * @returns the current particle system
  84244. */
  84245. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  84246. /**
  84247. * Gets the current list of ramp gradients.
  84248. * You must use addRampGradient and removeRampGradient to udpate this list
  84249. * @returns the list of ramp gradients
  84250. */
  84251. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84252. /** Gets or sets a boolean indicating that ramp gradients must be used
  84253. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84254. */
  84255. useRampGradients: boolean;
  84256. /**
  84257. * Adds a new color remap gradient
  84258. * @param gradient defines the gradient to use (between 0 and 1)
  84259. * @param min defines the color remap minimal range
  84260. * @param max defines the color remap maximal range
  84261. * @returns the current particle system
  84262. */
  84263. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84264. /**
  84265. * Gets the current list of color remap gradients.
  84266. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84267. * @returns the list of color remap gradients
  84268. */
  84269. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84270. /**
  84271. * Adds a new alpha remap gradient
  84272. * @param gradient defines the gradient to use (between 0 and 1)
  84273. * @param min defines the alpha remap minimal range
  84274. * @param max defines the alpha remap maximal range
  84275. * @returns the current particle system
  84276. */
  84277. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84278. /**
  84279. * Gets the current list of alpha remap gradients.
  84280. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84281. * @returns the list of alpha remap gradients
  84282. */
  84283. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84284. /**
  84285. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84286. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84287. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84288. * @returns the emitter
  84289. */
  84290. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84291. /**
  84292. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84293. * @param radius The radius of the hemisphere to emit from
  84294. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84295. * @returns the emitter
  84296. */
  84297. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  84298. /**
  84299. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84300. * @param radius The radius of the sphere to emit from
  84301. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84302. * @returns the emitter
  84303. */
  84304. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  84305. /**
  84306. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84307. * @param radius The radius of the sphere to emit from
  84308. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84309. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84310. * @returns the emitter
  84311. */
  84312. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84313. /**
  84314. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84315. * @param radius The radius of the emission cylinder
  84316. * @param height The height of the emission cylinder
  84317. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84318. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84319. * @returns the emitter
  84320. */
  84321. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  84322. /**
  84323. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84324. * @param radius The radius of the cylinder to emit from
  84325. * @param height The height of the emission cylinder
  84326. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84327. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84328. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84329. * @returns the emitter
  84330. */
  84331. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84332. /**
  84333. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84334. * @param radius The radius of the cone to emit from
  84335. * @param angle The base angle of the cone
  84336. * @returns the emitter
  84337. */
  84338. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  84339. /**
  84340. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84341. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84342. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84343. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84344. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84345. * @returns the emitter
  84346. */
  84347. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84348. /**
  84349. * Get hosting scene
  84350. * @returns the scene
  84351. */
  84352. getScene(): Scene;
  84353. }
  84354. }
  84355. declare module BABYLON {
  84356. /** @hidden */
  84357. export var linePixelShader: {
  84358. name: string;
  84359. shader: string;
  84360. };
  84361. }
  84362. declare module BABYLON {
  84363. /** @hidden */
  84364. export var lineVertexShader: {
  84365. name: string;
  84366. shader: string;
  84367. };
  84368. }
  84369. declare module BABYLON {
  84370. interface AbstractMesh {
  84371. /**
  84372. * Gets the edgesRenderer associated with the mesh
  84373. */
  84374. edgesRenderer: Nullable<EdgesRenderer>;
  84375. }
  84376. interface LinesMesh {
  84377. /**
  84378. * Enables the edge rendering mode on the mesh.
  84379. * This mode makes the mesh edges visible
  84380. * @param epsilon defines the maximal distance between two angles to detect a face
  84381. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  84382. * @returns the currentAbstractMesh
  84383. * @see https://www.babylonjs-playground.com/#19O9TU#0
  84384. */
  84385. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  84386. }
  84387. interface InstancedLinesMesh {
  84388. /**
  84389. * Enables the edge rendering mode on the mesh.
  84390. * This mode makes the mesh edges visible
  84391. * @param epsilon defines the maximal distance between two angles to detect a face
  84392. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  84393. * @returns the current InstancedLinesMesh
  84394. * @see https://www.babylonjs-playground.com/#19O9TU#0
  84395. */
  84396. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  84397. }
  84398. /**
  84399. * Defines the minimum contract an Edges renderer should follow.
  84400. */
  84401. export interface IEdgesRenderer extends IDisposable {
  84402. /**
  84403. * Gets or sets a boolean indicating if the edgesRenderer is active
  84404. */
  84405. isEnabled: boolean;
  84406. /**
  84407. * Renders the edges of the attached mesh,
  84408. */
  84409. render(): void;
  84410. /**
  84411. * Checks wether or not the edges renderer is ready to render.
  84412. * @return true if ready, otherwise false.
  84413. */
  84414. isReady(): boolean;
  84415. }
  84416. /**
  84417. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  84418. */
  84419. export class EdgesRenderer implements IEdgesRenderer {
  84420. /**
  84421. * Define the size of the edges with an orthographic camera
  84422. */
  84423. edgesWidthScalerForOrthographic: number;
  84424. /**
  84425. * Define the size of the edges with a perspective camera
  84426. */
  84427. edgesWidthScalerForPerspective: number;
  84428. protected _source: AbstractMesh;
  84429. protected _linesPositions: number[];
  84430. protected _linesNormals: number[];
  84431. protected _linesIndices: number[];
  84432. protected _epsilon: number;
  84433. protected _indicesCount: number;
  84434. protected _lineShader: ShaderMaterial;
  84435. protected _ib: DataBuffer;
  84436. protected _buffers: {
  84437. [key: string]: Nullable<VertexBuffer>;
  84438. };
  84439. protected _checkVerticesInsteadOfIndices: boolean;
  84440. private _meshRebuildObserver;
  84441. private _meshDisposeObserver;
  84442. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  84443. isEnabled: boolean;
  84444. /**
  84445. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  84446. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  84447. * @param source Mesh used to create edges
  84448. * @param epsilon sum of angles in adjacency to check for edge
  84449. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  84450. * @param generateEdgesLines - should generate Lines or only prepare resources.
  84451. */
  84452. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  84453. protected _prepareRessources(): void;
  84454. /** @hidden */
  84455. _rebuild(): void;
  84456. /**
  84457. * Releases the required resources for the edges renderer
  84458. */
  84459. dispose(): void;
  84460. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  84461. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  84462. /**
  84463. * Checks if the pair of p0 and p1 is en edge
  84464. * @param faceIndex
  84465. * @param edge
  84466. * @param faceNormals
  84467. * @param p0
  84468. * @param p1
  84469. * @private
  84470. */
  84471. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  84472. /**
  84473. * push line into the position, normal and index buffer
  84474. * @protected
  84475. */
  84476. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  84477. /**
  84478. * Generates lines edges from adjacencjes
  84479. * @private
  84480. */
  84481. _generateEdgesLines(): void;
  84482. /**
  84483. * Checks wether or not the edges renderer is ready to render.
  84484. * @return true if ready, otherwise false.
  84485. */
  84486. isReady(): boolean;
  84487. /**
  84488. * Renders the edges of the attached mesh,
  84489. */
  84490. render(): void;
  84491. }
  84492. /**
  84493. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  84494. */
  84495. export class LineEdgesRenderer extends EdgesRenderer {
  84496. /**
  84497. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  84498. * @param source LineMesh used to generate edges
  84499. * @param epsilon not important (specified angle for edge detection)
  84500. * @param checkVerticesInsteadOfIndices not important for LineMesh
  84501. */
  84502. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  84503. /**
  84504. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  84505. */
  84506. _generateEdgesLines(): void;
  84507. }
  84508. }
  84509. declare module BABYLON {
  84510. /**
  84511. * This represents the object necessary to create a rendering group.
  84512. * This is exclusively used and created by the rendering manager.
  84513. * To modify the behavior, you use the available helpers in your scene or meshes.
  84514. * @hidden
  84515. */
  84516. export class RenderingGroup {
  84517. index: number;
  84518. private static _zeroVector;
  84519. private _scene;
  84520. private _opaqueSubMeshes;
  84521. private _transparentSubMeshes;
  84522. private _alphaTestSubMeshes;
  84523. private _depthOnlySubMeshes;
  84524. private _particleSystems;
  84525. private _spriteManagers;
  84526. private _opaqueSortCompareFn;
  84527. private _alphaTestSortCompareFn;
  84528. private _transparentSortCompareFn;
  84529. private _renderOpaque;
  84530. private _renderAlphaTest;
  84531. private _renderTransparent;
  84532. /** @hidden */
  84533. _edgesRenderers: SmartArray<IEdgesRenderer>;
  84534. onBeforeTransparentRendering: () => void;
  84535. /**
  84536. * Set the opaque sort comparison function.
  84537. * If null the sub meshes will be render in the order they were created
  84538. */
  84539. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84540. /**
  84541. * Set the alpha test sort comparison function.
  84542. * If null the sub meshes will be render in the order they were created
  84543. */
  84544. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84545. /**
  84546. * Set the transparent sort comparison function.
  84547. * If null the sub meshes will be render in the order they were created
  84548. */
  84549. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84550. /**
  84551. * Creates a new rendering group.
  84552. * @param index The rendering group index
  84553. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  84554. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  84555. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  84556. */
  84557. 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>);
  84558. /**
  84559. * Render all the sub meshes contained in the group.
  84560. * @param customRenderFunction Used to override the default render behaviour of the group.
  84561. * @returns true if rendered some submeshes.
  84562. */
  84563. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  84564. /**
  84565. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  84566. * @param subMeshes The submeshes to render
  84567. */
  84568. private renderOpaqueSorted;
  84569. /**
  84570. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  84571. * @param subMeshes The submeshes to render
  84572. */
  84573. private renderAlphaTestSorted;
  84574. /**
  84575. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  84576. * @param subMeshes The submeshes to render
  84577. */
  84578. private renderTransparentSorted;
  84579. /**
  84580. * Renders the submeshes in a specified order.
  84581. * @param subMeshes The submeshes to sort before render
  84582. * @param sortCompareFn The comparison function use to sort
  84583. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  84584. * @param transparent Specifies to activate blending if true
  84585. */
  84586. private static renderSorted;
  84587. /**
  84588. * Renders the submeshes in the order they were dispatched (no sort applied).
  84589. * @param subMeshes The submeshes to render
  84590. */
  84591. private static renderUnsorted;
  84592. /**
  84593. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84594. * are rendered back to front if in the same alpha index.
  84595. *
  84596. * @param a The first submesh
  84597. * @param b The second submesh
  84598. * @returns The result of the comparison
  84599. */
  84600. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  84601. /**
  84602. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84603. * are rendered back to front.
  84604. *
  84605. * @param a The first submesh
  84606. * @param b The second submesh
  84607. * @returns The result of the comparison
  84608. */
  84609. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  84610. /**
  84611. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84612. * are rendered front to back (prevent overdraw).
  84613. *
  84614. * @param a The first submesh
  84615. * @param b The second submesh
  84616. * @returns The result of the comparison
  84617. */
  84618. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  84619. /**
  84620. * Resets the different lists of submeshes to prepare a new frame.
  84621. */
  84622. prepare(): void;
  84623. dispose(): void;
  84624. /**
  84625. * Inserts the submesh in its correct queue depending on its material.
  84626. * @param subMesh The submesh to dispatch
  84627. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84628. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84629. */
  84630. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84631. dispatchSprites(spriteManager: ISpriteManager): void;
  84632. dispatchParticles(particleSystem: IParticleSystem): void;
  84633. private _renderParticles;
  84634. private _renderSprites;
  84635. }
  84636. }
  84637. declare module BABYLON {
  84638. /**
  84639. * Interface describing the different options available in the rendering manager
  84640. * regarding Auto Clear between groups.
  84641. */
  84642. export interface IRenderingManagerAutoClearSetup {
  84643. /**
  84644. * Defines whether or not autoclear is enable.
  84645. */
  84646. autoClear: boolean;
  84647. /**
  84648. * Defines whether or not to autoclear the depth buffer.
  84649. */
  84650. depth: boolean;
  84651. /**
  84652. * Defines whether or not to autoclear the stencil buffer.
  84653. */
  84654. stencil: boolean;
  84655. }
  84656. /**
  84657. * This class is used by the onRenderingGroupObservable
  84658. */
  84659. export class RenderingGroupInfo {
  84660. /**
  84661. * The Scene that being rendered
  84662. */
  84663. scene: Scene;
  84664. /**
  84665. * The camera currently used for the rendering pass
  84666. */
  84667. camera: Nullable<Camera>;
  84668. /**
  84669. * The ID of the renderingGroup being processed
  84670. */
  84671. renderingGroupId: number;
  84672. }
  84673. /**
  84674. * This is the manager responsible of all the rendering for meshes sprites and particles.
  84675. * It is enable to manage the different groups as well as the different necessary sort functions.
  84676. * This should not be used directly aside of the few static configurations
  84677. */
  84678. export class RenderingManager {
  84679. /**
  84680. * The max id used for rendering groups (not included)
  84681. */
  84682. static MAX_RENDERINGGROUPS: number;
  84683. /**
  84684. * The min id used for rendering groups (included)
  84685. */
  84686. static MIN_RENDERINGGROUPS: number;
  84687. /**
  84688. * Used to globally prevent autoclearing scenes.
  84689. */
  84690. static AUTOCLEAR: boolean;
  84691. /**
  84692. * @hidden
  84693. */
  84694. _useSceneAutoClearSetup: boolean;
  84695. private _scene;
  84696. private _renderingGroups;
  84697. private _depthStencilBufferAlreadyCleaned;
  84698. private _autoClearDepthStencil;
  84699. private _customOpaqueSortCompareFn;
  84700. private _customAlphaTestSortCompareFn;
  84701. private _customTransparentSortCompareFn;
  84702. private _renderingGroupInfo;
  84703. /**
  84704. * Instantiates a new rendering group for a particular scene
  84705. * @param scene Defines the scene the groups belongs to
  84706. */
  84707. constructor(scene: Scene);
  84708. private _clearDepthStencilBuffer;
  84709. /**
  84710. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  84711. * @hidden
  84712. */
  84713. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  84714. /**
  84715. * Resets the different information of the group to prepare a new frame
  84716. * @hidden
  84717. */
  84718. reset(): void;
  84719. /**
  84720. * Dispose and release the group and its associated resources.
  84721. * @hidden
  84722. */
  84723. dispose(): void;
  84724. /**
  84725. * Clear the info related to rendering groups preventing retention points during dispose.
  84726. */
  84727. freeRenderingGroups(): void;
  84728. private _prepareRenderingGroup;
  84729. /**
  84730. * Add a sprite manager to the rendering manager in order to render it this frame.
  84731. * @param spriteManager Define the sprite manager to render
  84732. */
  84733. dispatchSprites(spriteManager: ISpriteManager): void;
  84734. /**
  84735. * Add a particle system to the rendering manager in order to render it this frame.
  84736. * @param particleSystem Define the particle system to render
  84737. */
  84738. dispatchParticles(particleSystem: IParticleSystem): void;
  84739. /**
  84740. * Add a submesh to the manager in order to render it this frame
  84741. * @param subMesh The submesh to dispatch
  84742. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84743. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84744. */
  84745. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84746. /**
  84747. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84748. * This allowed control for front to back rendering or reversly depending of the special needs.
  84749. *
  84750. * @param renderingGroupId The rendering group id corresponding to its index
  84751. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84752. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84753. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84754. */
  84755. 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;
  84756. /**
  84757. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84758. *
  84759. * @param renderingGroupId The rendering group id corresponding to its index
  84760. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84761. * @param depth Automatically clears depth between groups if true and autoClear is true.
  84762. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  84763. */
  84764. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  84765. /**
  84766. * Gets the current auto clear configuration for one rendering group of the rendering
  84767. * manager.
  84768. * @param index the rendering group index to get the information for
  84769. * @returns The auto clear setup for the requested rendering group
  84770. */
  84771. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  84772. }
  84773. }
  84774. declare module BABYLON {
  84775. /**
  84776. * This Helps creating a texture that will be created from a camera in your scene.
  84777. * It is basically a dynamic texture that could be used to create special effects for instance.
  84778. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  84779. */
  84780. export class RenderTargetTexture extends Texture {
  84781. isCube: boolean;
  84782. /**
  84783. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  84784. */
  84785. static readonly REFRESHRATE_RENDER_ONCE: number;
  84786. /**
  84787. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  84788. */
  84789. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  84790. /**
  84791. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  84792. * the central point of your effect and can save a lot of performances.
  84793. */
  84794. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  84795. /**
  84796. * Use this predicate to dynamically define the list of mesh you want to render.
  84797. * If set, the renderList property will be overwritten.
  84798. */
  84799. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  84800. private _renderList;
  84801. /**
  84802. * Use this list to define the list of mesh you want to render.
  84803. */
  84804. renderList: Nullable<Array<AbstractMesh>>;
  84805. private _hookArray;
  84806. /**
  84807. * Define if particles should be rendered in your texture.
  84808. */
  84809. renderParticles: boolean;
  84810. /**
  84811. * Define if sprites should be rendered in your texture.
  84812. */
  84813. renderSprites: boolean;
  84814. /**
  84815. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  84816. */
  84817. coordinatesMode: number;
  84818. /**
  84819. * Define the camera used to render the texture.
  84820. */
  84821. activeCamera: Nullable<Camera>;
  84822. /**
  84823. * Override the render function of the texture with your own one.
  84824. */
  84825. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  84826. /**
  84827. * Define if camera post processes should be use while rendering the texture.
  84828. */
  84829. useCameraPostProcesses: boolean;
  84830. /**
  84831. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  84832. */
  84833. ignoreCameraViewport: boolean;
  84834. private _postProcessManager;
  84835. private _postProcesses;
  84836. private _resizeObserver;
  84837. /**
  84838. * An event triggered when the texture is unbind.
  84839. */
  84840. onBeforeBindObservable: Observable<RenderTargetTexture>;
  84841. /**
  84842. * An event triggered when the texture is unbind.
  84843. */
  84844. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  84845. private _onAfterUnbindObserver;
  84846. /**
  84847. * Set a after unbind callback in the texture.
  84848. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  84849. */
  84850. onAfterUnbind: () => void;
  84851. /**
  84852. * An event triggered before rendering the texture
  84853. */
  84854. onBeforeRenderObservable: Observable<number>;
  84855. private _onBeforeRenderObserver;
  84856. /**
  84857. * Set a before render callback in the texture.
  84858. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  84859. */
  84860. onBeforeRender: (faceIndex: number) => void;
  84861. /**
  84862. * An event triggered after rendering the texture
  84863. */
  84864. onAfterRenderObservable: Observable<number>;
  84865. private _onAfterRenderObserver;
  84866. /**
  84867. * Set a after render callback in the texture.
  84868. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  84869. */
  84870. onAfterRender: (faceIndex: number) => void;
  84871. /**
  84872. * An event triggered after the texture clear
  84873. */
  84874. onClearObservable: Observable<Engine>;
  84875. private _onClearObserver;
  84876. /**
  84877. * Set a clear callback in the texture.
  84878. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  84879. */
  84880. onClear: (Engine: Engine) => void;
  84881. /**
  84882. * Define the clear color of the Render Target if it should be different from the scene.
  84883. */
  84884. clearColor: Color4;
  84885. protected _size: number | {
  84886. width: number;
  84887. height: number;
  84888. };
  84889. protected _initialSizeParameter: number | {
  84890. width: number;
  84891. height: number;
  84892. } | {
  84893. ratio: number;
  84894. };
  84895. protected _sizeRatio: Nullable<number>;
  84896. /** @hidden */
  84897. _generateMipMaps: boolean;
  84898. protected _renderingManager: RenderingManager;
  84899. /** @hidden */
  84900. _waitingRenderList: string[];
  84901. protected _doNotChangeAspectRatio: boolean;
  84902. protected _currentRefreshId: number;
  84903. protected _refreshRate: number;
  84904. protected _textureMatrix: Matrix;
  84905. protected _samples: number;
  84906. protected _renderTargetOptions: RenderTargetCreationOptions;
  84907. /**
  84908. * Gets render target creation options that were used.
  84909. */
  84910. readonly renderTargetOptions: RenderTargetCreationOptions;
  84911. protected _engine: Engine;
  84912. protected _onRatioRescale(): void;
  84913. /**
  84914. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  84915. * It must define where the camera used to render the texture is set
  84916. */
  84917. boundingBoxPosition: Vector3;
  84918. private _boundingBoxSize;
  84919. /**
  84920. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  84921. * When defined, the cubemap will switch to local mode
  84922. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  84923. * @example https://www.babylonjs-playground.com/#RNASML
  84924. */
  84925. boundingBoxSize: Vector3;
  84926. /**
  84927. * In case the RTT has been created with a depth texture, get the associated
  84928. * depth texture.
  84929. * Otherwise, return null.
  84930. */
  84931. depthStencilTexture: Nullable<InternalTexture>;
  84932. /**
  84933. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  84934. * or used a shadow, depth texture...
  84935. * @param name The friendly name of the texture
  84936. * @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)
  84937. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  84938. * @param generateMipMaps True if mip maps need to be generated after render.
  84939. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  84940. * @param type The type of the buffer in the RTT (int, half float, float...)
  84941. * @param isCube True if a cube texture needs to be created
  84942. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  84943. * @param generateDepthBuffer True to generate a depth buffer
  84944. * @param generateStencilBuffer True to generate a stencil buffer
  84945. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  84946. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  84947. * @param delayAllocation if the texture allocation should be delayed (default: false)
  84948. */
  84949. constructor(name: string, size: number | {
  84950. width: number;
  84951. height: number;
  84952. } | {
  84953. ratio: number;
  84954. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  84955. /**
  84956. * Creates a depth stencil texture.
  84957. * This is only available in WebGL 2 or with the depth texture extension available.
  84958. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  84959. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  84960. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  84961. */
  84962. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  84963. private _processSizeParameter;
  84964. /**
  84965. * Define the number of samples to use in case of MSAA.
  84966. * It defaults to one meaning no MSAA has been enabled.
  84967. */
  84968. samples: number;
  84969. /**
  84970. * Resets the refresh counter of the texture and start bak from scratch.
  84971. * Could be useful to regenerate the texture if it is setup to render only once.
  84972. */
  84973. resetRefreshCounter(): void;
  84974. /**
  84975. * Define the refresh rate of the texture or the rendering frequency.
  84976. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84977. */
  84978. refreshRate: number;
  84979. /**
  84980. * Adds a post process to the render target rendering passes.
  84981. * @param postProcess define the post process to add
  84982. */
  84983. addPostProcess(postProcess: PostProcess): void;
  84984. /**
  84985. * Clear all the post processes attached to the render target
  84986. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  84987. */
  84988. clearPostProcesses(dispose?: boolean): void;
  84989. /**
  84990. * Remove one of the post process from the list of attached post processes to the texture
  84991. * @param postProcess define the post process to remove from the list
  84992. */
  84993. removePostProcess(postProcess: PostProcess): void;
  84994. /** @hidden */
  84995. _shouldRender(): boolean;
  84996. /**
  84997. * Gets the actual render size of the texture.
  84998. * @returns the width of the render size
  84999. */
  85000. getRenderSize(): number;
  85001. /**
  85002. * Gets the actual render width of the texture.
  85003. * @returns the width of the render size
  85004. */
  85005. getRenderWidth(): number;
  85006. /**
  85007. * Gets the actual render height of the texture.
  85008. * @returns the height of the render size
  85009. */
  85010. getRenderHeight(): number;
  85011. /**
  85012. * Get if the texture can be rescaled or not.
  85013. */
  85014. readonly canRescale: boolean;
  85015. /**
  85016. * Resize the texture using a ratio.
  85017. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  85018. */
  85019. scale(ratio: number): void;
  85020. /**
  85021. * Get the texture reflection matrix used to rotate/transform the reflection.
  85022. * @returns the reflection matrix
  85023. */
  85024. getReflectionTextureMatrix(): Matrix;
  85025. /**
  85026. * Resize the texture to a new desired size.
  85027. * Be carrefull as it will recreate all the data in the new texture.
  85028. * @param size Define the new size. It can be:
  85029. * - a number for squared texture,
  85030. * - an object containing { width: number, height: number }
  85031. * - or an object containing a ratio { ratio: number }
  85032. */
  85033. resize(size: number | {
  85034. width: number;
  85035. height: number;
  85036. } | {
  85037. ratio: number;
  85038. }): void;
  85039. /**
  85040. * Renders all the objects from the render list into the texture.
  85041. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  85042. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  85043. */
  85044. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  85045. private _bestReflectionRenderTargetDimension;
  85046. /**
  85047. * @hidden
  85048. * @param faceIndex face index to bind to if this is a cubetexture
  85049. */
  85050. _bindFrameBuffer(faceIndex?: number): void;
  85051. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  85052. private renderToTarget;
  85053. /**
  85054. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  85055. * This allowed control for front to back rendering or reversly depending of the special needs.
  85056. *
  85057. * @param renderingGroupId The rendering group id corresponding to its index
  85058. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  85059. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  85060. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  85061. */
  85062. 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;
  85063. /**
  85064. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  85065. *
  85066. * @param renderingGroupId The rendering group id corresponding to its index
  85067. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  85068. */
  85069. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  85070. /**
  85071. * Clones the texture.
  85072. * @returns the cloned texture
  85073. */
  85074. clone(): RenderTargetTexture;
  85075. /**
  85076. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  85077. * @returns The JSON representation of the texture
  85078. */
  85079. serialize(): any;
  85080. /**
  85081. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  85082. */
  85083. disposeFramebufferObjects(): void;
  85084. /**
  85085. * Dispose the texture and release its associated resources.
  85086. */
  85087. dispose(): void;
  85088. /** @hidden */
  85089. _rebuild(): void;
  85090. /**
  85091. * Clear the info related to rendering groups preventing retention point in material dispose.
  85092. */
  85093. freeRenderingGroups(): void;
  85094. /**
  85095. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  85096. * @returns the view count
  85097. */
  85098. getViewCount(): number;
  85099. }
  85100. }
  85101. declare module BABYLON {
  85102. /**
  85103. * Base class for the main features of a material in Babylon.js
  85104. */
  85105. export class Material implements IAnimatable {
  85106. /**
  85107. * Returns the triangle fill mode
  85108. */
  85109. static readonly TriangleFillMode: number;
  85110. /**
  85111. * Returns the wireframe mode
  85112. */
  85113. static readonly WireFrameFillMode: number;
  85114. /**
  85115. * Returns the point fill mode
  85116. */
  85117. static readonly PointFillMode: number;
  85118. /**
  85119. * Returns the point list draw mode
  85120. */
  85121. static readonly PointListDrawMode: number;
  85122. /**
  85123. * Returns the line list draw mode
  85124. */
  85125. static readonly LineListDrawMode: number;
  85126. /**
  85127. * Returns the line loop draw mode
  85128. */
  85129. static readonly LineLoopDrawMode: number;
  85130. /**
  85131. * Returns the line strip draw mode
  85132. */
  85133. static readonly LineStripDrawMode: number;
  85134. /**
  85135. * Returns the triangle strip draw mode
  85136. */
  85137. static readonly TriangleStripDrawMode: number;
  85138. /**
  85139. * Returns the triangle fan draw mode
  85140. */
  85141. static readonly TriangleFanDrawMode: number;
  85142. /**
  85143. * Stores the clock-wise side orientation
  85144. */
  85145. static readonly ClockWiseSideOrientation: number;
  85146. /**
  85147. * Stores the counter clock-wise side orientation
  85148. */
  85149. static readonly CounterClockWiseSideOrientation: number;
  85150. /**
  85151. * The dirty texture flag value
  85152. */
  85153. static readonly TextureDirtyFlag: number;
  85154. /**
  85155. * The dirty light flag value
  85156. */
  85157. static readonly LightDirtyFlag: number;
  85158. /**
  85159. * The dirty fresnel flag value
  85160. */
  85161. static readonly FresnelDirtyFlag: number;
  85162. /**
  85163. * The dirty attribute flag value
  85164. */
  85165. static readonly AttributesDirtyFlag: number;
  85166. /**
  85167. * The dirty misc flag value
  85168. */
  85169. static readonly MiscDirtyFlag: number;
  85170. /**
  85171. * The all dirty flag value
  85172. */
  85173. static readonly AllDirtyFlag: number;
  85174. /**
  85175. * The ID of the material
  85176. */
  85177. id: string;
  85178. /**
  85179. * Gets or sets the unique id of the material
  85180. */
  85181. uniqueId: number;
  85182. /**
  85183. * The name of the material
  85184. */
  85185. name: string;
  85186. /**
  85187. * Gets or sets user defined metadata
  85188. */
  85189. metadata: any;
  85190. /**
  85191. * For internal use only. Please do not use.
  85192. */
  85193. reservedDataStore: any;
  85194. /**
  85195. * Specifies if the ready state should be checked on each call
  85196. */
  85197. checkReadyOnEveryCall: boolean;
  85198. /**
  85199. * Specifies if the ready state should be checked once
  85200. */
  85201. checkReadyOnlyOnce: boolean;
  85202. /**
  85203. * The state of the material
  85204. */
  85205. state: string;
  85206. /**
  85207. * The alpha value of the material
  85208. */
  85209. protected _alpha: number;
  85210. /**
  85211. * List of inspectable custom properties (used by the Inspector)
  85212. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85213. */
  85214. inspectableCustomProperties: IInspectable[];
  85215. /**
  85216. * Sets the alpha value of the material
  85217. */
  85218. /**
  85219. * Gets the alpha value of the material
  85220. */
  85221. alpha: number;
  85222. /**
  85223. * Specifies if back face culling is enabled
  85224. */
  85225. protected _backFaceCulling: boolean;
  85226. /**
  85227. * Sets the back-face culling state
  85228. */
  85229. /**
  85230. * Gets the back-face culling state
  85231. */
  85232. backFaceCulling: boolean;
  85233. /**
  85234. * Stores the value for side orientation
  85235. */
  85236. sideOrientation: number;
  85237. /**
  85238. * Callback triggered when the material is compiled
  85239. */
  85240. onCompiled: Nullable<(effect: Effect) => void>;
  85241. /**
  85242. * Callback triggered when an error occurs
  85243. */
  85244. onError: Nullable<(effect: Effect, errors: string) => void>;
  85245. /**
  85246. * Callback triggered to get the render target textures
  85247. */
  85248. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  85249. /**
  85250. * Gets a boolean indicating that current material needs to register RTT
  85251. */
  85252. readonly hasRenderTargetTextures: boolean;
  85253. /**
  85254. * Specifies if the material should be serialized
  85255. */
  85256. doNotSerialize: boolean;
  85257. /**
  85258. * @hidden
  85259. */
  85260. _storeEffectOnSubMeshes: boolean;
  85261. /**
  85262. * Stores the animations for the material
  85263. */
  85264. animations: Nullable<Array<Animation>>;
  85265. /**
  85266. * An event triggered when the material is disposed
  85267. */
  85268. onDisposeObservable: Observable<Material>;
  85269. /**
  85270. * An observer which watches for dispose events
  85271. */
  85272. private _onDisposeObserver;
  85273. private _onUnBindObservable;
  85274. /**
  85275. * Called during a dispose event
  85276. */
  85277. onDispose: () => void;
  85278. private _onBindObservable;
  85279. /**
  85280. * An event triggered when the material is bound
  85281. */
  85282. readonly onBindObservable: Observable<AbstractMesh>;
  85283. /**
  85284. * An observer which watches for bind events
  85285. */
  85286. private _onBindObserver;
  85287. /**
  85288. * Called during a bind event
  85289. */
  85290. onBind: (Mesh: AbstractMesh) => void;
  85291. /**
  85292. * An event triggered when the material is unbound
  85293. */
  85294. readonly onUnBindObservable: Observable<Material>;
  85295. /**
  85296. * Stores the value of the alpha mode
  85297. */
  85298. private _alphaMode;
  85299. /**
  85300. * Sets the value of the alpha mode.
  85301. *
  85302. * | Value | Type | Description |
  85303. * | --- | --- | --- |
  85304. * | 0 | ALPHA_DISABLE | |
  85305. * | 1 | ALPHA_ADD | |
  85306. * | 2 | ALPHA_COMBINE | |
  85307. * | 3 | ALPHA_SUBTRACT | |
  85308. * | 4 | ALPHA_MULTIPLY | |
  85309. * | 5 | ALPHA_MAXIMIZED | |
  85310. * | 6 | ALPHA_ONEONE | |
  85311. * | 7 | ALPHA_PREMULTIPLIED | |
  85312. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  85313. * | 9 | ALPHA_INTERPOLATE | |
  85314. * | 10 | ALPHA_SCREENMODE | |
  85315. *
  85316. */
  85317. /**
  85318. * Gets the value of the alpha mode
  85319. */
  85320. alphaMode: number;
  85321. /**
  85322. * Stores the state of the need depth pre-pass value
  85323. */
  85324. private _needDepthPrePass;
  85325. /**
  85326. * Sets the need depth pre-pass value
  85327. */
  85328. /**
  85329. * Gets the depth pre-pass value
  85330. */
  85331. needDepthPrePass: boolean;
  85332. /**
  85333. * Specifies if depth writing should be disabled
  85334. */
  85335. disableDepthWrite: boolean;
  85336. /**
  85337. * Specifies if depth writing should be forced
  85338. */
  85339. forceDepthWrite: boolean;
  85340. /**
  85341. * Specifies if there should be a separate pass for culling
  85342. */
  85343. separateCullingPass: boolean;
  85344. /**
  85345. * Stores the state specifing if fog should be enabled
  85346. */
  85347. private _fogEnabled;
  85348. /**
  85349. * Sets the state for enabling fog
  85350. */
  85351. /**
  85352. * Gets the value of the fog enabled state
  85353. */
  85354. fogEnabled: boolean;
  85355. /**
  85356. * Stores the size of points
  85357. */
  85358. pointSize: number;
  85359. /**
  85360. * Stores the z offset value
  85361. */
  85362. zOffset: number;
  85363. /**
  85364. * Gets a value specifying if wireframe mode is enabled
  85365. */
  85366. /**
  85367. * Sets the state of wireframe mode
  85368. */
  85369. wireframe: boolean;
  85370. /**
  85371. * Gets the value specifying if point clouds are enabled
  85372. */
  85373. /**
  85374. * Sets the state of point cloud mode
  85375. */
  85376. pointsCloud: boolean;
  85377. /**
  85378. * Gets the material fill mode
  85379. */
  85380. /**
  85381. * Sets the material fill mode
  85382. */
  85383. fillMode: number;
  85384. /**
  85385. * @hidden
  85386. * Stores the effects for the material
  85387. */
  85388. _effect: Nullable<Effect>;
  85389. /**
  85390. * @hidden
  85391. * Specifies if the material was previously ready
  85392. */
  85393. _wasPreviouslyReady: boolean;
  85394. /**
  85395. * Specifies if uniform buffers should be used
  85396. */
  85397. private _useUBO;
  85398. /**
  85399. * Stores a reference to the scene
  85400. */
  85401. private _scene;
  85402. /**
  85403. * Stores the fill mode state
  85404. */
  85405. private _fillMode;
  85406. /**
  85407. * Specifies if the depth write state should be cached
  85408. */
  85409. private _cachedDepthWriteState;
  85410. /**
  85411. * Stores the uniform buffer
  85412. */
  85413. protected _uniformBuffer: UniformBuffer;
  85414. /** @hidden */
  85415. _indexInSceneMaterialArray: number;
  85416. /** @hidden */
  85417. meshMap: Nullable<{
  85418. [id: string]: AbstractMesh | undefined;
  85419. }>;
  85420. /**
  85421. * Creates a material instance
  85422. * @param name defines the name of the material
  85423. * @param scene defines the scene to reference
  85424. * @param doNotAdd specifies if the material should be added to the scene
  85425. */
  85426. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  85427. /**
  85428. * Returns a string representation of the current material
  85429. * @param fullDetails defines a boolean indicating which levels of logging is desired
  85430. * @returns a string with material information
  85431. */
  85432. toString(fullDetails?: boolean): string;
  85433. /**
  85434. * Gets the class name of the material
  85435. * @returns a string with the class name of the material
  85436. */
  85437. getClassName(): string;
  85438. /**
  85439. * Specifies if updates for the material been locked
  85440. */
  85441. readonly isFrozen: boolean;
  85442. /**
  85443. * Locks updates for the material
  85444. */
  85445. freeze(): void;
  85446. /**
  85447. * Unlocks updates for the material
  85448. */
  85449. unfreeze(): void;
  85450. /**
  85451. * Specifies if the material is ready to be used
  85452. * @param mesh defines the mesh to check
  85453. * @param useInstances specifies if instances should be used
  85454. * @returns a boolean indicating if the material is ready to be used
  85455. */
  85456. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  85457. /**
  85458. * Specifies that the submesh is ready to be used
  85459. * @param mesh defines the mesh to check
  85460. * @param subMesh defines which submesh to check
  85461. * @param useInstances specifies that instances should be used
  85462. * @returns a boolean indicating that the submesh is ready or not
  85463. */
  85464. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85465. /**
  85466. * Returns the material effect
  85467. * @returns the effect associated with the material
  85468. */
  85469. getEffect(): Nullable<Effect>;
  85470. /**
  85471. * Returns the current scene
  85472. * @returns a Scene
  85473. */
  85474. getScene(): Scene;
  85475. /**
  85476. * Specifies if the material will require alpha blending
  85477. * @returns a boolean specifying if alpha blending is needed
  85478. */
  85479. needAlphaBlending(): boolean;
  85480. /**
  85481. * Specifies if the mesh will require alpha blending
  85482. * @param mesh defines the mesh to check
  85483. * @returns a boolean specifying if alpha blending is needed for the mesh
  85484. */
  85485. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  85486. /**
  85487. * Specifies if this material should be rendered in alpha test mode
  85488. * @returns a boolean specifying if an alpha test is needed.
  85489. */
  85490. needAlphaTesting(): boolean;
  85491. /**
  85492. * Gets the texture used for the alpha test
  85493. * @returns the texture to use for alpha testing
  85494. */
  85495. getAlphaTestTexture(): Nullable<BaseTexture>;
  85496. /**
  85497. * Marks the material to indicate that it needs to be re-calculated
  85498. */
  85499. markDirty(): void;
  85500. /** @hidden */
  85501. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  85502. /**
  85503. * Binds the material to the mesh
  85504. * @param world defines the world transformation matrix
  85505. * @param mesh defines the mesh to bind the material to
  85506. */
  85507. bind(world: Matrix, mesh?: Mesh): void;
  85508. /**
  85509. * Binds the submesh to the material
  85510. * @param world defines the world transformation matrix
  85511. * @param mesh defines the mesh containing the submesh
  85512. * @param subMesh defines the submesh to bind the material to
  85513. */
  85514. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  85515. /**
  85516. * Binds the world matrix to the material
  85517. * @param world defines the world transformation matrix
  85518. */
  85519. bindOnlyWorldMatrix(world: Matrix): void;
  85520. /**
  85521. * Binds the scene's uniform buffer to the effect.
  85522. * @param effect defines the effect to bind to the scene uniform buffer
  85523. * @param sceneUbo defines the uniform buffer storing scene data
  85524. */
  85525. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  85526. /**
  85527. * Binds the view matrix to the effect
  85528. * @param effect defines the effect to bind the view matrix to
  85529. */
  85530. bindView(effect: Effect): void;
  85531. /**
  85532. * Binds the view projection matrix to the effect
  85533. * @param effect defines the effect to bind the view projection matrix to
  85534. */
  85535. bindViewProjection(effect: Effect): void;
  85536. /**
  85537. * Specifies if material alpha testing should be turned on for the mesh
  85538. * @param mesh defines the mesh to check
  85539. */
  85540. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  85541. /**
  85542. * Processes to execute after binding the material to a mesh
  85543. * @param mesh defines the rendered mesh
  85544. */
  85545. protected _afterBind(mesh?: Mesh): void;
  85546. /**
  85547. * Unbinds the material from the mesh
  85548. */
  85549. unbind(): void;
  85550. /**
  85551. * Gets the active textures from the material
  85552. * @returns an array of textures
  85553. */
  85554. getActiveTextures(): BaseTexture[];
  85555. /**
  85556. * Specifies if the material uses a texture
  85557. * @param texture defines the texture to check against the material
  85558. * @returns a boolean specifying if the material uses the texture
  85559. */
  85560. hasTexture(texture: BaseTexture): boolean;
  85561. /**
  85562. * Makes a duplicate of the material, and gives it a new name
  85563. * @param name defines the new name for the duplicated material
  85564. * @returns the cloned material
  85565. */
  85566. clone(name: string): Nullable<Material>;
  85567. /**
  85568. * Gets the meshes bound to the material
  85569. * @returns an array of meshes bound to the material
  85570. */
  85571. getBindedMeshes(): AbstractMesh[];
  85572. /**
  85573. * Force shader compilation
  85574. * @param mesh defines the mesh associated with this material
  85575. * @param onCompiled defines a function to execute once the material is compiled
  85576. * @param options defines the options to configure the compilation
  85577. */
  85578. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  85579. clipPlane: boolean;
  85580. }>): void;
  85581. /**
  85582. * Force shader compilation
  85583. * @param mesh defines the mesh that will use this material
  85584. * @param options defines additional options for compiling the shaders
  85585. * @returns a promise that resolves when the compilation completes
  85586. */
  85587. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  85588. clipPlane: boolean;
  85589. }>): Promise<void>;
  85590. private static readonly _AllDirtyCallBack;
  85591. private static readonly _ImageProcessingDirtyCallBack;
  85592. private static readonly _TextureDirtyCallBack;
  85593. private static readonly _FresnelDirtyCallBack;
  85594. private static readonly _MiscDirtyCallBack;
  85595. private static readonly _LightsDirtyCallBack;
  85596. private static readonly _AttributeDirtyCallBack;
  85597. private static _FresnelAndMiscDirtyCallBack;
  85598. private static _TextureAndMiscDirtyCallBack;
  85599. private static readonly _DirtyCallbackArray;
  85600. private static readonly _RunDirtyCallBacks;
  85601. /**
  85602. * Marks a define in the material to indicate that it needs to be re-computed
  85603. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  85604. */
  85605. markAsDirty(flag: number): void;
  85606. /**
  85607. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  85608. * @param func defines a function which checks material defines against the submeshes
  85609. */
  85610. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  85611. /**
  85612. * Indicates that we need to re-calculated for all submeshes
  85613. */
  85614. protected _markAllSubMeshesAsAllDirty(): void;
  85615. /**
  85616. * Indicates that image processing needs to be re-calculated for all submeshes
  85617. */
  85618. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  85619. /**
  85620. * Indicates that textures need to be re-calculated for all submeshes
  85621. */
  85622. protected _markAllSubMeshesAsTexturesDirty(): void;
  85623. /**
  85624. * Indicates that fresnel needs to be re-calculated for all submeshes
  85625. */
  85626. protected _markAllSubMeshesAsFresnelDirty(): void;
  85627. /**
  85628. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  85629. */
  85630. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  85631. /**
  85632. * Indicates that lights need to be re-calculated for all submeshes
  85633. */
  85634. protected _markAllSubMeshesAsLightsDirty(): void;
  85635. /**
  85636. * Indicates that attributes need to be re-calculated for all submeshes
  85637. */
  85638. protected _markAllSubMeshesAsAttributesDirty(): void;
  85639. /**
  85640. * Indicates that misc needs to be re-calculated for all submeshes
  85641. */
  85642. protected _markAllSubMeshesAsMiscDirty(): void;
  85643. /**
  85644. * Indicates that textures and misc need to be re-calculated for all submeshes
  85645. */
  85646. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  85647. /**
  85648. * Disposes the material
  85649. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85650. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  85651. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  85652. */
  85653. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  85654. /** @hidden */
  85655. private releaseVertexArrayObject;
  85656. /**
  85657. * Serializes this material
  85658. * @returns the serialized material object
  85659. */
  85660. serialize(): any;
  85661. /**
  85662. * Creates a material from parsed material data
  85663. * @param parsedMaterial defines parsed material data
  85664. * @param scene defines the hosting scene
  85665. * @param rootUrl defines the root URL to use to load textures
  85666. * @returns a new material
  85667. */
  85668. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  85669. }
  85670. }
  85671. declare module BABYLON {
  85672. /**
  85673. * Base class for submeshes
  85674. */
  85675. export class BaseSubMesh {
  85676. /** @hidden */
  85677. _materialDefines: Nullable<MaterialDefines>;
  85678. /** @hidden */
  85679. _materialEffect: Nullable<Effect>;
  85680. /**
  85681. * Gets associated effect
  85682. */
  85683. readonly effect: Nullable<Effect>;
  85684. /**
  85685. * Sets associated effect (effect used to render this submesh)
  85686. * @param effect defines the effect to associate with
  85687. * @param defines defines the set of defines used to compile this effect
  85688. */
  85689. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  85690. }
  85691. /**
  85692. * Defines a subdivision inside a mesh
  85693. */
  85694. export class SubMesh extends BaseSubMesh implements ICullable {
  85695. /** the material index to use */
  85696. materialIndex: number;
  85697. /** vertex index start */
  85698. verticesStart: number;
  85699. /** vertices count */
  85700. verticesCount: number;
  85701. /** index start */
  85702. indexStart: number;
  85703. /** indices count */
  85704. indexCount: number;
  85705. /** @hidden */
  85706. _linesIndexCount: number;
  85707. private _mesh;
  85708. private _renderingMesh;
  85709. private _boundingInfo;
  85710. private _linesIndexBuffer;
  85711. /** @hidden */
  85712. _lastColliderWorldVertices: Nullable<Vector3[]>;
  85713. /** @hidden */
  85714. _trianglePlanes: Plane[];
  85715. /** @hidden */
  85716. _lastColliderTransformMatrix: Nullable<Matrix>;
  85717. /** @hidden */
  85718. _renderId: number;
  85719. /** @hidden */
  85720. _alphaIndex: number;
  85721. /** @hidden */
  85722. _distanceToCamera: number;
  85723. /** @hidden */
  85724. _id: number;
  85725. private _currentMaterial;
  85726. /**
  85727. * Add a new submesh to a mesh
  85728. * @param materialIndex defines the material index to use
  85729. * @param verticesStart defines vertex index start
  85730. * @param verticesCount defines vertices count
  85731. * @param indexStart defines index start
  85732. * @param indexCount defines indices count
  85733. * @param mesh defines the parent mesh
  85734. * @param renderingMesh defines an optional rendering mesh
  85735. * @param createBoundingBox defines if bounding box should be created for this submesh
  85736. * @returns the new submesh
  85737. */
  85738. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  85739. /**
  85740. * Creates a new submesh
  85741. * @param materialIndex defines the material index to use
  85742. * @param verticesStart defines vertex index start
  85743. * @param verticesCount defines vertices count
  85744. * @param indexStart defines index start
  85745. * @param indexCount defines indices count
  85746. * @param mesh defines the parent mesh
  85747. * @param renderingMesh defines an optional rendering mesh
  85748. * @param createBoundingBox defines if bounding box should be created for this submesh
  85749. */
  85750. constructor(
  85751. /** the material index to use */
  85752. materialIndex: number,
  85753. /** vertex index start */
  85754. verticesStart: number,
  85755. /** vertices count */
  85756. verticesCount: number,
  85757. /** index start */
  85758. indexStart: number,
  85759. /** indices count */
  85760. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  85761. /**
  85762. * Returns true if this submesh covers the entire parent mesh
  85763. * @ignorenaming
  85764. */
  85765. readonly IsGlobal: boolean;
  85766. /**
  85767. * Returns the submesh BoudingInfo object
  85768. * @returns current bounding info (or mesh's one if the submesh is global)
  85769. */
  85770. getBoundingInfo(): BoundingInfo;
  85771. /**
  85772. * Sets the submesh BoundingInfo
  85773. * @param boundingInfo defines the new bounding info to use
  85774. * @returns the SubMesh
  85775. */
  85776. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  85777. /**
  85778. * Returns the mesh of the current submesh
  85779. * @return the parent mesh
  85780. */
  85781. getMesh(): AbstractMesh;
  85782. /**
  85783. * Returns the rendering mesh of the submesh
  85784. * @returns the rendering mesh (could be different from parent mesh)
  85785. */
  85786. getRenderingMesh(): Mesh;
  85787. /**
  85788. * Returns the submesh material
  85789. * @returns null or the current material
  85790. */
  85791. getMaterial(): Nullable<Material>;
  85792. /**
  85793. * Sets a new updated BoundingInfo object to the submesh
  85794. * @param data defines an optional position array to use to determine the bounding info
  85795. * @returns the SubMesh
  85796. */
  85797. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  85798. /** @hidden */
  85799. _checkCollision(collider: Collider): boolean;
  85800. /**
  85801. * Updates the submesh BoundingInfo
  85802. * @param world defines the world matrix to use to update the bounding info
  85803. * @returns the submesh
  85804. */
  85805. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  85806. /**
  85807. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  85808. * @param frustumPlanes defines the frustum planes
  85809. * @returns true if the submesh is intersecting with the frustum
  85810. */
  85811. isInFrustum(frustumPlanes: Plane[]): boolean;
  85812. /**
  85813. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  85814. * @param frustumPlanes defines the frustum planes
  85815. * @returns true if the submesh is inside the frustum
  85816. */
  85817. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  85818. /**
  85819. * Renders the submesh
  85820. * @param enableAlphaMode defines if alpha needs to be used
  85821. * @returns the submesh
  85822. */
  85823. render(enableAlphaMode: boolean): SubMesh;
  85824. /**
  85825. * @hidden
  85826. */
  85827. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  85828. /**
  85829. * Checks if the submesh intersects with a ray
  85830. * @param ray defines the ray to test
  85831. * @returns true is the passed ray intersects the submesh bounding box
  85832. */
  85833. canIntersects(ray: Ray): boolean;
  85834. /**
  85835. * Intersects current submesh with a ray
  85836. * @param ray defines the ray to test
  85837. * @param positions defines mesh's positions array
  85838. * @param indices defines mesh's indices array
  85839. * @param fastCheck defines if only bounding info should be used
  85840. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  85841. * @returns intersection info or null if no intersection
  85842. */
  85843. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  85844. /** @hidden */
  85845. private _intersectLines;
  85846. /** @hidden */
  85847. private _intersectUnIndexedLines;
  85848. /** @hidden */
  85849. private _intersectTriangles;
  85850. /** @hidden */
  85851. private _intersectUnIndexedTriangles;
  85852. /** @hidden */
  85853. _rebuild(): void;
  85854. /**
  85855. * Creates a new submesh from the passed mesh
  85856. * @param newMesh defines the new hosting mesh
  85857. * @param newRenderingMesh defines an optional rendering mesh
  85858. * @returns the new submesh
  85859. */
  85860. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  85861. /**
  85862. * Release associated resources
  85863. */
  85864. dispose(): void;
  85865. /**
  85866. * Gets the class name
  85867. * @returns the string "SubMesh".
  85868. */
  85869. getClassName(): string;
  85870. /**
  85871. * Creates a new submesh from indices data
  85872. * @param materialIndex the index of the main mesh material
  85873. * @param startIndex the index where to start the copy in the mesh indices array
  85874. * @param indexCount the number of indices to copy then from the startIndex
  85875. * @param mesh the main mesh to create the submesh from
  85876. * @param renderingMesh the optional rendering mesh
  85877. * @returns a new submesh
  85878. */
  85879. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  85880. }
  85881. }
  85882. declare module BABYLON {
  85883. /**
  85884. * Class used to store geometry data (vertex buffers + index buffer)
  85885. */
  85886. export class Geometry implements IGetSetVerticesData {
  85887. /**
  85888. * Gets or sets the ID of the geometry
  85889. */
  85890. id: string;
  85891. /**
  85892. * Gets or sets the unique ID of the geometry
  85893. */
  85894. uniqueId: number;
  85895. /**
  85896. * Gets the delay loading state of the geometry (none by default which means not delayed)
  85897. */
  85898. delayLoadState: number;
  85899. /**
  85900. * Gets the file containing the data to load when running in delay load state
  85901. */
  85902. delayLoadingFile: Nullable<string>;
  85903. /**
  85904. * Callback called when the geometry is updated
  85905. */
  85906. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  85907. private _scene;
  85908. private _engine;
  85909. private _meshes;
  85910. private _totalVertices;
  85911. /** @hidden */
  85912. _indices: IndicesArray;
  85913. /** @hidden */
  85914. _vertexBuffers: {
  85915. [key: string]: VertexBuffer;
  85916. };
  85917. private _isDisposed;
  85918. private _extend;
  85919. private _boundingBias;
  85920. /** @hidden */
  85921. _delayInfo: Array<string>;
  85922. private _indexBuffer;
  85923. private _indexBufferIsUpdatable;
  85924. /** @hidden */
  85925. _boundingInfo: Nullable<BoundingInfo>;
  85926. /** @hidden */
  85927. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  85928. /** @hidden */
  85929. _softwareSkinningFrameId: number;
  85930. private _vertexArrayObjects;
  85931. private _updatable;
  85932. /** @hidden */
  85933. _positions: Nullable<Vector3[]>;
  85934. /**
  85935. * 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
  85936. */
  85937. /**
  85938. * 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
  85939. */
  85940. boundingBias: Vector2;
  85941. /**
  85942. * Static function used to attach a new empty geometry to a mesh
  85943. * @param mesh defines the mesh to attach the geometry to
  85944. * @returns the new Geometry
  85945. */
  85946. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  85947. /**
  85948. * Creates a new geometry
  85949. * @param id defines the unique ID
  85950. * @param scene defines the hosting scene
  85951. * @param vertexData defines the VertexData used to get geometry data
  85952. * @param updatable defines if geometry must be updatable (false by default)
  85953. * @param mesh defines the mesh that will be associated with the geometry
  85954. */
  85955. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  85956. /**
  85957. * Gets the current extend of the geometry
  85958. */
  85959. readonly extend: {
  85960. minimum: Vector3;
  85961. maximum: Vector3;
  85962. };
  85963. /**
  85964. * Gets the hosting scene
  85965. * @returns the hosting Scene
  85966. */
  85967. getScene(): Scene;
  85968. /**
  85969. * Gets the hosting engine
  85970. * @returns the hosting Engine
  85971. */
  85972. getEngine(): Engine;
  85973. /**
  85974. * Defines if the geometry is ready to use
  85975. * @returns true if the geometry is ready to be used
  85976. */
  85977. isReady(): boolean;
  85978. /**
  85979. * Gets a value indicating that the geometry should not be serialized
  85980. */
  85981. readonly doNotSerialize: boolean;
  85982. /** @hidden */
  85983. _rebuild(): void;
  85984. /**
  85985. * Affects all geometry data in one call
  85986. * @param vertexData defines the geometry data
  85987. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  85988. */
  85989. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  85990. /**
  85991. * Set specific vertex data
  85992. * @param kind defines the data kind (Position, normal, etc...)
  85993. * @param data defines the vertex data to use
  85994. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85995. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85996. */
  85997. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  85998. /**
  85999. * Removes a specific vertex data
  86000. * @param kind defines the data kind (Position, normal, etc...)
  86001. */
  86002. removeVerticesData(kind: string): void;
  86003. /**
  86004. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  86005. * @param buffer defines the vertex buffer to use
  86006. * @param totalVertices defines the total number of vertices for position kind (could be null)
  86007. */
  86008. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  86009. /**
  86010. * Update a specific vertex buffer
  86011. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  86012. * It will do nothing if the buffer is not updatable
  86013. * @param kind defines the data kind (Position, normal, etc...)
  86014. * @param data defines the data to use
  86015. * @param offset defines the offset in the target buffer where to store the data
  86016. * @param useBytes set to true if the offset is in bytes
  86017. */
  86018. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  86019. /**
  86020. * Update a specific vertex buffer
  86021. * This function will create a new buffer if the current one is not updatable
  86022. * @param kind defines the data kind (Position, normal, etc...)
  86023. * @param data defines the data to use
  86024. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  86025. */
  86026. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  86027. private _updateBoundingInfo;
  86028. /** @hidden */
  86029. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  86030. /**
  86031. * Gets total number of vertices
  86032. * @returns the total number of vertices
  86033. */
  86034. getTotalVertices(): number;
  86035. /**
  86036. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  86037. * @param kind defines the data kind (Position, normal, etc...)
  86038. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86039. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86040. * @returns a float array containing vertex data
  86041. */
  86042. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  86043. /**
  86044. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  86045. * @param kind defines the data kind (Position, normal, etc...)
  86046. * @returns true if the vertex buffer with the specified kind is updatable
  86047. */
  86048. isVertexBufferUpdatable(kind: string): boolean;
  86049. /**
  86050. * Gets a specific vertex buffer
  86051. * @param kind defines the data kind (Position, normal, etc...)
  86052. * @returns a VertexBuffer
  86053. */
  86054. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  86055. /**
  86056. * Returns all vertex buffers
  86057. * @return an object holding all vertex buffers indexed by kind
  86058. */
  86059. getVertexBuffers(): Nullable<{
  86060. [key: string]: VertexBuffer;
  86061. }>;
  86062. /**
  86063. * Gets a boolean indicating if specific vertex buffer is present
  86064. * @param kind defines the data kind (Position, normal, etc...)
  86065. * @returns true if data is present
  86066. */
  86067. isVerticesDataPresent(kind: string): boolean;
  86068. /**
  86069. * Gets a list of all attached data kinds (Position, normal, etc...)
  86070. * @returns a list of string containing all kinds
  86071. */
  86072. getVerticesDataKinds(): string[];
  86073. /**
  86074. * Update index buffer
  86075. * @param indices defines the indices to store in the index buffer
  86076. * @param offset defines the offset in the target buffer where to store the data
  86077. * @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)
  86078. */
  86079. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  86080. /**
  86081. * Creates a new index buffer
  86082. * @param indices defines the indices to store in the index buffer
  86083. * @param totalVertices defines the total number of vertices (could be null)
  86084. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  86085. */
  86086. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  86087. /**
  86088. * Return the total number of indices
  86089. * @returns the total number of indices
  86090. */
  86091. getTotalIndices(): number;
  86092. /**
  86093. * Gets the index buffer array
  86094. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86095. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86096. * @returns the index buffer array
  86097. */
  86098. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  86099. /**
  86100. * Gets the index buffer
  86101. * @return the index buffer
  86102. */
  86103. getIndexBuffer(): Nullable<DataBuffer>;
  86104. /** @hidden */
  86105. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  86106. /**
  86107. * Release the associated resources for a specific mesh
  86108. * @param mesh defines the source mesh
  86109. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  86110. */
  86111. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  86112. /**
  86113. * Apply current geometry to a given mesh
  86114. * @param mesh defines the mesh to apply geometry to
  86115. */
  86116. applyToMesh(mesh: Mesh): void;
  86117. private _updateExtend;
  86118. private _applyToMesh;
  86119. private notifyUpdate;
  86120. /**
  86121. * Load the geometry if it was flagged as delay loaded
  86122. * @param scene defines the hosting scene
  86123. * @param onLoaded defines a callback called when the geometry is loaded
  86124. */
  86125. load(scene: Scene, onLoaded?: () => void): void;
  86126. private _queueLoad;
  86127. /**
  86128. * Invert the geometry to move from a right handed system to a left handed one.
  86129. */
  86130. toLeftHanded(): void;
  86131. /** @hidden */
  86132. _resetPointsArrayCache(): void;
  86133. /** @hidden */
  86134. _generatePointsArray(): boolean;
  86135. /**
  86136. * Gets a value indicating if the geometry is disposed
  86137. * @returns true if the geometry was disposed
  86138. */
  86139. isDisposed(): boolean;
  86140. private _disposeVertexArrayObjects;
  86141. /**
  86142. * Free all associated resources
  86143. */
  86144. dispose(): void;
  86145. /**
  86146. * Clone the current geometry into a new geometry
  86147. * @param id defines the unique ID of the new geometry
  86148. * @returns a new geometry object
  86149. */
  86150. copy(id: string): Geometry;
  86151. /**
  86152. * Serialize the current geometry info (and not the vertices data) into a JSON object
  86153. * @return a JSON representation of the current geometry data (without the vertices data)
  86154. */
  86155. serialize(): any;
  86156. private toNumberArray;
  86157. /**
  86158. * Serialize all vertices data into a JSON oject
  86159. * @returns a JSON representation of the current geometry data
  86160. */
  86161. serializeVerticeData(): any;
  86162. /**
  86163. * Extracts a clone of a mesh geometry
  86164. * @param mesh defines the source mesh
  86165. * @param id defines the unique ID of the new geometry object
  86166. * @returns the new geometry object
  86167. */
  86168. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  86169. /**
  86170. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  86171. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  86172. * Be aware Math.random() could cause collisions, but:
  86173. * "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"
  86174. * @returns a string containing a new GUID
  86175. */
  86176. static RandomId(): string;
  86177. /** @hidden */
  86178. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  86179. private static _CleanMatricesWeights;
  86180. /**
  86181. * Create a new geometry from persisted data (Using .babylon file format)
  86182. * @param parsedVertexData defines the persisted data
  86183. * @param scene defines the hosting scene
  86184. * @param rootUrl defines the root url to use to load assets (like delayed data)
  86185. * @returns the new geometry object
  86186. */
  86187. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  86188. }
  86189. }
  86190. declare module BABYLON {
  86191. /**
  86192. * Define an interface for all classes that will get and set the data on vertices
  86193. */
  86194. export interface IGetSetVerticesData {
  86195. /**
  86196. * Gets a boolean indicating if specific vertex data is present
  86197. * @param kind defines the vertex data kind to use
  86198. * @returns true is data kind is present
  86199. */
  86200. isVerticesDataPresent(kind: string): boolean;
  86201. /**
  86202. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  86203. * @param kind defines the data kind (Position, normal, etc...)
  86204. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86205. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86206. * @returns a float array containing vertex data
  86207. */
  86208. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  86209. /**
  86210. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  86211. * @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.
  86212. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86213. * @returns the indices array or an empty array if the mesh has no geometry
  86214. */
  86215. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  86216. /**
  86217. * Set specific vertex data
  86218. * @param kind defines the data kind (Position, normal, etc...)
  86219. * @param data defines the vertex data to use
  86220. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  86221. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  86222. */
  86223. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  86224. /**
  86225. * Update a specific associated vertex buffer
  86226. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  86227. * - VertexBuffer.PositionKind
  86228. * - VertexBuffer.UVKind
  86229. * - VertexBuffer.UV2Kind
  86230. * - VertexBuffer.UV3Kind
  86231. * - VertexBuffer.UV4Kind
  86232. * - VertexBuffer.UV5Kind
  86233. * - VertexBuffer.UV6Kind
  86234. * - VertexBuffer.ColorKind
  86235. * - VertexBuffer.MatricesIndicesKind
  86236. * - VertexBuffer.MatricesIndicesExtraKind
  86237. * - VertexBuffer.MatricesWeightsKind
  86238. * - VertexBuffer.MatricesWeightsExtraKind
  86239. * @param data defines the data source
  86240. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  86241. * @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)
  86242. */
  86243. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  86244. /**
  86245. * Creates a new index buffer
  86246. * @param indices defines the indices to store in the index buffer
  86247. * @param totalVertices defines the total number of vertices (could be null)
  86248. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  86249. */
  86250. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  86251. }
  86252. /**
  86253. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  86254. */
  86255. export class VertexData {
  86256. /**
  86257. * Mesh side orientation : usually the external or front surface
  86258. */
  86259. static readonly FRONTSIDE: number;
  86260. /**
  86261. * Mesh side orientation : usually the internal or back surface
  86262. */
  86263. static readonly BACKSIDE: number;
  86264. /**
  86265. * Mesh side orientation : both internal and external or front and back surfaces
  86266. */
  86267. static readonly DOUBLESIDE: number;
  86268. /**
  86269. * Mesh side orientation : by default, `FRONTSIDE`
  86270. */
  86271. static readonly DEFAULTSIDE: number;
  86272. /**
  86273. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  86274. */
  86275. positions: Nullable<FloatArray>;
  86276. /**
  86277. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  86278. */
  86279. normals: Nullable<FloatArray>;
  86280. /**
  86281. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  86282. */
  86283. tangents: Nullable<FloatArray>;
  86284. /**
  86285. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86286. */
  86287. uvs: Nullable<FloatArray>;
  86288. /**
  86289. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86290. */
  86291. uvs2: Nullable<FloatArray>;
  86292. /**
  86293. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86294. */
  86295. uvs3: Nullable<FloatArray>;
  86296. /**
  86297. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86298. */
  86299. uvs4: Nullable<FloatArray>;
  86300. /**
  86301. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86302. */
  86303. uvs5: Nullable<FloatArray>;
  86304. /**
  86305. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86306. */
  86307. uvs6: Nullable<FloatArray>;
  86308. /**
  86309. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  86310. */
  86311. colors: Nullable<FloatArray>;
  86312. /**
  86313. * 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).
  86314. */
  86315. matricesIndices: Nullable<FloatArray>;
  86316. /**
  86317. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  86318. */
  86319. matricesWeights: Nullable<FloatArray>;
  86320. /**
  86321. * An array extending the number of possible indices
  86322. */
  86323. matricesIndicesExtra: Nullable<FloatArray>;
  86324. /**
  86325. * An array extending the number of possible weights when the number of indices is extended
  86326. */
  86327. matricesWeightsExtra: Nullable<FloatArray>;
  86328. /**
  86329. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  86330. */
  86331. indices: Nullable<IndicesArray>;
  86332. /**
  86333. * Uses the passed data array to set the set the values for the specified kind of data
  86334. * @param data a linear array of floating numbers
  86335. * @param kind the type of data that is being set, eg positions, colors etc
  86336. */
  86337. set(data: FloatArray, kind: string): void;
  86338. /**
  86339. * Associates the vertexData to the passed Mesh.
  86340. * Sets it as updatable or not (default `false`)
  86341. * @param mesh the mesh the vertexData is applied to
  86342. * @param updatable when used and having the value true allows new data to update the vertexData
  86343. * @returns the VertexData
  86344. */
  86345. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  86346. /**
  86347. * Associates the vertexData to the passed Geometry.
  86348. * Sets it as updatable or not (default `false`)
  86349. * @param geometry the geometry the vertexData is applied to
  86350. * @param updatable when used and having the value true allows new data to update the vertexData
  86351. * @returns VertexData
  86352. */
  86353. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  86354. /**
  86355. * Updates the associated mesh
  86356. * @param mesh the mesh to be updated
  86357. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  86358. * @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
  86359. * @returns VertexData
  86360. */
  86361. updateMesh(mesh: Mesh): VertexData;
  86362. /**
  86363. * Updates the associated geometry
  86364. * @param geometry the geometry to be updated
  86365. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  86366. * @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
  86367. * @returns VertexData.
  86368. */
  86369. updateGeometry(geometry: Geometry): VertexData;
  86370. private _applyTo;
  86371. private _update;
  86372. /**
  86373. * Transforms each position and each normal of the vertexData according to the passed Matrix
  86374. * @param matrix the transforming matrix
  86375. * @returns the VertexData
  86376. */
  86377. transform(matrix: Matrix): VertexData;
  86378. /**
  86379. * Merges the passed VertexData into the current one
  86380. * @param other the VertexData to be merged into the current one
  86381. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  86382. * @returns the modified VertexData
  86383. */
  86384. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  86385. private _mergeElement;
  86386. private _validate;
  86387. /**
  86388. * Serializes the VertexData
  86389. * @returns a serialized object
  86390. */
  86391. serialize(): any;
  86392. /**
  86393. * Extracts the vertexData from a mesh
  86394. * @param mesh the mesh from which to extract the VertexData
  86395. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  86396. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  86397. * @returns the object VertexData associated to the passed mesh
  86398. */
  86399. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  86400. /**
  86401. * Extracts the vertexData from the geometry
  86402. * @param geometry the geometry from which to extract the VertexData
  86403. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  86404. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  86405. * @returns the object VertexData associated to the passed mesh
  86406. */
  86407. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  86408. private static _ExtractFrom;
  86409. /**
  86410. * Creates the VertexData for a Ribbon
  86411. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  86412. * * pathArray array of paths, each of which an array of successive Vector3
  86413. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  86414. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  86415. * * 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
  86416. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86417. * * 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)
  86418. * * 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)
  86419. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  86420. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  86421. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  86422. * @returns the VertexData of the ribbon
  86423. */
  86424. static CreateRibbon(options: {
  86425. pathArray: Vector3[][];
  86426. closeArray?: boolean;
  86427. closePath?: boolean;
  86428. offset?: number;
  86429. sideOrientation?: number;
  86430. frontUVs?: Vector4;
  86431. backUVs?: Vector4;
  86432. invertUV?: boolean;
  86433. uvs?: Vector2[];
  86434. colors?: Color4[];
  86435. }): VertexData;
  86436. /**
  86437. * Creates the VertexData for a box
  86438. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86439. * * size sets the width, height and depth of the box to the value of size, optional default 1
  86440. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  86441. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  86442. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  86443. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  86444. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  86445. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86446. * * 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)
  86447. * * 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)
  86448. * @returns the VertexData of the box
  86449. */
  86450. static CreateBox(options: {
  86451. size?: number;
  86452. width?: number;
  86453. height?: number;
  86454. depth?: number;
  86455. faceUV?: Vector4[];
  86456. faceColors?: Color4[];
  86457. sideOrientation?: number;
  86458. frontUVs?: Vector4;
  86459. backUVs?: Vector4;
  86460. }): VertexData;
  86461. /**
  86462. * Creates the VertexData for a tiled box
  86463. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86464. * * faceTiles sets the pattern, tile size and number of tiles for a face
  86465. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  86466. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  86467. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86468. * @returns the VertexData of the box
  86469. */
  86470. static CreateTiledBox(options: {
  86471. pattern?: number;
  86472. width?: number;
  86473. height?: number;
  86474. depth?: number;
  86475. tileSize?: number;
  86476. tileWidth?: number;
  86477. tileHeight?: number;
  86478. alignHorizontal?: number;
  86479. alignVertical?: number;
  86480. faceUV?: Vector4[];
  86481. faceColors?: Color4[];
  86482. sideOrientation?: number;
  86483. }): VertexData;
  86484. /**
  86485. * Creates the VertexData for a tiled plane
  86486. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86487. * * pattern a limited pattern arrangement depending on the number
  86488. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  86489. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  86490. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  86491. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86492. * * 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)
  86493. * * 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)
  86494. * @returns the VertexData of the tiled plane
  86495. */
  86496. static CreateTiledPlane(options: {
  86497. pattern?: number;
  86498. tileSize?: number;
  86499. tileWidth?: number;
  86500. tileHeight?: number;
  86501. size?: number;
  86502. width?: number;
  86503. height?: number;
  86504. alignHorizontal?: number;
  86505. alignVertical?: number;
  86506. sideOrientation?: number;
  86507. frontUVs?: Vector4;
  86508. backUVs?: Vector4;
  86509. }): VertexData;
  86510. /**
  86511. * Creates the VertexData for an ellipsoid, defaults to a sphere
  86512. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86513. * * segments sets the number of horizontal strips optional, default 32
  86514. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  86515. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  86516. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  86517. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  86518. * * 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
  86519. * * 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
  86520. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86521. * * 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)
  86522. * * 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)
  86523. * @returns the VertexData of the ellipsoid
  86524. */
  86525. static CreateSphere(options: {
  86526. segments?: number;
  86527. diameter?: number;
  86528. diameterX?: number;
  86529. diameterY?: number;
  86530. diameterZ?: number;
  86531. arc?: number;
  86532. slice?: number;
  86533. sideOrientation?: number;
  86534. frontUVs?: Vector4;
  86535. backUVs?: Vector4;
  86536. }): VertexData;
  86537. /**
  86538. * Creates the VertexData for a cylinder, cone or prism
  86539. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86540. * * height sets the height (y direction) of the cylinder, optional, default 2
  86541. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  86542. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  86543. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  86544. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86545. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  86546. * * 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
  86547. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86548. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86549. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  86550. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  86551. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86552. * * 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)
  86553. * * 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)
  86554. * @returns the VertexData of the cylinder, cone or prism
  86555. */
  86556. static CreateCylinder(options: {
  86557. height?: number;
  86558. diameterTop?: number;
  86559. diameterBottom?: number;
  86560. diameter?: number;
  86561. tessellation?: number;
  86562. subdivisions?: number;
  86563. arc?: number;
  86564. faceColors?: Color4[];
  86565. faceUV?: Vector4[];
  86566. hasRings?: boolean;
  86567. enclose?: boolean;
  86568. sideOrientation?: number;
  86569. frontUVs?: Vector4;
  86570. backUVs?: Vector4;
  86571. }): VertexData;
  86572. /**
  86573. * Creates the VertexData for a torus
  86574. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86575. * * diameter the diameter of the torus, optional default 1
  86576. * * thickness the diameter of the tube forming the torus, optional default 0.5
  86577. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86578. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86579. * * 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)
  86580. * * 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)
  86581. * @returns the VertexData of the torus
  86582. */
  86583. static CreateTorus(options: {
  86584. diameter?: number;
  86585. thickness?: number;
  86586. tessellation?: number;
  86587. sideOrientation?: number;
  86588. frontUVs?: Vector4;
  86589. backUVs?: Vector4;
  86590. }): VertexData;
  86591. /**
  86592. * Creates the VertexData of the LineSystem
  86593. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  86594. * - lines an array of lines, each line being an array of successive Vector3
  86595. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  86596. * @returns the VertexData of the LineSystem
  86597. */
  86598. static CreateLineSystem(options: {
  86599. lines: Vector3[][];
  86600. colors?: Nullable<Color4[][]>;
  86601. }): VertexData;
  86602. /**
  86603. * Create the VertexData for a DashedLines
  86604. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  86605. * - points an array successive Vector3
  86606. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  86607. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  86608. * - dashNb the intended total number of dashes, optional, default 200
  86609. * @returns the VertexData for the DashedLines
  86610. */
  86611. static CreateDashedLines(options: {
  86612. points: Vector3[];
  86613. dashSize?: number;
  86614. gapSize?: number;
  86615. dashNb?: number;
  86616. }): VertexData;
  86617. /**
  86618. * Creates the VertexData for a Ground
  86619. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86620. * - width the width (x direction) of the ground, optional, default 1
  86621. * - height the height (z direction) of the ground, optional, default 1
  86622. * - subdivisions the number of subdivisions per side, optional, default 1
  86623. * @returns the VertexData of the Ground
  86624. */
  86625. static CreateGround(options: {
  86626. width?: number;
  86627. height?: number;
  86628. subdivisions?: number;
  86629. subdivisionsX?: number;
  86630. subdivisionsY?: number;
  86631. }): VertexData;
  86632. /**
  86633. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  86634. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86635. * * xmin the ground minimum X coordinate, optional, default -1
  86636. * * zmin the ground minimum Z coordinate, optional, default -1
  86637. * * xmax the ground maximum X coordinate, optional, default 1
  86638. * * zmax the ground maximum Z coordinate, optional, default 1
  86639. * * 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}
  86640. * * 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}
  86641. * @returns the VertexData of the TiledGround
  86642. */
  86643. static CreateTiledGround(options: {
  86644. xmin: number;
  86645. zmin: number;
  86646. xmax: number;
  86647. zmax: number;
  86648. subdivisions?: {
  86649. w: number;
  86650. h: number;
  86651. };
  86652. precision?: {
  86653. w: number;
  86654. h: number;
  86655. };
  86656. }): VertexData;
  86657. /**
  86658. * Creates the VertexData of the Ground designed from a heightmap
  86659. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  86660. * * width the width (x direction) of the ground
  86661. * * height the height (z direction) of the ground
  86662. * * subdivisions the number of subdivisions per side
  86663. * * minHeight the minimum altitude on the ground, optional, default 0
  86664. * * maxHeight the maximum altitude on the ground, optional default 1
  86665. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  86666. * * buffer the array holding the image color data
  86667. * * bufferWidth the width of image
  86668. * * bufferHeight the height of image
  86669. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  86670. * @returns the VertexData of the Ground designed from a heightmap
  86671. */
  86672. static CreateGroundFromHeightMap(options: {
  86673. width: number;
  86674. height: number;
  86675. subdivisions: number;
  86676. minHeight: number;
  86677. maxHeight: number;
  86678. colorFilter: Color3;
  86679. buffer: Uint8Array;
  86680. bufferWidth: number;
  86681. bufferHeight: number;
  86682. alphaFilter: number;
  86683. }): VertexData;
  86684. /**
  86685. * Creates the VertexData for a Plane
  86686. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  86687. * * size sets the width and height of the plane to the value of size, optional default 1
  86688. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  86689. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  86690. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86691. * * 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)
  86692. * * 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)
  86693. * @returns the VertexData of the box
  86694. */
  86695. static CreatePlane(options: {
  86696. size?: number;
  86697. width?: number;
  86698. height?: number;
  86699. sideOrientation?: number;
  86700. frontUVs?: Vector4;
  86701. backUVs?: Vector4;
  86702. }): VertexData;
  86703. /**
  86704. * Creates the VertexData of the Disc or regular Polygon
  86705. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  86706. * * radius the radius of the disc, optional default 0.5
  86707. * * tessellation the number of polygon sides, optional, default 64
  86708. * * 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
  86709. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86710. * * 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)
  86711. * * 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)
  86712. * @returns the VertexData of the box
  86713. */
  86714. static CreateDisc(options: {
  86715. radius?: number;
  86716. tessellation?: number;
  86717. arc?: number;
  86718. sideOrientation?: number;
  86719. frontUVs?: Vector4;
  86720. backUVs?: Vector4;
  86721. }): VertexData;
  86722. /**
  86723. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  86724. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  86725. * @param polygon a mesh built from polygonTriangulation.build()
  86726. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86727. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86728. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86729. * @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)
  86730. * @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)
  86731. * @returns the VertexData of the Polygon
  86732. */
  86733. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  86734. /**
  86735. * Creates the VertexData of the IcoSphere
  86736. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  86737. * * radius the radius of the IcoSphere, optional default 1
  86738. * * radiusX allows stretching in the x direction, optional, default radius
  86739. * * radiusY allows stretching in the y direction, optional, default radius
  86740. * * radiusZ allows stretching in the z direction, optional, default radius
  86741. * * flat when true creates a flat shaded mesh, optional, default true
  86742. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86743. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86744. * * 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)
  86745. * * 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)
  86746. * @returns the VertexData of the IcoSphere
  86747. */
  86748. static CreateIcoSphere(options: {
  86749. radius?: number;
  86750. radiusX?: number;
  86751. radiusY?: number;
  86752. radiusZ?: number;
  86753. flat?: boolean;
  86754. subdivisions?: number;
  86755. sideOrientation?: number;
  86756. frontUVs?: Vector4;
  86757. backUVs?: Vector4;
  86758. }): VertexData;
  86759. /**
  86760. * Creates the VertexData for a Polyhedron
  86761. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  86762. * * type provided types are:
  86763. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  86764. * * 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)
  86765. * * size the size of the IcoSphere, optional default 1
  86766. * * sizeX allows stretching in the x direction, optional, default size
  86767. * * sizeY allows stretching in the y direction, optional, default size
  86768. * * sizeZ allows stretching in the z direction, optional, default size
  86769. * * 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
  86770. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86771. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86772. * * flat when true creates a flat shaded mesh, optional, default true
  86773. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86774. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86775. * * 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)
  86776. * * 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)
  86777. * @returns the VertexData of the Polyhedron
  86778. */
  86779. static CreatePolyhedron(options: {
  86780. type?: number;
  86781. size?: number;
  86782. sizeX?: number;
  86783. sizeY?: number;
  86784. sizeZ?: number;
  86785. custom?: any;
  86786. faceUV?: Vector4[];
  86787. faceColors?: Color4[];
  86788. flat?: boolean;
  86789. sideOrientation?: number;
  86790. frontUVs?: Vector4;
  86791. backUVs?: Vector4;
  86792. }): VertexData;
  86793. /**
  86794. * Creates the VertexData for a TorusKnot
  86795. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  86796. * * radius the radius of the torus knot, optional, default 2
  86797. * * tube the thickness of the tube, optional, default 0.5
  86798. * * radialSegments the number of sides on each tube segments, optional, default 32
  86799. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  86800. * * p the number of windings around the z axis, optional, default 2
  86801. * * q the number of windings around the x axis, optional, default 3
  86802. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86803. * * 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)
  86804. * * 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)
  86805. * @returns the VertexData of the Torus Knot
  86806. */
  86807. static CreateTorusKnot(options: {
  86808. radius?: number;
  86809. tube?: number;
  86810. radialSegments?: number;
  86811. tubularSegments?: number;
  86812. p?: number;
  86813. q?: number;
  86814. sideOrientation?: number;
  86815. frontUVs?: Vector4;
  86816. backUVs?: Vector4;
  86817. }): VertexData;
  86818. /**
  86819. * Compute normals for given positions and indices
  86820. * @param positions an array of vertex positions, [...., x, y, z, ......]
  86821. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  86822. * @param normals an array of vertex normals, [...., x, y, z, ......]
  86823. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  86824. * * facetNormals : optional array of facet normals (vector3)
  86825. * * facetPositions : optional array of facet positions (vector3)
  86826. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  86827. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  86828. * * bInfo : optional bounding info, required for facetPartitioning computation
  86829. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  86830. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  86831. * * useRightHandedSystem: optional boolean to for right handed system computation
  86832. * * depthSort : optional boolean to enable the facet depth sort computation
  86833. * * distanceTo : optional Vector3 to compute the facet depth from this location
  86834. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  86835. */
  86836. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  86837. facetNormals?: any;
  86838. facetPositions?: any;
  86839. facetPartitioning?: any;
  86840. ratio?: number;
  86841. bInfo?: any;
  86842. bbSize?: Vector3;
  86843. subDiv?: any;
  86844. useRightHandedSystem?: boolean;
  86845. depthSort?: boolean;
  86846. distanceTo?: Vector3;
  86847. depthSortedFacets?: any;
  86848. }): void;
  86849. /** @hidden */
  86850. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  86851. /**
  86852. * Applies VertexData created from the imported parameters to the geometry
  86853. * @param parsedVertexData the parsed data from an imported file
  86854. * @param geometry the geometry to apply the VertexData to
  86855. */
  86856. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  86857. }
  86858. }
  86859. declare module BABYLON {
  86860. /**
  86861. * Class containing static functions to help procedurally build meshes
  86862. */
  86863. export class DiscBuilder {
  86864. /**
  86865. * Creates a plane polygonal mesh. By default, this is a disc
  86866. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  86867. * * 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
  86868. * * 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
  86869. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86870. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  86871. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86872. * @param name defines the name of the mesh
  86873. * @param options defines the options used to create the mesh
  86874. * @param scene defines the hosting scene
  86875. * @returns the plane polygonal mesh
  86876. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  86877. */
  86878. static CreateDisc(name: string, options: {
  86879. radius?: number;
  86880. tessellation?: number;
  86881. arc?: number;
  86882. updatable?: boolean;
  86883. sideOrientation?: number;
  86884. frontUVs?: Vector4;
  86885. backUVs?: Vector4;
  86886. }, scene?: Nullable<Scene>): Mesh;
  86887. }
  86888. }
  86889. declare module BABYLON {
  86890. /**
  86891. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  86892. *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.
  86893. * The SPS is also a particle system. It provides some methods to manage the particles.
  86894. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  86895. *
  86896. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  86897. */
  86898. export class SolidParticleSystem implements IDisposable {
  86899. /**
  86900. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  86901. * Example : var p = SPS.particles[i];
  86902. */
  86903. particles: SolidParticle[];
  86904. /**
  86905. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  86906. */
  86907. nbParticles: number;
  86908. /**
  86909. * If the particles must ever face the camera (default false). Useful for planar particles.
  86910. */
  86911. billboard: boolean;
  86912. /**
  86913. * Recompute normals when adding a shape
  86914. */
  86915. recomputeNormals: boolean;
  86916. /**
  86917. * This a counter ofr your own usage. It's not set by any SPS functions.
  86918. */
  86919. counter: number;
  86920. /**
  86921. * The SPS name. This name is also given to the underlying mesh.
  86922. */
  86923. name: string;
  86924. /**
  86925. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  86926. */
  86927. mesh: Mesh;
  86928. /**
  86929. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  86930. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  86931. */
  86932. vars: any;
  86933. /**
  86934. * This array is populated when the SPS is set as 'pickable'.
  86935. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  86936. * Each element of this array is an object `{idx: int, faceId: int}`.
  86937. * `idx` is the picked particle index in the `SPS.particles` array
  86938. * `faceId` is the picked face index counted within this particle.
  86939. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  86940. */
  86941. pickedParticles: {
  86942. idx: number;
  86943. faceId: number;
  86944. }[];
  86945. /**
  86946. * This array is populated when `enableDepthSort` is set to true.
  86947. * Each element of this array is an instance of the class DepthSortedParticle.
  86948. */
  86949. depthSortedParticles: DepthSortedParticle[];
  86950. /**
  86951. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  86952. * @hidden
  86953. */
  86954. _bSphereOnly: boolean;
  86955. /**
  86956. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  86957. * @hidden
  86958. */
  86959. _bSphereRadiusFactor: number;
  86960. private _scene;
  86961. private _positions;
  86962. private _indices;
  86963. private _normals;
  86964. private _colors;
  86965. private _uvs;
  86966. private _indices32;
  86967. private _positions32;
  86968. private _normals32;
  86969. private _fixedNormal32;
  86970. private _colors32;
  86971. private _uvs32;
  86972. private _index;
  86973. private _updatable;
  86974. private _pickable;
  86975. private _isVisibilityBoxLocked;
  86976. private _alwaysVisible;
  86977. private _depthSort;
  86978. private _shapeCounter;
  86979. private _copy;
  86980. private _color;
  86981. private _computeParticleColor;
  86982. private _computeParticleTexture;
  86983. private _computeParticleRotation;
  86984. private _computeParticleVertex;
  86985. private _computeBoundingBox;
  86986. private _depthSortParticles;
  86987. private _camera;
  86988. private _mustUnrotateFixedNormals;
  86989. private _particlesIntersect;
  86990. private _needs32Bits;
  86991. /**
  86992. * Creates a SPS (Solid Particle System) object.
  86993. * @param name (String) is the SPS name, this will be the underlying mesh name.
  86994. * @param scene (Scene) is the scene in which the SPS is added.
  86995. * @param options defines the options of the sps e.g.
  86996. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  86997. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  86998. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  86999. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  87000. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  87001. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  87002. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  87003. */
  87004. constructor(name: string, scene: Scene, options?: {
  87005. updatable?: boolean;
  87006. isPickable?: boolean;
  87007. enableDepthSort?: boolean;
  87008. particleIntersection?: boolean;
  87009. boundingSphereOnly?: boolean;
  87010. bSphereRadiusFactor?: number;
  87011. });
  87012. /**
  87013. * Builds the SPS underlying mesh. Returns a standard Mesh.
  87014. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  87015. * @returns the created mesh
  87016. */
  87017. buildMesh(): Mesh;
  87018. /**
  87019. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  87020. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  87021. * Thus the particles generated from `digest()` have their property `position` set yet.
  87022. * @param mesh ( Mesh ) is the mesh to be digested
  87023. * @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
  87024. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  87025. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  87026. * @returns the current SPS
  87027. */
  87028. digest(mesh: Mesh, options?: {
  87029. facetNb?: number;
  87030. number?: number;
  87031. delta?: number;
  87032. }): SolidParticleSystem;
  87033. private _unrotateFixedNormals;
  87034. private _resetCopy;
  87035. private _meshBuilder;
  87036. private _posToShape;
  87037. private _uvsToShapeUV;
  87038. private _addParticle;
  87039. /**
  87040. * Adds some particles to the SPS from the model shape. Returns the shape id.
  87041. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  87042. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  87043. * @param nb (positive integer) the number of particles to be created from this model
  87044. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  87045. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  87046. * @returns the number of shapes in the system
  87047. */
  87048. addShape(mesh: Mesh, nb: number, options?: {
  87049. positionFunction?: any;
  87050. vertexFunction?: any;
  87051. }): number;
  87052. private _rebuildParticle;
  87053. /**
  87054. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  87055. * @returns the SPS.
  87056. */
  87057. rebuildMesh(): SolidParticleSystem;
  87058. /**
  87059. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  87060. * This method calls `updateParticle()` for each particle of the SPS.
  87061. * For an animated SPS, it is usually called within the render loop.
  87062. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  87063. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  87064. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  87065. * @returns the SPS.
  87066. */
  87067. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  87068. /**
  87069. * Disposes the SPS.
  87070. */
  87071. dispose(): void;
  87072. /**
  87073. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  87074. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  87075. * @returns the SPS.
  87076. */
  87077. refreshVisibleSize(): SolidParticleSystem;
  87078. /**
  87079. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  87080. * @param size the size (float) of the visibility box
  87081. * note : this doesn't lock the SPS mesh bounding box.
  87082. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  87083. */
  87084. setVisibilityBox(size: number): void;
  87085. /**
  87086. * Gets whether the SPS as always visible or not
  87087. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  87088. */
  87089. /**
  87090. * Sets the SPS as always visible or not
  87091. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  87092. */
  87093. isAlwaysVisible: boolean;
  87094. /**
  87095. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  87096. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  87097. */
  87098. /**
  87099. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  87100. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  87101. */
  87102. isVisibilityBoxLocked: boolean;
  87103. /**
  87104. * Tells to `setParticles()` to compute the particle rotations or not.
  87105. * Default value : true. The SPS is faster when it's set to false.
  87106. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  87107. */
  87108. /**
  87109. * Gets if `setParticles()` computes the particle rotations or not.
  87110. * Default value : true. The SPS is faster when it's set to false.
  87111. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  87112. */
  87113. computeParticleRotation: boolean;
  87114. /**
  87115. * Tells to `setParticles()` to compute the particle colors or not.
  87116. * Default value : true. The SPS is faster when it's set to false.
  87117. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  87118. */
  87119. /**
  87120. * Gets if `setParticles()` computes the particle colors or not.
  87121. * Default value : true. The SPS is faster when it's set to false.
  87122. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  87123. */
  87124. computeParticleColor: boolean;
  87125. /**
  87126. * Gets if `setParticles()` computes the particle textures or not.
  87127. * Default value : true. The SPS is faster when it's set to false.
  87128. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  87129. */
  87130. computeParticleTexture: boolean;
  87131. /**
  87132. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  87133. * Default value : false. The SPS is faster when it's set to false.
  87134. * Note : the particle custom vertex positions aren't stored values.
  87135. */
  87136. /**
  87137. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  87138. * Default value : false. The SPS is faster when it's set to false.
  87139. * Note : the particle custom vertex positions aren't stored values.
  87140. */
  87141. computeParticleVertex: boolean;
  87142. /**
  87143. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  87144. */
  87145. /**
  87146. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  87147. */
  87148. computeBoundingBox: boolean;
  87149. /**
  87150. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  87151. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  87152. * Default : `true`
  87153. */
  87154. /**
  87155. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  87156. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  87157. * Default : `true`
  87158. */
  87159. depthSortParticles: boolean;
  87160. /**
  87161. * This function does nothing. It may be overwritten to set all the particle first values.
  87162. * The SPS doesn't call this function, you may have to call it by your own.
  87163. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  87164. */
  87165. initParticles(): void;
  87166. /**
  87167. * This function does nothing. It may be overwritten to recycle a particle.
  87168. * The SPS doesn't call this function, you may have to call it by your own.
  87169. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  87170. * @param particle The particle to recycle
  87171. * @returns the recycled particle
  87172. */
  87173. recycleParticle(particle: SolidParticle): SolidParticle;
  87174. /**
  87175. * Updates a particle : this function should be overwritten by the user.
  87176. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  87177. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  87178. * @example : just set a particle position or velocity and recycle conditions
  87179. * @param particle The particle to update
  87180. * @returns the updated particle
  87181. */
  87182. updateParticle(particle: SolidParticle): SolidParticle;
  87183. /**
  87184. * Updates a vertex of a particle : it can be overwritten by the user.
  87185. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  87186. * @param particle the current particle
  87187. * @param vertex the current index of the current particle
  87188. * @param pt the index of the current vertex in the particle shape
  87189. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  87190. * @example : just set a vertex particle position
  87191. * @returns the updated vertex
  87192. */
  87193. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  87194. /**
  87195. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  87196. * This does nothing and may be overwritten by the user.
  87197. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  87198. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  87199. * @param update the boolean update value actually passed to setParticles()
  87200. */
  87201. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  87202. /**
  87203. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  87204. * This will be passed three parameters.
  87205. * This does nothing and may be overwritten by the user.
  87206. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  87207. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  87208. * @param update the boolean update value actually passed to setParticles()
  87209. */
  87210. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  87211. }
  87212. }
  87213. declare module BABYLON {
  87214. /**
  87215. * Represents one particle of a solid particle system.
  87216. */
  87217. export class SolidParticle {
  87218. /**
  87219. * particle global index
  87220. */
  87221. idx: number;
  87222. /**
  87223. * The color of the particle
  87224. */
  87225. color: Nullable<Color4>;
  87226. /**
  87227. * The world space position of the particle.
  87228. */
  87229. position: Vector3;
  87230. /**
  87231. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  87232. */
  87233. rotation: Vector3;
  87234. /**
  87235. * The world space rotation quaternion of the particle.
  87236. */
  87237. rotationQuaternion: Nullable<Quaternion>;
  87238. /**
  87239. * The scaling of the particle.
  87240. */
  87241. scaling: Vector3;
  87242. /**
  87243. * The uvs of the particle.
  87244. */
  87245. uvs: Vector4;
  87246. /**
  87247. * The current speed of the particle.
  87248. */
  87249. velocity: Vector3;
  87250. /**
  87251. * The pivot point in the particle local space.
  87252. */
  87253. pivot: Vector3;
  87254. /**
  87255. * Must the particle be translated from its pivot point in its local space ?
  87256. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  87257. * Default : false
  87258. */
  87259. translateFromPivot: boolean;
  87260. /**
  87261. * Is the particle active or not ?
  87262. */
  87263. alive: boolean;
  87264. /**
  87265. * Is the particle visible or not ?
  87266. */
  87267. isVisible: boolean;
  87268. /**
  87269. * Index of this particle in the global "positions" array (Internal use)
  87270. * @hidden
  87271. */
  87272. _pos: number;
  87273. /**
  87274. * @hidden Index of this particle in the global "indices" array (Internal use)
  87275. */
  87276. _ind: number;
  87277. /**
  87278. * @hidden ModelShape of this particle (Internal use)
  87279. */
  87280. _model: ModelShape;
  87281. /**
  87282. * ModelShape id of this particle
  87283. */
  87284. shapeId: number;
  87285. /**
  87286. * Index of the particle in its shape id (Internal use)
  87287. */
  87288. idxInShape: number;
  87289. /**
  87290. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  87291. */
  87292. _modelBoundingInfo: BoundingInfo;
  87293. /**
  87294. * @hidden Particle BoundingInfo object (Internal use)
  87295. */
  87296. _boundingInfo: BoundingInfo;
  87297. /**
  87298. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  87299. */
  87300. _sps: SolidParticleSystem;
  87301. /**
  87302. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  87303. */
  87304. _stillInvisible: boolean;
  87305. /**
  87306. * @hidden Last computed particle rotation matrix
  87307. */
  87308. _rotationMatrix: number[];
  87309. /**
  87310. * Parent particle Id, if any.
  87311. * Default null.
  87312. */
  87313. parentId: Nullable<number>;
  87314. /**
  87315. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  87316. * The possible values are :
  87317. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  87318. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  87319. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  87320. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  87321. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  87322. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  87323. * */
  87324. cullingStrategy: number;
  87325. /**
  87326. * @hidden Internal global position in the SPS.
  87327. */
  87328. _globalPosition: Vector3;
  87329. /**
  87330. * Creates a Solid Particle object.
  87331. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  87332. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  87333. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  87334. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  87335. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  87336. * @param shapeId (integer) is the model shape identifier in the SPS.
  87337. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  87338. * @param sps defines the sps it is associated to
  87339. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  87340. */
  87341. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  87342. /**
  87343. * Legacy support, changed scale to scaling
  87344. */
  87345. /**
  87346. * Legacy support, changed scale to scaling
  87347. */
  87348. scale: Vector3;
  87349. /**
  87350. * Legacy support, changed quaternion to rotationQuaternion
  87351. */
  87352. /**
  87353. * Legacy support, changed quaternion to rotationQuaternion
  87354. */
  87355. quaternion: Nullable<Quaternion>;
  87356. /**
  87357. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  87358. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  87359. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  87360. * @returns true if it intersects
  87361. */
  87362. intersectsMesh(target: Mesh | SolidParticle): boolean;
  87363. /**
  87364. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  87365. * A particle is in the frustum if its bounding box intersects the frustum
  87366. * @param frustumPlanes defines the frustum to test
  87367. * @returns true if the particle is in the frustum planes
  87368. */
  87369. isInFrustum(frustumPlanes: Plane[]): boolean;
  87370. /**
  87371. * get the rotation matrix of the particle
  87372. * @hidden
  87373. */
  87374. getRotationMatrix(m: Matrix): void;
  87375. }
  87376. /**
  87377. * Represents the shape of the model used by one particle of a solid particle system.
  87378. * SPS internal tool, don't use it manually.
  87379. */
  87380. export class ModelShape {
  87381. /**
  87382. * The shape id
  87383. * @hidden
  87384. */
  87385. shapeID: number;
  87386. /**
  87387. * flat array of model positions (internal use)
  87388. * @hidden
  87389. */
  87390. _shape: Vector3[];
  87391. /**
  87392. * flat array of model UVs (internal use)
  87393. * @hidden
  87394. */
  87395. _shapeUV: number[];
  87396. /**
  87397. * length of the shape in the model indices array (internal use)
  87398. * @hidden
  87399. */
  87400. _indicesLength: number;
  87401. /**
  87402. * Custom position function (internal use)
  87403. * @hidden
  87404. */
  87405. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  87406. /**
  87407. * Custom vertex function (internal use)
  87408. * @hidden
  87409. */
  87410. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  87411. /**
  87412. * 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.
  87413. * SPS internal tool, don't use it manually.
  87414. * @hidden
  87415. */
  87416. 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>);
  87417. }
  87418. /**
  87419. * Represents a Depth Sorted Particle in the solid particle system.
  87420. */
  87421. export class DepthSortedParticle {
  87422. /**
  87423. * Index of the particle in the "indices" array
  87424. */
  87425. ind: number;
  87426. /**
  87427. * Length of the particle shape in the "indices" array
  87428. */
  87429. indicesLength: number;
  87430. /**
  87431. * Squared distance from the particle to the camera
  87432. */
  87433. sqDistance: number;
  87434. }
  87435. }
  87436. declare module BABYLON {
  87437. /**
  87438. * @hidden
  87439. */
  87440. export class _MeshCollisionData {
  87441. _checkCollisions: boolean;
  87442. _collisionMask: number;
  87443. _collisionGroup: number;
  87444. _collider: Nullable<Collider>;
  87445. _oldPositionForCollisions: Vector3;
  87446. _diffPositionForCollisions: Vector3;
  87447. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  87448. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  87449. }
  87450. }
  87451. declare module BABYLON {
  87452. /** @hidden */
  87453. class _FacetDataStorage {
  87454. facetPositions: Vector3[];
  87455. facetNormals: Vector3[];
  87456. facetPartitioning: number[][];
  87457. facetNb: number;
  87458. partitioningSubdivisions: number;
  87459. partitioningBBoxRatio: number;
  87460. facetDataEnabled: boolean;
  87461. facetParameters: any;
  87462. bbSize: Vector3;
  87463. subDiv: {
  87464. max: number;
  87465. X: number;
  87466. Y: number;
  87467. Z: number;
  87468. };
  87469. facetDepthSort: boolean;
  87470. facetDepthSortEnabled: boolean;
  87471. depthSortedIndices: IndicesArray;
  87472. depthSortedFacets: {
  87473. ind: number;
  87474. sqDistance: number;
  87475. }[];
  87476. facetDepthSortFunction: (f1: {
  87477. ind: number;
  87478. sqDistance: number;
  87479. }, f2: {
  87480. ind: number;
  87481. sqDistance: number;
  87482. }) => number;
  87483. facetDepthSortFrom: Vector3;
  87484. facetDepthSortOrigin: Vector3;
  87485. invertedMatrix: Matrix;
  87486. }
  87487. /**
  87488. * @hidden
  87489. **/
  87490. class _InternalAbstractMeshDataInfo {
  87491. _hasVertexAlpha: boolean;
  87492. _useVertexColors: boolean;
  87493. _numBoneInfluencers: number;
  87494. _applyFog: boolean;
  87495. _receiveShadows: boolean;
  87496. _facetData: _FacetDataStorage;
  87497. _visibility: number;
  87498. _skeleton: Nullable<Skeleton>;
  87499. _layerMask: number;
  87500. _computeBonesUsingShaders: boolean;
  87501. _isActive: boolean;
  87502. _onlyForInstances: boolean;
  87503. _isActiveIntermediate: boolean;
  87504. _onlyForInstancesIntermediate: boolean;
  87505. }
  87506. /**
  87507. * Class used to store all common mesh properties
  87508. */
  87509. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  87510. /** No occlusion */
  87511. static OCCLUSION_TYPE_NONE: number;
  87512. /** Occlusion set to optimisitic */
  87513. static OCCLUSION_TYPE_OPTIMISTIC: number;
  87514. /** Occlusion set to strict */
  87515. static OCCLUSION_TYPE_STRICT: number;
  87516. /** Use an accurante occlusion algorithm */
  87517. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  87518. /** Use a conservative occlusion algorithm */
  87519. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  87520. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  87521. * Test order :
  87522. * Is the bounding sphere outside the frustum ?
  87523. * If not, are the bounding box vertices outside the frustum ?
  87524. * It not, then the cullable object is in the frustum.
  87525. */
  87526. static readonly CULLINGSTRATEGY_STANDARD: number;
  87527. /** Culling strategy : Bounding Sphere Only.
  87528. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  87529. * It's also less accurate than the standard because some not visible objects can still be selected.
  87530. * Test : is the bounding sphere outside the frustum ?
  87531. * If not, then the cullable object is in the frustum.
  87532. */
  87533. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  87534. /** Culling strategy : Optimistic Inclusion.
  87535. * This in an inclusion test first, then the standard exclusion test.
  87536. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  87537. * 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.
  87538. * Anyway, it's as accurate as the standard strategy.
  87539. * Test :
  87540. * Is the cullable object bounding sphere center in the frustum ?
  87541. * If not, apply the default culling strategy.
  87542. */
  87543. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  87544. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  87545. * This in an inclusion test first, then the bounding sphere only exclusion test.
  87546. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  87547. * 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.
  87548. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  87549. * Test :
  87550. * Is the cullable object bounding sphere center in the frustum ?
  87551. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  87552. */
  87553. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  87554. /**
  87555. * No billboard
  87556. */
  87557. static readonly BILLBOARDMODE_NONE: number;
  87558. /** Billboard on X axis */
  87559. static readonly BILLBOARDMODE_X: number;
  87560. /** Billboard on Y axis */
  87561. static readonly BILLBOARDMODE_Y: number;
  87562. /** Billboard on Z axis */
  87563. static readonly BILLBOARDMODE_Z: number;
  87564. /** Billboard on all axes */
  87565. static readonly BILLBOARDMODE_ALL: number;
  87566. /** @hidden */
  87567. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  87568. /**
  87569. * The culling strategy to use to check whether the mesh must be rendered or not.
  87570. * This value can be changed at any time and will be used on the next render mesh selection.
  87571. * The possible values are :
  87572. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  87573. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  87574. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  87575. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  87576. * Please read each static variable documentation to get details about the culling process.
  87577. * */
  87578. cullingStrategy: number;
  87579. /**
  87580. * Gets the number of facets in the mesh
  87581. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  87582. */
  87583. readonly facetNb: number;
  87584. /**
  87585. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  87586. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  87587. */
  87588. partitioningSubdivisions: number;
  87589. /**
  87590. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  87591. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  87592. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  87593. */
  87594. partitioningBBoxRatio: number;
  87595. /**
  87596. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  87597. * Works only for updatable meshes.
  87598. * Doesn't work with multi-materials
  87599. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  87600. */
  87601. mustDepthSortFacets: boolean;
  87602. /**
  87603. * The location (Vector3) where the facet depth sort must be computed from.
  87604. * By default, the active camera position.
  87605. * Used only when facet depth sort is enabled
  87606. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  87607. */
  87608. facetDepthSortFrom: Vector3;
  87609. /**
  87610. * gets a boolean indicating if facetData is enabled
  87611. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  87612. */
  87613. readonly isFacetDataEnabled: boolean;
  87614. /** @hidden */
  87615. _updateNonUniformScalingState(value: boolean): boolean;
  87616. /**
  87617. * An event triggered when this mesh collides with another one
  87618. */
  87619. onCollideObservable: Observable<AbstractMesh>;
  87620. /** Set a function to call when this mesh collides with another one */
  87621. onCollide: () => void;
  87622. /**
  87623. * An event triggered when the collision's position changes
  87624. */
  87625. onCollisionPositionChangeObservable: Observable<Vector3>;
  87626. /** Set a function to call when the collision's position changes */
  87627. onCollisionPositionChange: () => void;
  87628. /**
  87629. * An event triggered when material is changed
  87630. */
  87631. onMaterialChangedObservable: Observable<AbstractMesh>;
  87632. /**
  87633. * Gets or sets the orientation for POV movement & rotation
  87634. */
  87635. definedFacingForward: boolean;
  87636. /** @hidden */
  87637. _occlusionQuery: Nullable<WebGLQuery>;
  87638. /** @hidden */
  87639. _renderingGroup: Nullable<RenderingGroup>;
  87640. /**
  87641. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  87642. */
  87643. /**
  87644. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  87645. */
  87646. visibility: number;
  87647. /** Gets or sets the alpha index used to sort transparent meshes
  87648. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  87649. */
  87650. alphaIndex: number;
  87651. /**
  87652. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  87653. */
  87654. isVisible: boolean;
  87655. /**
  87656. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  87657. */
  87658. isPickable: boolean;
  87659. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  87660. showSubMeshesBoundingBox: boolean;
  87661. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  87662. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  87663. */
  87664. isBlocker: boolean;
  87665. /**
  87666. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  87667. */
  87668. enablePointerMoveEvents: boolean;
  87669. /**
  87670. * Specifies the rendering group id for this mesh (0 by default)
  87671. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  87672. */
  87673. renderingGroupId: number;
  87674. private _material;
  87675. /** Gets or sets current material */
  87676. material: Nullable<Material>;
  87677. /**
  87678. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  87679. * @see http://doc.babylonjs.com/babylon101/shadows
  87680. */
  87681. receiveShadows: boolean;
  87682. /** Defines color to use when rendering outline */
  87683. outlineColor: Color3;
  87684. /** Define width to use when rendering outline */
  87685. outlineWidth: number;
  87686. /** Defines color to use when rendering overlay */
  87687. overlayColor: Color3;
  87688. /** Defines alpha to use when rendering overlay */
  87689. overlayAlpha: number;
  87690. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  87691. hasVertexAlpha: boolean;
  87692. /** 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) */
  87693. useVertexColors: boolean;
  87694. /**
  87695. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  87696. */
  87697. computeBonesUsingShaders: boolean;
  87698. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  87699. numBoneInfluencers: number;
  87700. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  87701. applyFog: boolean;
  87702. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  87703. useOctreeForRenderingSelection: boolean;
  87704. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  87705. useOctreeForPicking: boolean;
  87706. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  87707. useOctreeForCollisions: boolean;
  87708. /**
  87709. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  87710. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  87711. */
  87712. layerMask: number;
  87713. /**
  87714. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  87715. */
  87716. alwaysSelectAsActiveMesh: boolean;
  87717. /**
  87718. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  87719. */
  87720. doNotSyncBoundingInfo: boolean;
  87721. /**
  87722. * Gets or sets the current action manager
  87723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87724. */
  87725. actionManager: Nullable<AbstractActionManager>;
  87726. private _meshCollisionData;
  87727. /**
  87728. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  87729. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87730. */
  87731. ellipsoid: Vector3;
  87732. /**
  87733. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  87734. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87735. */
  87736. ellipsoidOffset: Vector3;
  87737. /**
  87738. * Gets or sets a collision mask used to mask collisions (default is -1).
  87739. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  87740. */
  87741. collisionMask: number;
  87742. /**
  87743. * Gets or sets the current collision group mask (-1 by default).
  87744. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  87745. */
  87746. collisionGroup: number;
  87747. /**
  87748. * Defines edge width used when edgesRenderer is enabled
  87749. * @see https://www.babylonjs-playground.com/#10OJSG#13
  87750. */
  87751. edgesWidth: number;
  87752. /**
  87753. * Defines edge color used when edgesRenderer is enabled
  87754. * @see https://www.babylonjs-playground.com/#10OJSG#13
  87755. */
  87756. edgesColor: Color4;
  87757. /** @hidden */
  87758. _edgesRenderer: Nullable<IEdgesRenderer>;
  87759. /** @hidden */
  87760. _masterMesh: Nullable<AbstractMesh>;
  87761. /** @hidden */
  87762. _boundingInfo: Nullable<BoundingInfo>;
  87763. /** @hidden */
  87764. _renderId: number;
  87765. /**
  87766. * Gets or sets the list of subMeshes
  87767. * @see http://doc.babylonjs.com/how_to/multi_materials
  87768. */
  87769. subMeshes: SubMesh[];
  87770. /** @hidden */
  87771. _intersectionsInProgress: AbstractMesh[];
  87772. /** @hidden */
  87773. _unIndexed: boolean;
  87774. /** @hidden */
  87775. _lightSources: Light[];
  87776. /** Gets the list of lights affecting that mesh */
  87777. readonly lightSources: Light[];
  87778. /** @hidden */
  87779. readonly _positions: Nullable<Vector3[]>;
  87780. /** @hidden */
  87781. _waitingData: {
  87782. lods: Nullable<any>;
  87783. actions: Nullable<any>;
  87784. freezeWorldMatrix: Nullable<boolean>;
  87785. };
  87786. /** @hidden */
  87787. _bonesTransformMatrices: Nullable<Float32Array>;
  87788. /** @hidden */
  87789. _transformMatrixTexture: Nullable<RawTexture>;
  87790. /**
  87791. * Gets or sets a skeleton to apply skining transformations
  87792. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87793. */
  87794. skeleton: Nullable<Skeleton>;
  87795. /**
  87796. * An event triggered when the mesh is rebuilt.
  87797. */
  87798. onRebuildObservable: Observable<AbstractMesh>;
  87799. /**
  87800. * Creates a new AbstractMesh
  87801. * @param name defines the name of the mesh
  87802. * @param scene defines the hosting scene
  87803. */
  87804. constructor(name: string, scene?: Nullable<Scene>);
  87805. /**
  87806. * Returns the string "AbstractMesh"
  87807. * @returns "AbstractMesh"
  87808. */
  87809. getClassName(): string;
  87810. /**
  87811. * Gets a string representation of the current mesh
  87812. * @param fullDetails defines a boolean indicating if full details must be included
  87813. * @returns a string representation of the current mesh
  87814. */
  87815. toString(fullDetails?: boolean): string;
  87816. /**
  87817. * @hidden
  87818. */
  87819. protected _getEffectiveParent(): Nullable<Node>;
  87820. /** @hidden */
  87821. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  87822. /** @hidden */
  87823. _rebuild(): void;
  87824. /** @hidden */
  87825. _resyncLightSources(): void;
  87826. /** @hidden */
  87827. _resyncLighSource(light: Light): void;
  87828. /** @hidden */
  87829. _unBindEffect(): void;
  87830. /** @hidden */
  87831. _removeLightSource(light: Light): void;
  87832. private _markSubMeshesAsDirty;
  87833. /** @hidden */
  87834. _markSubMeshesAsLightDirty(): void;
  87835. /** @hidden */
  87836. _markSubMeshesAsAttributesDirty(): void;
  87837. /** @hidden */
  87838. _markSubMeshesAsMiscDirty(): void;
  87839. /**
  87840. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  87841. */
  87842. scaling: Vector3;
  87843. /**
  87844. * Returns true if the mesh is blocked. Implemented by child classes
  87845. */
  87846. readonly isBlocked: boolean;
  87847. /**
  87848. * Returns the mesh itself by default. Implemented by child classes
  87849. * @param camera defines the camera to use to pick the right LOD level
  87850. * @returns the currentAbstractMesh
  87851. */
  87852. getLOD(camera: Camera): Nullable<AbstractMesh>;
  87853. /**
  87854. * Returns 0 by default. Implemented by child classes
  87855. * @returns an integer
  87856. */
  87857. getTotalVertices(): number;
  87858. /**
  87859. * Returns a positive integer : the total number of indices in this mesh geometry.
  87860. * @returns the numner of indices or zero if the mesh has no geometry.
  87861. */
  87862. getTotalIndices(): number;
  87863. /**
  87864. * Returns null by default. Implemented by child classes
  87865. * @returns null
  87866. */
  87867. getIndices(): Nullable<IndicesArray>;
  87868. /**
  87869. * Returns the array of the requested vertex data kind. Implemented by child classes
  87870. * @param kind defines the vertex data kind to use
  87871. * @returns null
  87872. */
  87873. getVerticesData(kind: string): Nullable<FloatArray>;
  87874. /**
  87875. * Sets the vertex data of the mesh geometry for the requested `kind`.
  87876. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  87877. * Note that a new underlying VertexBuffer object is created each call.
  87878. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  87879. * @param kind defines vertex data kind:
  87880. * * VertexBuffer.PositionKind
  87881. * * VertexBuffer.UVKind
  87882. * * VertexBuffer.UV2Kind
  87883. * * VertexBuffer.UV3Kind
  87884. * * VertexBuffer.UV4Kind
  87885. * * VertexBuffer.UV5Kind
  87886. * * VertexBuffer.UV6Kind
  87887. * * VertexBuffer.ColorKind
  87888. * * VertexBuffer.MatricesIndicesKind
  87889. * * VertexBuffer.MatricesIndicesExtraKind
  87890. * * VertexBuffer.MatricesWeightsKind
  87891. * * VertexBuffer.MatricesWeightsExtraKind
  87892. * @param data defines the data source
  87893. * @param updatable defines if the data must be flagged as updatable (or static)
  87894. * @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
  87895. * @returns the current mesh
  87896. */
  87897. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  87898. /**
  87899. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  87900. * If the mesh has no geometry, it is simply returned as it is.
  87901. * @param kind defines vertex data kind:
  87902. * * VertexBuffer.PositionKind
  87903. * * VertexBuffer.UVKind
  87904. * * VertexBuffer.UV2Kind
  87905. * * VertexBuffer.UV3Kind
  87906. * * VertexBuffer.UV4Kind
  87907. * * VertexBuffer.UV5Kind
  87908. * * VertexBuffer.UV6Kind
  87909. * * VertexBuffer.ColorKind
  87910. * * VertexBuffer.MatricesIndicesKind
  87911. * * VertexBuffer.MatricesIndicesExtraKind
  87912. * * VertexBuffer.MatricesWeightsKind
  87913. * * VertexBuffer.MatricesWeightsExtraKind
  87914. * @param data defines the data source
  87915. * @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
  87916. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  87917. * @returns the current mesh
  87918. */
  87919. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  87920. /**
  87921. * Sets the mesh indices,
  87922. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  87923. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  87924. * @param totalVertices Defines the total number of vertices
  87925. * @returns the current mesh
  87926. */
  87927. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  87928. /**
  87929. * Gets a boolean indicating if specific vertex data is present
  87930. * @param kind defines the vertex data kind to use
  87931. * @returns true is data kind is present
  87932. */
  87933. isVerticesDataPresent(kind: string): boolean;
  87934. /**
  87935. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  87936. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  87937. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  87938. * @returns a BoundingInfo
  87939. */
  87940. getBoundingInfo(): BoundingInfo;
  87941. /**
  87942. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87943. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87944. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87945. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87946. * @returns the current mesh
  87947. */
  87948. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  87949. /**
  87950. * Overwrite the current bounding info
  87951. * @param boundingInfo defines the new bounding info
  87952. * @returns the current mesh
  87953. */
  87954. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  87955. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  87956. readonly useBones: boolean;
  87957. /** @hidden */
  87958. _preActivate(): void;
  87959. /** @hidden */
  87960. _preActivateForIntermediateRendering(renderId: number): void;
  87961. /** @hidden */
  87962. _activate(renderId: number, intermediateRendering: boolean): boolean;
  87963. /** @hidden */
  87964. _postActivate(): void;
  87965. /** @hidden */
  87966. _freeze(): void;
  87967. /** @hidden */
  87968. _unFreeze(): void;
  87969. /**
  87970. * Gets the current world matrix
  87971. * @returns a Matrix
  87972. */
  87973. getWorldMatrix(): Matrix;
  87974. /** @hidden */
  87975. _getWorldMatrixDeterminant(): number;
  87976. /**
  87977. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  87978. */
  87979. readonly isAnInstance: boolean;
  87980. /**
  87981. * Perform relative position change from the point of view of behind the front of the mesh.
  87982. * This is performed taking into account the meshes current rotation, so you do not have to care.
  87983. * Supports definition of mesh facing forward or backward
  87984. * @param amountRight defines the distance on the right axis
  87985. * @param amountUp defines the distance on the up axis
  87986. * @param amountForward defines the distance on the forward axis
  87987. * @returns the current mesh
  87988. */
  87989. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  87990. /**
  87991. * Calculate relative position change from the point of view of behind the front of the mesh.
  87992. * This is performed taking into account the meshes current rotation, so you do not have to care.
  87993. * Supports definition of mesh facing forward or backward
  87994. * @param amountRight defines the distance on the right axis
  87995. * @param amountUp defines the distance on the up axis
  87996. * @param amountForward defines the distance on the forward axis
  87997. * @returns the new displacement vector
  87998. */
  87999. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  88000. /**
  88001. * Perform relative rotation change from the point of view of behind the front of the mesh.
  88002. * Supports definition of mesh facing forward or backward
  88003. * @param flipBack defines the flip
  88004. * @param twirlClockwise defines the twirl
  88005. * @param tiltRight defines the tilt
  88006. * @returns the current mesh
  88007. */
  88008. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  88009. /**
  88010. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  88011. * Supports definition of mesh facing forward or backward.
  88012. * @param flipBack defines the flip
  88013. * @param twirlClockwise defines the twirl
  88014. * @param tiltRight defines the tilt
  88015. * @returns the new rotation vector
  88016. */
  88017. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  88018. /**
  88019. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88020. * This means the mesh underlying bounding box and sphere are recomputed.
  88021. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88022. * @returns the current mesh
  88023. */
  88024. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  88025. /** @hidden */
  88026. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  88027. /** @hidden */
  88028. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  88029. /** @hidden */
  88030. _updateBoundingInfo(): AbstractMesh;
  88031. /** @hidden */
  88032. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  88033. /** @hidden */
  88034. protected _afterComputeWorldMatrix(): void;
  88035. /** @hidden */
  88036. readonly _effectiveMesh: AbstractMesh;
  88037. /**
  88038. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  88039. * A mesh is in the frustum if its bounding box intersects the frustum
  88040. * @param frustumPlanes defines the frustum to test
  88041. * @returns true if the mesh is in the frustum planes
  88042. */
  88043. isInFrustum(frustumPlanes: Plane[]): boolean;
  88044. /**
  88045. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  88046. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  88047. * @param frustumPlanes defines the frustum to test
  88048. * @returns true if the mesh is completely in the frustum planes
  88049. */
  88050. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  88051. /**
  88052. * True if the mesh intersects another mesh or a SolidParticle object
  88053. * @param mesh defines a target mesh or SolidParticle to test
  88054. * @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)
  88055. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  88056. * @returns true if there is an intersection
  88057. */
  88058. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  88059. /**
  88060. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  88061. * @param point defines the point to test
  88062. * @returns true if there is an intersection
  88063. */
  88064. intersectsPoint(point: Vector3): boolean;
  88065. /**
  88066. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  88067. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  88068. */
  88069. checkCollisions: boolean;
  88070. /**
  88071. * Gets Collider object used to compute collisions (not physics)
  88072. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  88073. */
  88074. readonly collider: Nullable<Collider>;
  88075. /**
  88076. * Move the mesh using collision engine
  88077. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  88078. * @param displacement defines the requested displacement vector
  88079. * @returns the current mesh
  88080. */
  88081. moveWithCollisions(displacement: Vector3): AbstractMesh;
  88082. private _onCollisionPositionChange;
  88083. /** @hidden */
  88084. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  88085. /** @hidden */
  88086. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  88087. /** @hidden */
  88088. _checkCollision(collider: Collider): AbstractMesh;
  88089. /** @hidden */
  88090. _generatePointsArray(): boolean;
  88091. /**
  88092. * Checks if the passed Ray intersects with the mesh
  88093. * @param ray defines the ray to use
  88094. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  88095. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  88096. * @returns the picking info
  88097. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  88098. */
  88099. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  88100. /**
  88101. * Clones the current mesh
  88102. * @param name defines the mesh name
  88103. * @param newParent defines the new mesh parent
  88104. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  88105. * @returns the new mesh
  88106. */
  88107. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  88108. /**
  88109. * Disposes all the submeshes of the current meshnp
  88110. * @returns the current mesh
  88111. */
  88112. releaseSubMeshes(): AbstractMesh;
  88113. /**
  88114. * Releases resources associated with this abstract mesh.
  88115. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88116. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88117. */
  88118. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88119. /**
  88120. * Adds the passed mesh as a child to the current mesh
  88121. * @param mesh defines the child mesh
  88122. * @returns the current mesh
  88123. */
  88124. addChild(mesh: AbstractMesh): AbstractMesh;
  88125. /**
  88126. * Removes the passed mesh from the current mesh children list
  88127. * @param mesh defines the child mesh
  88128. * @returns the current mesh
  88129. */
  88130. removeChild(mesh: AbstractMesh): AbstractMesh;
  88131. /** @hidden */
  88132. private _initFacetData;
  88133. /**
  88134. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  88135. * This method can be called within the render loop.
  88136. * 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
  88137. * @returns the current mesh
  88138. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88139. */
  88140. updateFacetData(): AbstractMesh;
  88141. /**
  88142. * Returns the facetLocalNormals array.
  88143. * The normals are expressed in the mesh local spac
  88144. * @returns an array of Vector3
  88145. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88146. */
  88147. getFacetLocalNormals(): Vector3[];
  88148. /**
  88149. * Returns the facetLocalPositions array.
  88150. * The facet positions are expressed in the mesh local space
  88151. * @returns an array of Vector3
  88152. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88153. */
  88154. getFacetLocalPositions(): Vector3[];
  88155. /**
  88156. * Returns the facetLocalPartioning array
  88157. * @returns an array of array of numbers
  88158. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88159. */
  88160. getFacetLocalPartitioning(): number[][];
  88161. /**
  88162. * Returns the i-th facet position in the world system.
  88163. * This method allocates a new Vector3 per call
  88164. * @param i defines the facet index
  88165. * @returns a new Vector3
  88166. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88167. */
  88168. getFacetPosition(i: number): Vector3;
  88169. /**
  88170. * Sets the reference Vector3 with the i-th facet position in the world system
  88171. * @param i defines the facet index
  88172. * @param ref defines the target vector
  88173. * @returns the current mesh
  88174. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88175. */
  88176. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  88177. /**
  88178. * Returns the i-th facet normal in the world system.
  88179. * This method allocates a new Vector3 per call
  88180. * @param i defines the facet index
  88181. * @returns a new Vector3
  88182. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88183. */
  88184. getFacetNormal(i: number): Vector3;
  88185. /**
  88186. * Sets the reference Vector3 with the i-th facet normal in the world system
  88187. * @param i defines the facet index
  88188. * @param ref defines the target vector
  88189. * @returns the current mesh
  88190. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88191. */
  88192. getFacetNormalToRef(i: number, ref: Vector3): this;
  88193. /**
  88194. * 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)
  88195. * @param x defines x coordinate
  88196. * @param y defines y coordinate
  88197. * @param z defines z coordinate
  88198. * @returns the array of facet indexes
  88199. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88200. */
  88201. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  88202. /**
  88203. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  88204. * @param projected sets as the (x,y,z) world projection on the facet
  88205. * @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
  88206. * @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
  88207. * @param x defines x coordinate
  88208. * @param y defines y coordinate
  88209. * @param z defines z coordinate
  88210. * @returns the face index if found (or null instead)
  88211. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88212. */
  88213. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  88214. /**
  88215. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  88216. * @param projected sets as the (x,y,z) local projection on the facet
  88217. * @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
  88218. * @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
  88219. * @param x defines x coordinate
  88220. * @param y defines y coordinate
  88221. * @param z defines z coordinate
  88222. * @returns the face index if found (or null instead)
  88223. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88224. */
  88225. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  88226. /**
  88227. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  88228. * @returns the parameters
  88229. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88230. */
  88231. getFacetDataParameters(): any;
  88232. /**
  88233. * Disables the feature FacetData and frees the related memory
  88234. * @returns the current mesh
  88235. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88236. */
  88237. disableFacetData(): AbstractMesh;
  88238. /**
  88239. * Updates the AbstractMesh indices array
  88240. * @param indices defines the data source
  88241. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  88242. * @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)
  88243. * @returns the current mesh
  88244. */
  88245. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  88246. /**
  88247. * Creates new normals data for the mesh
  88248. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  88249. * @returns the current mesh
  88250. */
  88251. createNormals(updatable: boolean): AbstractMesh;
  88252. /**
  88253. * Align the mesh with a normal
  88254. * @param normal defines the normal to use
  88255. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  88256. * @returns the current mesh
  88257. */
  88258. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  88259. /** @hidden */
  88260. _checkOcclusionQuery(): boolean;
  88261. /**
  88262. * Disables the mesh edge rendering mode
  88263. * @returns the currentAbstractMesh
  88264. */
  88265. disableEdgesRendering(): AbstractMesh;
  88266. /**
  88267. * Enables the edge rendering mode on the mesh.
  88268. * This mode makes the mesh edges visible
  88269. * @param epsilon defines the maximal distance between two angles to detect a face
  88270. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88271. * @returns the currentAbstractMesh
  88272. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88273. */
  88274. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  88275. }
  88276. }
  88277. declare module BABYLON {
  88278. /**
  88279. * Interface used to define ActionEvent
  88280. */
  88281. export interface IActionEvent {
  88282. /** The mesh or sprite that triggered the action */
  88283. source: any;
  88284. /** The X mouse cursor position at the time of the event */
  88285. pointerX: number;
  88286. /** The Y mouse cursor position at the time of the event */
  88287. pointerY: number;
  88288. /** The mesh that is currently pointed at (can be null) */
  88289. meshUnderPointer: Nullable<AbstractMesh>;
  88290. /** the original (browser) event that triggered the ActionEvent */
  88291. sourceEvent?: any;
  88292. /** additional data for the event */
  88293. additionalData?: any;
  88294. }
  88295. /**
  88296. * ActionEvent is the event being sent when an action is triggered.
  88297. */
  88298. export class ActionEvent implements IActionEvent {
  88299. /** The mesh or sprite that triggered the action */
  88300. source: any;
  88301. /** The X mouse cursor position at the time of the event */
  88302. pointerX: number;
  88303. /** The Y mouse cursor position at the time of the event */
  88304. pointerY: number;
  88305. /** The mesh that is currently pointed at (can be null) */
  88306. meshUnderPointer: Nullable<AbstractMesh>;
  88307. /** the original (browser) event that triggered the ActionEvent */
  88308. sourceEvent?: any;
  88309. /** additional data for the event */
  88310. additionalData?: any;
  88311. /**
  88312. * Creates a new ActionEvent
  88313. * @param source The mesh or sprite that triggered the action
  88314. * @param pointerX The X mouse cursor position at the time of the event
  88315. * @param pointerY The Y mouse cursor position at the time of the event
  88316. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  88317. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  88318. * @param additionalData additional data for the event
  88319. */
  88320. constructor(
  88321. /** The mesh or sprite that triggered the action */
  88322. source: any,
  88323. /** The X mouse cursor position at the time of the event */
  88324. pointerX: number,
  88325. /** The Y mouse cursor position at the time of the event */
  88326. pointerY: number,
  88327. /** The mesh that is currently pointed at (can be null) */
  88328. meshUnderPointer: Nullable<AbstractMesh>,
  88329. /** the original (browser) event that triggered the ActionEvent */
  88330. sourceEvent?: any,
  88331. /** additional data for the event */
  88332. additionalData?: any);
  88333. /**
  88334. * Helper function to auto-create an ActionEvent from a source mesh.
  88335. * @param source The source mesh that triggered the event
  88336. * @param evt The original (browser) event
  88337. * @param additionalData additional data for the event
  88338. * @returns the new ActionEvent
  88339. */
  88340. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  88341. /**
  88342. * Helper function to auto-create an ActionEvent from a source sprite
  88343. * @param source The source sprite that triggered the event
  88344. * @param scene Scene associated with the sprite
  88345. * @param evt The original (browser) event
  88346. * @param additionalData additional data for the event
  88347. * @returns the new ActionEvent
  88348. */
  88349. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  88350. /**
  88351. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  88352. * @param scene the scene where the event occurred
  88353. * @param evt The original (browser) event
  88354. * @returns the new ActionEvent
  88355. */
  88356. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  88357. /**
  88358. * Helper function to auto-create an ActionEvent from a primitive
  88359. * @param prim defines the target primitive
  88360. * @param pointerPos defines the pointer position
  88361. * @param evt The original (browser) event
  88362. * @param additionalData additional data for the event
  88363. * @returns the new ActionEvent
  88364. */
  88365. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  88366. }
  88367. }
  88368. declare module BABYLON {
  88369. /**
  88370. * Abstract class used to decouple action Manager from scene and meshes.
  88371. * Do not instantiate.
  88372. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  88373. */
  88374. export abstract class AbstractActionManager implements IDisposable {
  88375. /** Gets the list of active triggers */
  88376. static Triggers: {
  88377. [key: string]: number;
  88378. };
  88379. /** Gets the cursor to use when hovering items */
  88380. hoverCursor: string;
  88381. /** Gets the list of actions */
  88382. actions: IAction[];
  88383. /**
  88384. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  88385. */
  88386. isRecursive: boolean;
  88387. /**
  88388. * Releases all associated resources
  88389. */
  88390. abstract dispose(): void;
  88391. /**
  88392. * Does this action manager has pointer triggers
  88393. */
  88394. abstract readonly hasPointerTriggers: boolean;
  88395. /**
  88396. * Does this action manager has pick triggers
  88397. */
  88398. abstract readonly hasPickTriggers: boolean;
  88399. /**
  88400. * Process a specific trigger
  88401. * @param trigger defines the trigger to process
  88402. * @param evt defines the event details to be processed
  88403. */
  88404. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  88405. /**
  88406. * Does this action manager handles actions of any of the given triggers
  88407. * @param triggers defines the triggers to be tested
  88408. * @return a boolean indicating whether one (or more) of the triggers is handled
  88409. */
  88410. abstract hasSpecificTriggers(triggers: number[]): boolean;
  88411. /**
  88412. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  88413. * speed.
  88414. * @param triggerA defines the trigger to be tested
  88415. * @param triggerB defines the trigger to be tested
  88416. * @return a boolean indicating whether one (or more) of the triggers is handled
  88417. */
  88418. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  88419. /**
  88420. * Does this action manager handles actions of a given trigger
  88421. * @param trigger defines the trigger to be tested
  88422. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  88423. * @return whether the trigger is handled
  88424. */
  88425. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  88426. /**
  88427. * Serialize this manager to a JSON object
  88428. * @param name defines the property name to store this manager
  88429. * @returns a JSON representation of this manager
  88430. */
  88431. abstract serialize(name: string): any;
  88432. /**
  88433. * Registers an action to this action manager
  88434. * @param action defines the action to be registered
  88435. * @return the action amended (prepared) after registration
  88436. */
  88437. abstract registerAction(action: IAction): Nullable<IAction>;
  88438. /**
  88439. * Unregisters an action to this action manager
  88440. * @param action defines the action to be unregistered
  88441. * @return a boolean indicating whether the action has been unregistered
  88442. */
  88443. abstract unregisterAction(action: IAction): Boolean;
  88444. /**
  88445. * Does exist one action manager with at least one trigger
  88446. **/
  88447. static readonly HasTriggers: boolean;
  88448. /**
  88449. * Does exist one action manager with at least one pick trigger
  88450. **/
  88451. static readonly HasPickTriggers: boolean;
  88452. /**
  88453. * Does exist one action manager that handles actions of a given trigger
  88454. * @param trigger defines the trigger to be tested
  88455. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  88456. **/
  88457. static HasSpecificTrigger(trigger: number): boolean;
  88458. }
  88459. }
  88460. declare module BABYLON {
  88461. /**
  88462. * Defines how a node can be built from a string name.
  88463. */
  88464. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  88465. /**
  88466. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  88467. */
  88468. export class Node implements IBehaviorAware<Node> {
  88469. /** @hidden */
  88470. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  88471. private static _NodeConstructors;
  88472. /**
  88473. * Add a new node constructor
  88474. * @param type defines the type name of the node to construct
  88475. * @param constructorFunc defines the constructor function
  88476. */
  88477. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  88478. /**
  88479. * Returns a node constructor based on type name
  88480. * @param type defines the type name
  88481. * @param name defines the new node name
  88482. * @param scene defines the hosting scene
  88483. * @param options defines optional options to transmit to constructors
  88484. * @returns the new constructor or null
  88485. */
  88486. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  88487. /**
  88488. * Gets or sets the name of the node
  88489. */
  88490. name: string;
  88491. /**
  88492. * Gets or sets the id of the node
  88493. */
  88494. id: string;
  88495. /**
  88496. * Gets or sets the unique id of the node
  88497. */
  88498. uniqueId: number;
  88499. /**
  88500. * Gets or sets a string used to store user defined state for the node
  88501. */
  88502. state: string;
  88503. /**
  88504. * Gets or sets an object used to store user defined information for the node
  88505. */
  88506. metadata: any;
  88507. /**
  88508. * For internal use only. Please do not use.
  88509. */
  88510. reservedDataStore: any;
  88511. /**
  88512. * List of inspectable custom properties (used by the Inspector)
  88513. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88514. */
  88515. inspectableCustomProperties: IInspectable[];
  88516. /**
  88517. * Gets or sets a boolean used to define if the node must be serialized
  88518. */
  88519. doNotSerialize: boolean;
  88520. /** @hidden */
  88521. _isDisposed: boolean;
  88522. /**
  88523. * Gets a list of Animations associated with the node
  88524. */
  88525. animations: Animation[];
  88526. protected _ranges: {
  88527. [name: string]: Nullable<AnimationRange>;
  88528. };
  88529. /**
  88530. * Callback raised when the node is ready to be used
  88531. */
  88532. onReady: Nullable<(node: Node) => void>;
  88533. private _isEnabled;
  88534. private _isParentEnabled;
  88535. private _isReady;
  88536. /** @hidden */
  88537. _currentRenderId: number;
  88538. private _parentUpdateId;
  88539. /** @hidden */
  88540. _childUpdateId: number;
  88541. /** @hidden */
  88542. _waitingParentId: Nullable<string>;
  88543. /** @hidden */
  88544. _scene: Scene;
  88545. /** @hidden */
  88546. _cache: any;
  88547. private _parentNode;
  88548. private _children;
  88549. /** @hidden */
  88550. _worldMatrix: Matrix;
  88551. /** @hidden */
  88552. _worldMatrixDeterminant: number;
  88553. /** @hidden */
  88554. _worldMatrixDeterminantIsDirty: boolean;
  88555. /** @hidden */
  88556. private _sceneRootNodesIndex;
  88557. /**
  88558. * Gets a boolean indicating if the node has been disposed
  88559. * @returns true if the node was disposed
  88560. */
  88561. isDisposed(): boolean;
  88562. /**
  88563. * Gets or sets the parent of the node (without keeping the current position in the scene)
  88564. * @see https://doc.babylonjs.com/how_to/parenting
  88565. */
  88566. parent: Nullable<Node>;
  88567. private addToSceneRootNodes;
  88568. private removeFromSceneRootNodes;
  88569. private _animationPropertiesOverride;
  88570. /**
  88571. * Gets or sets the animation properties override
  88572. */
  88573. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88574. /**
  88575. * Gets a string idenfifying the name of the class
  88576. * @returns "Node" string
  88577. */
  88578. getClassName(): string;
  88579. /** @hidden */
  88580. readonly _isNode: boolean;
  88581. /**
  88582. * An event triggered when the mesh is disposed
  88583. */
  88584. onDisposeObservable: Observable<Node>;
  88585. private _onDisposeObserver;
  88586. /**
  88587. * Sets a callback that will be raised when the node will be disposed
  88588. */
  88589. onDispose: () => void;
  88590. /**
  88591. * Creates a new Node
  88592. * @param name the name and id to be given to this node
  88593. * @param scene the scene this node will be added to
  88594. * @param addToRootNodes the node will be added to scene.rootNodes
  88595. */
  88596. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  88597. /**
  88598. * Gets the scene of the node
  88599. * @returns a scene
  88600. */
  88601. getScene(): Scene;
  88602. /**
  88603. * Gets the engine of the node
  88604. * @returns a Engine
  88605. */
  88606. getEngine(): Engine;
  88607. private _behaviors;
  88608. /**
  88609. * Attach a behavior to the node
  88610. * @see http://doc.babylonjs.com/features/behaviour
  88611. * @param behavior defines the behavior to attach
  88612. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  88613. * @returns the current Node
  88614. */
  88615. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  88616. /**
  88617. * Remove an attached behavior
  88618. * @see http://doc.babylonjs.com/features/behaviour
  88619. * @param behavior defines the behavior to attach
  88620. * @returns the current Node
  88621. */
  88622. removeBehavior(behavior: Behavior<Node>): Node;
  88623. /**
  88624. * Gets the list of attached behaviors
  88625. * @see http://doc.babylonjs.com/features/behaviour
  88626. */
  88627. readonly behaviors: Behavior<Node>[];
  88628. /**
  88629. * Gets an attached behavior by name
  88630. * @param name defines the name of the behavior to look for
  88631. * @see http://doc.babylonjs.com/features/behaviour
  88632. * @returns null if behavior was not found else the requested behavior
  88633. */
  88634. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  88635. /**
  88636. * Returns the latest update of the World matrix
  88637. * @returns a Matrix
  88638. */
  88639. getWorldMatrix(): Matrix;
  88640. /** @hidden */
  88641. _getWorldMatrixDeterminant(): number;
  88642. /**
  88643. * Returns directly the latest state of the mesh World matrix.
  88644. * A Matrix is returned.
  88645. */
  88646. readonly worldMatrixFromCache: Matrix;
  88647. /** @hidden */
  88648. _initCache(): void;
  88649. /** @hidden */
  88650. updateCache(force?: boolean): void;
  88651. /** @hidden */
  88652. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  88653. /** @hidden */
  88654. _updateCache(ignoreParentClass?: boolean): void;
  88655. /** @hidden */
  88656. _isSynchronized(): boolean;
  88657. /** @hidden */
  88658. _markSyncedWithParent(): void;
  88659. /** @hidden */
  88660. isSynchronizedWithParent(): boolean;
  88661. /** @hidden */
  88662. isSynchronized(): boolean;
  88663. /**
  88664. * Is this node ready to be used/rendered
  88665. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88666. * @return true if the node is ready
  88667. */
  88668. isReady(completeCheck?: boolean): boolean;
  88669. /**
  88670. * Is this node enabled?
  88671. * 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
  88672. * @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
  88673. * @return whether this node (and its parent) is enabled
  88674. */
  88675. isEnabled(checkAncestors?: boolean): boolean;
  88676. /** @hidden */
  88677. protected _syncParentEnabledState(): void;
  88678. /**
  88679. * Set the enabled state of this node
  88680. * @param value defines the new enabled state
  88681. */
  88682. setEnabled(value: boolean): void;
  88683. /**
  88684. * Is this node a descendant of the given node?
  88685. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  88686. * @param ancestor defines the parent node to inspect
  88687. * @returns a boolean indicating if this node is a descendant of the given node
  88688. */
  88689. isDescendantOf(ancestor: Node): boolean;
  88690. /** @hidden */
  88691. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  88692. /**
  88693. * Will return all nodes that have this node as ascendant
  88694. * @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
  88695. * @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
  88696. * @return all children nodes of all types
  88697. */
  88698. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  88699. /**
  88700. * Get all child-meshes of this node
  88701. * @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)
  88702. * @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
  88703. * @returns an array of AbstractMesh
  88704. */
  88705. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  88706. /**
  88707. * Get all direct children of this node
  88708. * @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
  88709. * @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)
  88710. * @returns an array of Node
  88711. */
  88712. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  88713. /** @hidden */
  88714. _setReady(state: boolean): void;
  88715. /**
  88716. * Get an animation by name
  88717. * @param name defines the name of the animation to look for
  88718. * @returns null if not found else the requested animation
  88719. */
  88720. getAnimationByName(name: string): Nullable<Animation>;
  88721. /**
  88722. * Creates an animation range for this node
  88723. * @param name defines the name of the range
  88724. * @param from defines the starting key
  88725. * @param to defines the end key
  88726. */
  88727. createAnimationRange(name: string, from: number, to: number): void;
  88728. /**
  88729. * Delete a specific animation range
  88730. * @param name defines the name of the range to delete
  88731. * @param deleteFrames defines if animation frames from the range must be deleted as well
  88732. */
  88733. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  88734. /**
  88735. * Get an animation range by name
  88736. * @param name defines the name of the animation range to look for
  88737. * @returns null if not found else the requested animation range
  88738. */
  88739. getAnimationRange(name: string): Nullable<AnimationRange>;
  88740. /**
  88741. * Gets the list of all animation ranges defined on this node
  88742. * @returns an array
  88743. */
  88744. getAnimationRanges(): Nullable<AnimationRange>[];
  88745. /**
  88746. * Will start the animation sequence
  88747. * @param name defines the range frames for animation sequence
  88748. * @param loop defines if the animation should loop (false by default)
  88749. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  88750. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  88751. * @returns the object created for this animation. If range does not exist, it will return null
  88752. */
  88753. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  88754. /**
  88755. * Serialize animation ranges into a JSON compatible object
  88756. * @returns serialization object
  88757. */
  88758. serializeAnimationRanges(): any;
  88759. /**
  88760. * Computes the world matrix of the node
  88761. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  88762. * @returns the world matrix
  88763. */
  88764. computeWorldMatrix(force?: boolean): Matrix;
  88765. /**
  88766. * Releases resources associated with this node.
  88767. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88768. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88769. */
  88770. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88771. /**
  88772. * Parse animation range data from a serialization object and store them into a given node
  88773. * @param node defines where to store the animation ranges
  88774. * @param parsedNode defines the serialization object to read data from
  88775. * @param scene defines the hosting scene
  88776. */
  88777. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  88778. /**
  88779. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  88780. * @param includeDescendants Include bounding info from descendants as well (true by default)
  88781. * @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
  88782. * @returns the new bounding vectors
  88783. */
  88784. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  88785. min: Vector3;
  88786. max: Vector3;
  88787. };
  88788. }
  88789. }
  88790. declare module BABYLON {
  88791. /**
  88792. * @hidden
  88793. */
  88794. export class _IAnimationState {
  88795. key: number;
  88796. repeatCount: number;
  88797. workValue?: any;
  88798. loopMode?: number;
  88799. offsetValue?: any;
  88800. highLimitValue?: any;
  88801. }
  88802. /**
  88803. * Class used to store any kind of animation
  88804. */
  88805. export class Animation {
  88806. /**Name of the animation */
  88807. name: string;
  88808. /**Property to animate */
  88809. targetProperty: string;
  88810. /**The frames per second of the animation */
  88811. framePerSecond: number;
  88812. /**The data type of the animation */
  88813. dataType: number;
  88814. /**The loop mode of the animation */
  88815. loopMode?: number | undefined;
  88816. /**Specifies if blending should be enabled */
  88817. enableBlending?: boolean | undefined;
  88818. /**
  88819. * Use matrix interpolation instead of using direct key value when animating matrices
  88820. */
  88821. static AllowMatricesInterpolation: boolean;
  88822. /**
  88823. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  88824. */
  88825. static AllowMatrixDecomposeForInterpolation: boolean;
  88826. /**
  88827. * Stores the key frames of the animation
  88828. */
  88829. private _keys;
  88830. /**
  88831. * Stores the easing function of the animation
  88832. */
  88833. private _easingFunction;
  88834. /**
  88835. * @hidden Internal use only
  88836. */
  88837. _runtimeAnimations: RuntimeAnimation[];
  88838. /**
  88839. * The set of event that will be linked to this animation
  88840. */
  88841. private _events;
  88842. /**
  88843. * Stores an array of target property paths
  88844. */
  88845. targetPropertyPath: string[];
  88846. /**
  88847. * Stores the blending speed of the animation
  88848. */
  88849. blendingSpeed: number;
  88850. /**
  88851. * Stores the animation ranges for the animation
  88852. */
  88853. private _ranges;
  88854. /**
  88855. * @hidden Internal use
  88856. */
  88857. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  88858. /**
  88859. * Sets up an animation
  88860. * @param property The property to animate
  88861. * @param animationType The animation type to apply
  88862. * @param framePerSecond The frames per second of the animation
  88863. * @param easingFunction The easing function used in the animation
  88864. * @returns The created animation
  88865. */
  88866. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  88867. /**
  88868. * Create and start an animation on a node
  88869. * @param name defines the name of the global animation that will be run on all nodes
  88870. * @param node defines the root node where the animation will take place
  88871. * @param targetProperty defines property to animate
  88872. * @param framePerSecond defines the number of frame per second yo use
  88873. * @param totalFrame defines the number of frames in total
  88874. * @param from defines the initial value
  88875. * @param to defines the final value
  88876. * @param loopMode defines which loop mode you want to use (off by default)
  88877. * @param easingFunction defines the easing function to use (linear by default)
  88878. * @param onAnimationEnd defines the callback to call when animation end
  88879. * @returns the animatable created for this animation
  88880. */
  88881. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  88882. /**
  88883. * Create and start an animation on a node and its descendants
  88884. * @param name defines the name of the global animation that will be run on all nodes
  88885. * @param node defines the root node where the animation will take place
  88886. * @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
  88887. * @param targetProperty defines property to animate
  88888. * @param framePerSecond defines the number of frame per second to use
  88889. * @param totalFrame defines the number of frames in total
  88890. * @param from defines the initial value
  88891. * @param to defines the final value
  88892. * @param loopMode defines which loop mode you want to use (off by default)
  88893. * @param easingFunction defines the easing function to use (linear by default)
  88894. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88895. * @returns the list of animatables created for all nodes
  88896. * @example https://www.babylonjs-playground.com/#MH0VLI
  88897. */
  88898. 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[]>;
  88899. /**
  88900. * Creates a new animation, merges it with the existing animations and starts it
  88901. * @param name Name of the animation
  88902. * @param node Node which contains the scene that begins the animations
  88903. * @param targetProperty Specifies which property to animate
  88904. * @param framePerSecond The frames per second of the animation
  88905. * @param totalFrame The total number of frames
  88906. * @param from The frame at the beginning of the animation
  88907. * @param to The frame at the end of the animation
  88908. * @param loopMode Specifies the loop mode of the animation
  88909. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  88910. * @param onAnimationEnd Callback to run once the animation is complete
  88911. * @returns Nullable animation
  88912. */
  88913. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  88914. /**
  88915. * Transition property of an host to the target Value
  88916. * @param property The property to transition
  88917. * @param targetValue The target Value of the property
  88918. * @param host The object where the property to animate belongs
  88919. * @param scene Scene used to run the animation
  88920. * @param frameRate Framerate (in frame/s) to use
  88921. * @param transition The transition type we want to use
  88922. * @param duration The duration of the animation, in milliseconds
  88923. * @param onAnimationEnd Callback trigger at the end of the animation
  88924. * @returns Nullable animation
  88925. */
  88926. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  88927. /**
  88928. * Return the array of runtime animations currently using this animation
  88929. */
  88930. readonly runtimeAnimations: RuntimeAnimation[];
  88931. /**
  88932. * Specifies if any of the runtime animations are currently running
  88933. */
  88934. readonly hasRunningRuntimeAnimations: boolean;
  88935. /**
  88936. * Initializes the animation
  88937. * @param name Name of the animation
  88938. * @param targetProperty Property to animate
  88939. * @param framePerSecond The frames per second of the animation
  88940. * @param dataType The data type of the animation
  88941. * @param loopMode The loop mode of the animation
  88942. * @param enableBlending Specifies if blending should be enabled
  88943. */
  88944. constructor(
  88945. /**Name of the animation */
  88946. name: string,
  88947. /**Property to animate */
  88948. targetProperty: string,
  88949. /**The frames per second of the animation */
  88950. framePerSecond: number,
  88951. /**The data type of the animation */
  88952. dataType: number,
  88953. /**The loop mode of the animation */
  88954. loopMode?: number | undefined,
  88955. /**Specifies if blending should be enabled */
  88956. enableBlending?: boolean | undefined);
  88957. /**
  88958. * Converts the animation to a string
  88959. * @param fullDetails support for multiple levels of logging within scene loading
  88960. * @returns String form of the animation
  88961. */
  88962. toString(fullDetails?: boolean): string;
  88963. /**
  88964. * Add an event to this animation
  88965. * @param event Event to add
  88966. */
  88967. addEvent(event: AnimationEvent): void;
  88968. /**
  88969. * Remove all events found at the given frame
  88970. * @param frame The frame to remove events from
  88971. */
  88972. removeEvents(frame: number): void;
  88973. /**
  88974. * Retrieves all the events from the animation
  88975. * @returns Events from the animation
  88976. */
  88977. getEvents(): AnimationEvent[];
  88978. /**
  88979. * Creates an animation range
  88980. * @param name Name of the animation range
  88981. * @param from Starting frame of the animation range
  88982. * @param to Ending frame of the animation
  88983. */
  88984. createRange(name: string, from: number, to: number): void;
  88985. /**
  88986. * Deletes an animation range by name
  88987. * @param name Name of the animation range to delete
  88988. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  88989. */
  88990. deleteRange(name: string, deleteFrames?: boolean): void;
  88991. /**
  88992. * Gets the animation range by name, or null if not defined
  88993. * @param name Name of the animation range
  88994. * @returns Nullable animation range
  88995. */
  88996. getRange(name: string): Nullable<AnimationRange>;
  88997. /**
  88998. * Gets the key frames from the animation
  88999. * @returns The key frames of the animation
  89000. */
  89001. getKeys(): Array<IAnimationKey>;
  89002. /**
  89003. * Gets the highest frame rate of the animation
  89004. * @returns Highest frame rate of the animation
  89005. */
  89006. getHighestFrame(): number;
  89007. /**
  89008. * Gets the easing function of the animation
  89009. * @returns Easing function of the animation
  89010. */
  89011. getEasingFunction(): IEasingFunction;
  89012. /**
  89013. * Sets the easing function of the animation
  89014. * @param easingFunction A custom mathematical formula for animation
  89015. */
  89016. setEasingFunction(easingFunction: EasingFunction): void;
  89017. /**
  89018. * Interpolates a scalar linearly
  89019. * @param startValue Start value of the animation curve
  89020. * @param endValue End value of the animation curve
  89021. * @param gradient Scalar amount to interpolate
  89022. * @returns Interpolated scalar value
  89023. */
  89024. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  89025. /**
  89026. * Interpolates a scalar cubically
  89027. * @param startValue Start value of the animation curve
  89028. * @param outTangent End tangent of the animation
  89029. * @param endValue End value of the animation curve
  89030. * @param inTangent Start tangent of the animation curve
  89031. * @param gradient Scalar amount to interpolate
  89032. * @returns Interpolated scalar value
  89033. */
  89034. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  89035. /**
  89036. * Interpolates a quaternion using a spherical linear interpolation
  89037. * @param startValue Start value of the animation curve
  89038. * @param endValue End value of the animation curve
  89039. * @param gradient Scalar amount to interpolate
  89040. * @returns Interpolated quaternion value
  89041. */
  89042. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  89043. /**
  89044. * Interpolates a quaternion cubically
  89045. * @param startValue Start value of the animation curve
  89046. * @param outTangent End tangent of the animation curve
  89047. * @param endValue End value of the animation curve
  89048. * @param inTangent Start tangent of the animation curve
  89049. * @param gradient Scalar amount to interpolate
  89050. * @returns Interpolated quaternion value
  89051. */
  89052. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  89053. /**
  89054. * Interpolates a Vector3 linearl
  89055. * @param startValue Start value of the animation curve
  89056. * @param endValue End value of the animation curve
  89057. * @param gradient Scalar amount to interpolate
  89058. * @returns Interpolated scalar value
  89059. */
  89060. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  89061. /**
  89062. * Interpolates a Vector3 cubically
  89063. * @param startValue Start value of the animation curve
  89064. * @param outTangent End tangent of the animation
  89065. * @param endValue End value of the animation curve
  89066. * @param inTangent Start tangent of the animation curve
  89067. * @param gradient Scalar amount to interpolate
  89068. * @returns InterpolatedVector3 value
  89069. */
  89070. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  89071. /**
  89072. * Interpolates a Vector2 linearly
  89073. * @param startValue Start value of the animation curve
  89074. * @param endValue End value of the animation curve
  89075. * @param gradient Scalar amount to interpolate
  89076. * @returns Interpolated Vector2 value
  89077. */
  89078. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  89079. /**
  89080. * Interpolates a Vector2 cubically
  89081. * @param startValue Start value of the animation curve
  89082. * @param outTangent End tangent of the animation
  89083. * @param endValue End value of the animation curve
  89084. * @param inTangent Start tangent of the animation curve
  89085. * @param gradient Scalar amount to interpolate
  89086. * @returns Interpolated Vector2 value
  89087. */
  89088. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  89089. /**
  89090. * Interpolates a size linearly
  89091. * @param startValue Start value of the animation curve
  89092. * @param endValue End value of the animation curve
  89093. * @param gradient Scalar amount to interpolate
  89094. * @returns Interpolated Size value
  89095. */
  89096. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  89097. /**
  89098. * Interpolates a Color3 linearly
  89099. * @param startValue Start value of the animation curve
  89100. * @param endValue End value of the animation curve
  89101. * @param gradient Scalar amount to interpolate
  89102. * @returns Interpolated Color3 value
  89103. */
  89104. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  89105. /**
  89106. * @hidden Internal use only
  89107. */
  89108. _getKeyValue(value: any): any;
  89109. /**
  89110. * @hidden Internal use only
  89111. */
  89112. _interpolate(currentFrame: number, state: _IAnimationState): any;
  89113. /**
  89114. * Defines the function to use to interpolate matrices
  89115. * @param startValue defines the start matrix
  89116. * @param endValue defines the end matrix
  89117. * @param gradient defines the gradient between both matrices
  89118. * @param result defines an optional target matrix where to store the interpolation
  89119. * @returns the interpolated matrix
  89120. */
  89121. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  89122. /**
  89123. * Makes a copy of the animation
  89124. * @returns Cloned animation
  89125. */
  89126. clone(): Animation;
  89127. /**
  89128. * Sets the key frames of the animation
  89129. * @param values The animation key frames to set
  89130. */
  89131. setKeys(values: Array<IAnimationKey>): void;
  89132. /**
  89133. * Serializes the animation to an object
  89134. * @returns Serialized object
  89135. */
  89136. serialize(): any;
  89137. /**
  89138. * Float animation type
  89139. */
  89140. private static _ANIMATIONTYPE_FLOAT;
  89141. /**
  89142. * Vector3 animation type
  89143. */
  89144. private static _ANIMATIONTYPE_VECTOR3;
  89145. /**
  89146. * Quaternion animation type
  89147. */
  89148. private static _ANIMATIONTYPE_QUATERNION;
  89149. /**
  89150. * Matrix animation type
  89151. */
  89152. private static _ANIMATIONTYPE_MATRIX;
  89153. /**
  89154. * Color3 animation type
  89155. */
  89156. private static _ANIMATIONTYPE_COLOR3;
  89157. /**
  89158. * Vector2 animation type
  89159. */
  89160. private static _ANIMATIONTYPE_VECTOR2;
  89161. /**
  89162. * Size animation type
  89163. */
  89164. private static _ANIMATIONTYPE_SIZE;
  89165. /**
  89166. * Relative Loop Mode
  89167. */
  89168. private static _ANIMATIONLOOPMODE_RELATIVE;
  89169. /**
  89170. * Cycle Loop Mode
  89171. */
  89172. private static _ANIMATIONLOOPMODE_CYCLE;
  89173. /**
  89174. * Constant Loop Mode
  89175. */
  89176. private static _ANIMATIONLOOPMODE_CONSTANT;
  89177. /**
  89178. * Get the float animation type
  89179. */
  89180. static readonly ANIMATIONTYPE_FLOAT: number;
  89181. /**
  89182. * Get the Vector3 animation type
  89183. */
  89184. static readonly ANIMATIONTYPE_VECTOR3: number;
  89185. /**
  89186. * Get the Vector2 animation type
  89187. */
  89188. static readonly ANIMATIONTYPE_VECTOR2: number;
  89189. /**
  89190. * Get the Size animation type
  89191. */
  89192. static readonly ANIMATIONTYPE_SIZE: number;
  89193. /**
  89194. * Get the Quaternion animation type
  89195. */
  89196. static readonly ANIMATIONTYPE_QUATERNION: number;
  89197. /**
  89198. * Get the Matrix animation type
  89199. */
  89200. static readonly ANIMATIONTYPE_MATRIX: number;
  89201. /**
  89202. * Get the Color3 animation type
  89203. */
  89204. static readonly ANIMATIONTYPE_COLOR3: number;
  89205. /**
  89206. * Get the Relative Loop Mode
  89207. */
  89208. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  89209. /**
  89210. * Get the Cycle Loop Mode
  89211. */
  89212. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  89213. /**
  89214. * Get the Constant Loop Mode
  89215. */
  89216. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  89217. /** @hidden */
  89218. static _UniversalLerp(left: any, right: any, amount: number): any;
  89219. /**
  89220. * Parses an animation object and creates an animation
  89221. * @param parsedAnimation Parsed animation object
  89222. * @returns Animation object
  89223. */
  89224. static Parse(parsedAnimation: any): Animation;
  89225. /**
  89226. * Appends the serialized animations from the source animations
  89227. * @param source Source containing the animations
  89228. * @param destination Target to store the animations
  89229. */
  89230. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  89231. }
  89232. }
  89233. declare module BABYLON {
  89234. /**
  89235. * Base class of all the textures in babylon.
  89236. * It groups all the common properties the materials, post process, lights... might need
  89237. * in order to make a correct use of the texture.
  89238. */
  89239. export class BaseTexture implements IAnimatable {
  89240. /**
  89241. * Default anisotropic filtering level for the application.
  89242. * It is set to 4 as a good tradeoff between perf and quality.
  89243. */
  89244. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  89245. /**
  89246. * Gets or sets the unique id of the texture
  89247. */
  89248. uniqueId: number;
  89249. /**
  89250. * Define the name of the texture.
  89251. */
  89252. name: string;
  89253. /**
  89254. * Gets or sets an object used to store user defined information.
  89255. */
  89256. metadata: any;
  89257. /**
  89258. * For internal use only. Please do not use.
  89259. */
  89260. reservedDataStore: any;
  89261. private _hasAlpha;
  89262. /**
  89263. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  89264. */
  89265. hasAlpha: boolean;
  89266. /**
  89267. * Defines if the alpha value should be determined via the rgb values.
  89268. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  89269. */
  89270. getAlphaFromRGB: boolean;
  89271. /**
  89272. * Intensity or strength of the texture.
  89273. * It is commonly used by materials to fine tune the intensity of the texture
  89274. */
  89275. level: number;
  89276. /**
  89277. * Define the UV chanel to use starting from 0 and defaulting to 0.
  89278. * This is part of the texture as textures usually maps to one uv set.
  89279. */
  89280. coordinatesIndex: number;
  89281. private _coordinatesMode;
  89282. /**
  89283. * How a texture is mapped.
  89284. *
  89285. * | Value | Type | Description |
  89286. * | ----- | ----------------------------------- | ----------- |
  89287. * | 0 | EXPLICIT_MODE | |
  89288. * | 1 | SPHERICAL_MODE | |
  89289. * | 2 | PLANAR_MODE | |
  89290. * | 3 | CUBIC_MODE | |
  89291. * | 4 | PROJECTION_MODE | |
  89292. * | 5 | SKYBOX_MODE | |
  89293. * | 6 | INVCUBIC_MODE | |
  89294. * | 7 | EQUIRECTANGULAR_MODE | |
  89295. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  89296. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  89297. */
  89298. coordinatesMode: number;
  89299. /**
  89300. * | Value | Type | Description |
  89301. * | ----- | ------------------ | ----------- |
  89302. * | 0 | CLAMP_ADDRESSMODE | |
  89303. * | 1 | WRAP_ADDRESSMODE | |
  89304. * | 2 | MIRROR_ADDRESSMODE | |
  89305. */
  89306. wrapU: number;
  89307. /**
  89308. * | Value | Type | Description |
  89309. * | ----- | ------------------ | ----------- |
  89310. * | 0 | CLAMP_ADDRESSMODE | |
  89311. * | 1 | WRAP_ADDRESSMODE | |
  89312. * | 2 | MIRROR_ADDRESSMODE | |
  89313. */
  89314. wrapV: number;
  89315. /**
  89316. * | Value | Type | Description |
  89317. * | ----- | ------------------ | ----------- |
  89318. * | 0 | CLAMP_ADDRESSMODE | |
  89319. * | 1 | WRAP_ADDRESSMODE | |
  89320. * | 2 | MIRROR_ADDRESSMODE | |
  89321. */
  89322. wrapR: number;
  89323. /**
  89324. * With compliant hardware and browser (supporting anisotropic filtering)
  89325. * this defines the level of anisotropic filtering in the texture.
  89326. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  89327. */
  89328. anisotropicFilteringLevel: number;
  89329. /**
  89330. * Define if the texture is a cube texture or if false a 2d texture.
  89331. */
  89332. isCube: boolean;
  89333. /**
  89334. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  89335. */
  89336. is3D: boolean;
  89337. /**
  89338. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  89339. * HDR texture are usually stored in linear space.
  89340. * This only impacts the PBR and Background materials
  89341. */
  89342. gammaSpace: boolean;
  89343. /**
  89344. * Gets whether or not the texture contains RGBD data.
  89345. */
  89346. readonly isRGBD: boolean;
  89347. /**
  89348. * Is Z inverted in the texture (useful in a cube texture).
  89349. */
  89350. invertZ: boolean;
  89351. /**
  89352. * Are mip maps generated for this texture or not.
  89353. */
  89354. readonly noMipmap: boolean;
  89355. /**
  89356. * @hidden
  89357. */
  89358. lodLevelInAlpha: boolean;
  89359. /**
  89360. * With prefiltered texture, defined the offset used during the prefiltering steps.
  89361. */
  89362. lodGenerationOffset: number;
  89363. /**
  89364. * With prefiltered texture, defined the scale used during the prefiltering steps.
  89365. */
  89366. lodGenerationScale: number;
  89367. /**
  89368. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  89369. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  89370. * average roughness values.
  89371. */
  89372. linearSpecularLOD: boolean;
  89373. /**
  89374. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  89375. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  89376. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  89377. */
  89378. irradianceTexture: Nullable<BaseTexture>;
  89379. /**
  89380. * Define if the texture is a render target.
  89381. */
  89382. isRenderTarget: boolean;
  89383. /**
  89384. * Define the unique id of the texture in the scene.
  89385. */
  89386. readonly uid: string;
  89387. /**
  89388. * Return a string representation of the texture.
  89389. * @returns the texture as a string
  89390. */
  89391. toString(): string;
  89392. /**
  89393. * Get the class name of the texture.
  89394. * @returns "BaseTexture"
  89395. */
  89396. getClassName(): string;
  89397. /**
  89398. * Define the list of animation attached to the texture.
  89399. */
  89400. animations: Animation[];
  89401. /**
  89402. * An event triggered when the texture is disposed.
  89403. */
  89404. onDisposeObservable: Observable<BaseTexture>;
  89405. private _onDisposeObserver;
  89406. /**
  89407. * Callback triggered when the texture has been disposed.
  89408. * Kept for back compatibility, you can use the onDisposeObservable instead.
  89409. */
  89410. onDispose: () => void;
  89411. /**
  89412. * Define the current state of the loading sequence when in delayed load mode.
  89413. */
  89414. delayLoadState: number;
  89415. private _scene;
  89416. /** @hidden */
  89417. _texture: Nullable<InternalTexture>;
  89418. private _uid;
  89419. /**
  89420. * Define if the texture is preventinga material to render or not.
  89421. * If not and the texture is not ready, the engine will use a default black texture instead.
  89422. */
  89423. readonly isBlocking: boolean;
  89424. /**
  89425. * Instantiates a new BaseTexture.
  89426. * Base class of all the textures in babylon.
  89427. * It groups all the common properties the materials, post process, lights... might need
  89428. * in order to make a correct use of the texture.
  89429. * @param scene Define the scene the texture blongs to
  89430. */
  89431. constructor(scene: Nullable<Scene>);
  89432. /**
  89433. * Get the scene the texture belongs to.
  89434. * @returns the scene or null if undefined
  89435. */
  89436. getScene(): Nullable<Scene>;
  89437. /**
  89438. * Get the texture transform matrix used to offset tile the texture for istance.
  89439. * @returns the transformation matrix
  89440. */
  89441. getTextureMatrix(): Matrix;
  89442. /**
  89443. * Get the texture reflection matrix used to rotate/transform the reflection.
  89444. * @returns the reflection matrix
  89445. */
  89446. getReflectionTextureMatrix(): Matrix;
  89447. /**
  89448. * Get the underlying lower level texture from Babylon.
  89449. * @returns the insternal texture
  89450. */
  89451. getInternalTexture(): Nullable<InternalTexture>;
  89452. /**
  89453. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  89454. * @returns true if ready or not blocking
  89455. */
  89456. isReadyOrNotBlocking(): boolean;
  89457. /**
  89458. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  89459. * @returns true if fully ready
  89460. */
  89461. isReady(): boolean;
  89462. private _cachedSize;
  89463. /**
  89464. * Get the size of the texture.
  89465. * @returns the texture size.
  89466. */
  89467. getSize(): ISize;
  89468. /**
  89469. * Get the base size of the texture.
  89470. * It can be different from the size if the texture has been resized for POT for instance
  89471. * @returns the base size
  89472. */
  89473. getBaseSize(): ISize;
  89474. /**
  89475. * Update the sampling mode of the texture.
  89476. * Default is Trilinear mode.
  89477. *
  89478. * | Value | Type | Description |
  89479. * | ----- | ------------------ | ----------- |
  89480. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  89481. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  89482. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  89483. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  89484. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  89485. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  89486. * | 7 | NEAREST_LINEAR | |
  89487. * | 8 | NEAREST_NEAREST | |
  89488. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  89489. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  89490. * | 11 | LINEAR_LINEAR | |
  89491. * | 12 | LINEAR_NEAREST | |
  89492. *
  89493. * > _mag_: magnification filter (close to the viewer)
  89494. * > _min_: minification filter (far from the viewer)
  89495. * > _mip_: filter used between mip map levels
  89496. *@param samplingMode Define the new sampling mode of the texture
  89497. */
  89498. updateSamplingMode(samplingMode: number): void;
  89499. /**
  89500. * Scales the texture if is `canRescale()`
  89501. * @param ratio the resize factor we want to use to rescale
  89502. */
  89503. scale(ratio: number): void;
  89504. /**
  89505. * Get if the texture can rescale.
  89506. */
  89507. readonly canRescale: boolean;
  89508. /** @hidden */
  89509. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  89510. /** @hidden */
  89511. _rebuild(): void;
  89512. /**
  89513. * Triggers the load sequence in delayed load mode.
  89514. */
  89515. delayLoad(): void;
  89516. /**
  89517. * Clones the texture.
  89518. * @returns the cloned texture
  89519. */
  89520. clone(): Nullable<BaseTexture>;
  89521. /**
  89522. * Get the texture underlying type (INT, FLOAT...)
  89523. */
  89524. readonly textureType: number;
  89525. /**
  89526. * Get the texture underlying format (RGB, RGBA...)
  89527. */
  89528. readonly textureFormat: number;
  89529. /**
  89530. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  89531. * This will returns an RGBA array buffer containing either in values (0-255) or
  89532. * float values (0-1) depending of the underlying buffer type.
  89533. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  89534. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  89535. * @param buffer defines a user defined buffer to fill with data (can be null)
  89536. * @returns The Array buffer containing the pixels data.
  89537. */
  89538. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  89539. /**
  89540. * Release and destroy the underlying lower level texture aka internalTexture.
  89541. */
  89542. releaseInternalTexture(): void;
  89543. /**
  89544. * Get the polynomial representation of the texture data.
  89545. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  89546. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  89547. */
  89548. sphericalPolynomial: Nullable<SphericalPolynomial>;
  89549. /** @hidden */
  89550. readonly _lodTextureHigh: Nullable<BaseTexture>;
  89551. /** @hidden */
  89552. readonly _lodTextureMid: Nullable<BaseTexture>;
  89553. /** @hidden */
  89554. readonly _lodTextureLow: Nullable<BaseTexture>;
  89555. /**
  89556. * Dispose the texture and release its associated resources.
  89557. */
  89558. dispose(): void;
  89559. /**
  89560. * Serialize the texture into a JSON representation that can be parsed later on.
  89561. * @returns the JSON representation of the texture
  89562. */
  89563. serialize(): any;
  89564. /**
  89565. * Helper function to be called back once a list of texture contains only ready textures.
  89566. * @param textures Define the list of textures to wait for
  89567. * @param callback Define the callback triggered once the entire list will be ready
  89568. */
  89569. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  89570. }
  89571. }
  89572. declare module BABYLON {
  89573. /**
  89574. * Uniform buffer objects.
  89575. *
  89576. * Handles blocks of uniform on the GPU.
  89577. *
  89578. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89579. *
  89580. * For more information, please refer to :
  89581. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89582. */
  89583. export class UniformBuffer {
  89584. private _engine;
  89585. private _buffer;
  89586. private _data;
  89587. private _bufferData;
  89588. private _dynamic?;
  89589. private _uniformLocations;
  89590. private _uniformSizes;
  89591. private _uniformLocationPointer;
  89592. private _needSync;
  89593. private _noUBO;
  89594. private _currentEffect;
  89595. private static _MAX_UNIFORM_SIZE;
  89596. private static _tempBuffer;
  89597. /**
  89598. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  89599. * This is dynamic to allow compat with webgl 1 and 2.
  89600. * You will need to pass the name of the uniform as well as the value.
  89601. */
  89602. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  89603. /**
  89604. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  89605. * This is dynamic to allow compat with webgl 1 and 2.
  89606. * You will need to pass the name of the uniform as well as the value.
  89607. */
  89608. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  89609. /**
  89610. * Lambda to Update a single float in a uniform buffer.
  89611. * This is dynamic to allow compat with webgl 1 and 2.
  89612. * You will need to pass the name of the uniform as well as the value.
  89613. */
  89614. updateFloat: (name: string, x: number) => void;
  89615. /**
  89616. * Lambda to Update a vec2 of float in a uniform buffer.
  89617. * This is dynamic to allow compat with webgl 1 and 2.
  89618. * You will need to pass the name of the uniform as well as the value.
  89619. */
  89620. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  89621. /**
  89622. * Lambda to Update a vec3 of float in a uniform buffer.
  89623. * This is dynamic to allow compat with webgl 1 and 2.
  89624. * You will need to pass the name of the uniform as well as the value.
  89625. */
  89626. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  89627. /**
  89628. * Lambda to Update a vec4 of float in a uniform buffer.
  89629. * This is dynamic to allow compat with webgl 1 and 2.
  89630. * You will need to pass the name of the uniform as well as the value.
  89631. */
  89632. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  89633. /**
  89634. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  89635. * This is dynamic to allow compat with webgl 1 and 2.
  89636. * You will need to pass the name of the uniform as well as the value.
  89637. */
  89638. updateMatrix: (name: string, mat: Matrix) => void;
  89639. /**
  89640. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  89641. * This is dynamic to allow compat with webgl 1 and 2.
  89642. * You will need to pass the name of the uniform as well as the value.
  89643. */
  89644. updateVector3: (name: string, vector: Vector3) => void;
  89645. /**
  89646. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  89647. * This is dynamic to allow compat with webgl 1 and 2.
  89648. * You will need to pass the name of the uniform as well as the value.
  89649. */
  89650. updateVector4: (name: string, vector: Vector4) => void;
  89651. /**
  89652. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  89653. * This is dynamic to allow compat with webgl 1 and 2.
  89654. * You will need to pass the name of the uniform as well as the value.
  89655. */
  89656. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  89657. /**
  89658. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  89659. * This is dynamic to allow compat with webgl 1 and 2.
  89660. * You will need to pass the name of the uniform as well as the value.
  89661. */
  89662. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  89663. /**
  89664. * Instantiates a new Uniform buffer objects.
  89665. *
  89666. * Handles blocks of uniform on the GPU.
  89667. *
  89668. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89669. *
  89670. * For more information, please refer to :
  89671. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89672. * @param engine Define the engine the buffer is associated with
  89673. * @param data Define the data contained in the buffer
  89674. * @param dynamic Define if the buffer is updatable
  89675. */
  89676. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  89677. /**
  89678. * Indicates if the buffer is using the WebGL2 UBO implementation,
  89679. * or just falling back on setUniformXXX calls.
  89680. */
  89681. readonly useUbo: boolean;
  89682. /**
  89683. * Indicates if the WebGL underlying uniform buffer is in sync
  89684. * with the javascript cache data.
  89685. */
  89686. readonly isSync: boolean;
  89687. /**
  89688. * Indicates if the WebGL underlying uniform buffer is dynamic.
  89689. * Also, a dynamic UniformBuffer will disable cache verification and always
  89690. * update the underlying WebGL uniform buffer to the GPU.
  89691. * @returns if Dynamic, otherwise false
  89692. */
  89693. isDynamic(): boolean;
  89694. /**
  89695. * The data cache on JS side.
  89696. * @returns the underlying data as a float array
  89697. */
  89698. getData(): Float32Array;
  89699. /**
  89700. * The underlying WebGL Uniform buffer.
  89701. * @returns the webgl buffer
  89702. */
  89703. getBuffer(): Nullable<DataBuffer>;
  89704. /**
  89705. * std140 layout specifies how to align data within an UBO structure.
  89706. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  89707. * for specs.
  89708. */
  89709. private _fillAlignment;
  89710. /**
  89711. * Adds an uniform in the buffer.
  89712. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  89713. * for the layout to be correct !
  89714. * @param name Name of the uniform, as used in the uniform block in the shader.
  89715. * @param size Data size, or data directly.
  89716. */
  89717. addUniform(name: string, size: number | number[]): void;
  89718. /**
  89719. * Adds a Matrix 4x4 to the uniform buffer.
  89720. * @param name Name of the uniform, as used in the uniform block in the shader.
  89721. * @param mat A 4x4 matrix.
  89722. */
  89723. addMatrix(name: string, mat: Matrix): void;
  89724. /**
  89725. * Adds a vec2 to the uniform buffer.
  89726. * @param name Name of the uniform, as used in the uniform block in the shader.
  89727. * @param x Define the x component value of the vec2
  89728. * @param y Define the y component value of the vec2
  89729. */
  89730. addFloat2(name: string, x: number, y: number): void;
  89731. /**
  89732. * Adds a vec3 to the uniform buffer.
  89733. * @param name Name of the uniform, as used in the uniform block in the shader.
  89734. * @param x Define the x component value of the vec3
  89735. * @param y Define the y component value of the vec3
  89736. * @param z Define the z component value of the vec3
  89737. */
  89738. addFloat3(name: string, x: number, y: number, z: number): void;
  89739. /**
  89740. * Adds a vec3 to the uniform buffer.
  89741. * @param name Name of the uniform, as used in the uniform block in the shader.
  89742. * @param color Define the vec3 from a Color
  89743. */
  89744. addColor3(name: string, color: Color3): void;
  89745. /**
  89746. * Adds a vec4 to the uniform buffer.
  89747. * @param name Name of the uniform, as used in the uniform block in the shader.
  89748. * @param color Define the rgb components from a Color
  89749. * @param alpha Define the a component of the vec4
  89750. */
  89751. addColor4(name: string, color: Color3, alpha: number): void;
  89752. /**
  89753. * Adds a vec3 to the uniform buffer.
  89754. * @param name Name of the uniform, as used in the uniform block in the shader.
  89755. * @param vector Define the vec3 components from a Vector
  89756. */
  89757. addVector3(name: string, vector: Vector3): void;
  89758. /**
  89759. * Adds a Matrix 3x3 to the uniform buffer.
  89760. * @param name Name of the uniform, as used in the uniform block in the shader.
  89761. */
  89762. addMatrix3x3(name: string): void;
  89763. /**
  89764. * Adds a Matrix 2x2 to the uniform buffer.
  89765. * @param name Name of the uniform, as used in the uniform block in the shader.
  89766. */
  89767. addMatrix2x2(name: string): void;
  89768. /**
  89769. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  89770. */
  89771. create(): void;
  89772. /** @hidden */
  89773. _rebuild(): void;
  89774. /**
  89775. * Updates the WebGL Uniform Buffer on the GPU.
  89776. * If the `dynamic` flag is set to true, no cache comparison is done.
  89777. * Otherwise, the buffer will be updated only if the cache differs.
  89778. */
  89779. update(): void;
  89780. /**
  89781. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  89782. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89783. * @param data Define the flattened data
  89784. * @param size Define the size of the data.
  89785. */
  89786. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  89787. private _updateMatrix3x3ForUniform;
  89788. private _updateMatrix3x3ForEffect;
  89789. private _updateMatrix2x2ForEffect;
  89790. private _updateMatrix2x2ForUniform;
  89791. private _updateFloatForEffect;
  89792. private _updateFloatForUniform;
  89793. private _updateFloat2ForEffect;
  89794. private _updateFloat2ForUniform;
  89795. private _updateFloat3ForEffect;
  89796. private _updateFloat3ForUniform;
  89797. private _updateFloat4ForEffect;
  89798. private _updateFloat4ForUniform;
  89799. private _updateMatrixForEffect;
  89800. private _updateMatrixForUniform;
  89801. private _updateVector3ForEffect;
  89802. private _updateVector3ForUniform;
  89803. private _updateVector4ForEffect;
  89804. private _updateVector4ForUniform;
  89805. private _updateColor3ForEffect;
  89806. private _updateColor3ForUniform;
  89807. private _updateColor4ForEffect;
  89808. private _updateColor4ForUniform;
  89809. /**
  89810. * Sets a sampler uniform on the effect.
  89811. * @param name Define the name of the sampler.
  89812. * @param texture Define the texture to set in the sampler
  89813. */
  89814. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  89815. /**
  89816. * Directly updates the value of the uniform in the cache AND on the GPU.
  89817. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89818. * @param data Define the flattened data
  89819. */
  89820. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  89821. /**
  89822. * Binds this uniform buffer to an effect.
  89823. * @param effect Define the effect to bind the buffer to
  89824. * @param name Name of the uniform block in the shader.
  89825. */
  89826. bindToEffect(effect: Effect, name: string): void;
  89827. /**
  89828. * Disposes the uniform buffer.
  89829. */
  89830. dispose(): void;
  89831. }
  89832. }
  89833. declare module BABYLON {
  89834. /**
  89835. * Class used to work with sound analyzer using fast fourier transform (FFT)
  89836. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89837. */
  89838. export class Analyser {
  89839. /**
  89840. * Gets or sets the smoothing
  89841. * @ignorenaming
  89842. */
  89843. SMOOTHING: number;
  89844. /**
  89845. * Gets or sets the FFT table size
  89846. * @ignorenaming
  89847. */
  89848. FFT_SIZE: number;
  89849. /**
  89850. * Gets or sets the bar graph amplitude
  89851. * @ignorenaming
  89852. */
  89853. BARGRAPHAMPLITUDE: number;
  89854. /**
  89855. * Gets or sets the position of the debug canvas
  89856. * @ignorenaming
  89857. */
  89858. DEBUGCANVASPOS: {
  89859. x: number;
  89860. y: number;
  89861. };
  89862. /**
  89863. * Gets or sets the debug canvas size
  89864. * @ignorenaming
  89865. */
  89866. DEBUGCANVASSIZE: {
  89867. width: number;
  89868. height: number;
  89869. };
  89870. private _byteFreqs;
  89871. private _byteTime;
  89872. private _floatFreqs;
  89873. private _webAudioAnalyser;
  89874. private _debugCanvas;
  89875. private _debugCanvasContext;
  89876. private _scene;
  89877. private _registerFunc;
  89878. private _audioEngine;
  89879. /**
  89880. * Creates a new analyser
  89881. * @param scene defines hosting scene
  89882. */
  89883. constructor(scene: Scene);
  89884. /**
  89885. * Get the number of data values you will have to play with for the visualization
  89886. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  89887. * @returns a number
  89888. */
  89889. getFrequencyBinCount(): number;
  89890. /**
  89891. * Gets the current frequency data as a byte array
  89892. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  89893. * @returns a Uint8Array
  89894. */
  89895. getByteFrequencyData(): Uint8Array;
  89896. /**
  89897. * Gets the current waveform as a byte array
  89898. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  89899. * @returns a Uint8Array
  89900. */
  89901. getByteTimeDomainData(): Uint8Array;
  89902. /**
  89903. * Gets the current frequency data as a float array
  89904. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  89905. * @returns a Float32Array
  89906. */
  89907. getFloatFrequencyData(): Float32Array;
  89908. /**
  89909. * Renders the debug canvas
  89910. */
  89911. drawDebugCanvas(): void;
  89912. /**
  89913. * Stops rendering the debug canvas and removes it
  89914. */
  89915. stopDebugCanvas(): void;
  89916. /**
  89917. * Connects two audio nodes
  89918. * @param inputAudioNode defines first node to connect
  89919. * @param outputAudioNode defines second node to connect
  89920. */
  89921. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  89922. /**
  89923. * Releases all associated resources
  89924. */
  89925. dispose(): void;
  89926. }
  89927. }
  89928. declare module BABYLON {
  89929. /**
  89930. * This represents an audio engine and it is responsible
  89931. * to play, synchronize and analyse sounds throughout the application.
  89932. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89933. */
  89934. export interface IAudioEngine extends IDisposable {
  89935. /**
  89936. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  89937. */
  89938. readonly canUseWebAudio: boolean;
  89939. /**
  89940. * Gets the current AudioContext if available.
  89941. */
  89942. readonly audioContext: Nullable<AudioContext>;
  89943. /**
  89944. * The master gain node defines the global audio volume of your audio engine.
  89945. */
  89946. readonly masterGain: GainNode;
  89947. /**
  89948. * Gets whether or not mp3 are supported by your browser.
  89949. */
  89950. readonly isMP3supported: boolean;
  89951. /**
  89952. * Gets whether or not ogg are supported by your browser.
  89953. */
  89954. readonly isOGGsupported: boolean;
  89955. /**
  89956. * Defines if Babylon should emit a warning if WebAudio is not supported.
  89957. * @ignoreNaming
  89958. */
  89959. WarnedWebAudioUnsupported: boolean;
  89960. /**
  89961. * Defines if the audio engine relies on a custom unlocked button.
  89962. * In this case, the embedded button will not be displayed.
  89963. */
  89964. useCustomUnlockedButton: boolean;
  89965. /**
  89966. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  89967. */
  89968. readonly unlocked: boolean;
  89969. /**
  89970. * Event raised when audio has been unlocked on the browser.
  89971. */
  89972. onAudioUnlockedObservable: Observable<AudioEngine>;
  89973. /**
  89974. * Event raised when audio has been locked on the browser.
  89975. */
  89976. onAudioLockedObservable: Observable<AudioEngine>;
  89977. /**
  89978. * Flags the audio engine in Locked state.
  89979. * This happens due to new browser policies preventing audio to autoplay.
  89980. */
  89981. lock(): void;
  89982. /**
  89983. * Unlocks the audio engine once a user action has been done on the dom.
  89984. * This is helpful to resume play once browser policies have been satisfied.
  89985. */
  89986. unlock(): void;
  89987. }
  89988. /**
  89989. * This represents the default audio engine used in babylon.
  89990. * It is responsible to play, synchronize and analyse sounds throughout the application.
  89991. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89992. */
  89993. export class AudioEngine implements IAudioEngine {
  89994. private _audioContext;
  89995. private _audioContextInitialized;
  89996. private _muteButton;
  89997. private _hostElement;
  89998. /**
  89999. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  90000. */
  90001. canUseWebAudio: boolean;
  90002. /**
  90003. * The master gain node defines the global audio volume of your audio engine.
  90004. */
  90005. masterGain: GainNode;
  90006. /**
  90007. * Defines if Babylon should emit a warning if WebAudio is not supported.
  90008. * @ignoreNaming
  90009. */
  90010. WarnedWebAudioUnsupported: boolean;
  90011. /**
  90012. * Gets whether or not mp3 are supported by your browser.
  90013. */
  90014. isMP3supported: boolean;
  90015. /**
  90016. * Gets whether or not ogg are supported by your browser.
  90017. */
  90018. isOGGsupported: boolean;
  90019. /**
  90020. * Gets whether audio has been unlocked on the device.
  90021. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  90022. * a user interaction has happened.
  90023. */
  90024. unlocked: boolean;
  90025. /**
  90026. * Defines if the audio engine relies on a custom unlocked button.
  90027. * In this case, the embedded button will not be displayed.
  90028. */
  90029. useCustomUnlockedButton: boolean;
  90030. /**
  90031. * Event raised when audio has been unlocked on the browser.
  90032. */
  90033. onAudioUnlockedObservable: Observable<AudioEngine>;
  90034. /**
  90035. * Event raised when audio has been locked on the browser.
  90036. */
  90037. onAudioLockedObservable: Observable<AudioEngine>;
  90038. /**
  90039. * Gets the current AudioContext if available.
  90040. */
  90041. readonly audioContext: Nullable<AudioContext>;
  90042. private _connectedAnalyser;
  90043. /**
  90044. * Instantiates a new audio engine.
  90045. *
  90046. * There should be only one per page as some browsers restrict the number
  90047. * of audio contexts you can create.
  90048. * @param hostElement defines the host element where to display the mute icon if necessary
  90049. */
  90050. constructor(hostElement?: Nullable<HTMLElement>);
  90051. /**
  90052. * Flags the audio engine in Locked state.
  90053. * This happens due to new browser policies preventing audio to autoplay.
  90054. */
  90055. lock(): void;
  90056. /**
  90057. * Unlocks the audio engine once a user action has been done on the dom.
  90058. * This is helpful to resume play once browser policies have been satisfied.
  90059. */
  90060. unlock(): void;
  90061. private _resumeAudioContext;
  90062. private _initializeAudioContext;
  90063. private _tryToRun;
  90064. private _triggerRunningState;
  90065. private _triggerSuspendedState;
  90066. private _displayMuteButton;
  90067. private _moveButtonToTopLeft;
  90068. private _onResize;
  90069. private _hideMuteButton;
  90070. /**
  90071. * Destroy and release the resources associated with the audio ccontext.
  90072. */
  90073. dispose(): void;
  90074. /**
  90075. * Gets the global volume sets on the master gain.
  90076. * @returns the global volume if set or -1 otherwise
  90077. */
  90078. getGlobalVolume(): number;
  90079. /**
  90080. * Sets the global volume of your experience (sets on the master gain).
  90081. * @param newVolume Defines the new global volume of the application
  90082. */
  90083. setGlobalVolume(newVolume: number): void;
  90084. /**
  90085. * Connect the audio engine to an audio analyser allowing some amazing
  90086. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  90087. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  90088. * @param analyser The analyser to connect to the engine
  90089. */
  90090. connectToAnalyser(analyser: Analyser): void;
  90091. }
  90092. }
  90093. declare module BABYLON {
  90094. /**
  90095. * Interface used to present a loading screen while loading a scene
  90096. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  90097. */
  90098. export interface ILoadingScreen {
  90099. /**
  90100. * Function called to display the loading screen
  90101. */
  90102. displayLoadingUI: () => void;
  90103. /**
  90104. * Function called to hide the loading screen
  90105. */
  90106. hideLoadingUI: () => void;
  90107. /**
  90108. * Gets or sets the color to use for the background
  90109. */
  90110. loadingUIBackgroundColor: string;
  90111. /**
  90112. * Gets or sets the text to display while loading
  90113. */
  90114. loadingUIText: string;
  90115. }
  90116. /**
  90117. * Class used for the default loading screen
  90118. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  90119. */
  90120. export class DefaultLoadingScreen implements ILoadingScreen {
  90121. private _renderingCanvas;
  90122. private _loadingText;
  90123. private _loadingDivBackgroundColor;
  90124. private _loadingDiv;
  90125. private _loadingTextDiv;
  90126. /** Gets or sets the logo url to use for the default loading screen */
  90127. static DefaultLogoUrl: string;
  90128. /** Gets or sets the spinner url to use for the default loading screen */
  90129. static DefaultSpinnerUrl: string;
  90130. /**
  90131. * Creates a new default loading screen
  90132. * @param _renderingCanvas defines the canvas used to render the scene
  90133. * @param _loadingText defines the default text to display
  90134. * @param _loadingDivBackgroundColor defines the default background color
  90135. */
  90136. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  90137. /**
  90138. * Function called to display the loading screen
  90139. */
  90140. displayLoadingUI(): void;
  90141. /**
  90142. * Function called to hide the loading screen
  90143. */
  90144. hideLoadingUI(): void;
  90145. /**
  90146. * Gets or sets the text to display while loading
  90147. */
  90148. loadingUIText: string;
  90149. /**
  90150. * Gets or sets the color to use for the background
  90151. */
  90152. loadingUIBackgroundColor: string;
  90153. private _resizeLoadingUI;
  90154. }
  90155. }
  90156. declare module BABYLON {
  90157. /** @hidden */
  90158. export class WebGLPipelineContext implements IPipelineContext {
  90159. engine: Engine;
  90160. program: Nullable<WebGLProgram>;
  90161. context?: WebGLRenderingContext;
  90162. vertexShader?: WebGLShader;
  90163. fragmentShader?: WebGLShader;
  90164. isParallelCompiled: boolean;
  90165. onCompiled?: () => void;
  90166. transformFeedback?: WebGLTransformFeedback | null;
  90167. readonly isAsync: boolean;
  90168. readonly isReady: boolean;
  90169. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  90170. }
  90171. }
  90172. declare module BABYLON {
  90173. /** @hidden */
  90174. export class WebGLDataBuffer extends DataBuffer {
  90175. private _buffer;
  90176. constructor(resource: WebGLBuffer);
  90177. readonly underlyingResource: any;
  90178. }
  90179. }
  90180. declare module BABYLON {
  90181. /** @hidden */
  90182. export class WebGL2ShaderProcessor implements IShaderProcessor {
  90183. attributeProcessor(attribute: string): string;
  90184. varyingProcessor(varying: string, isFragment: boolean): string;
  90185. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  90186. }
  90187. }
  90188. declare module BABYLON {
  90189. /**
  90190. * Settings for finer control over video usage
  90191. */
  90192. export interface VideoTextureSettings {
  90193. /**
  90194. * Applies `autoplay` to video, if specified
  90195. */
  90196. autoPlay?: boolean;
  90197. /**
  90198. * Applies `loop` to video, if specified
  90199. */
  90200. loop?: boolean;
  90201. /**
  90202. * Automatically updates internal texture from video at every frame in the render loop
  90203. */
  90204. autoUpdateTexture: boolean;
  90205. /**
  90206. * Image src displayed during the video loading or until the user interacts with the video.
  90207. */
  90208. poster?: string;
  90209. }
  90210. /**
  90211. * If you want to display a video in your scene, this is the special texture for that.
  90212. * This special texture works similar to other textures, with the exception of a few parameters.
  90213. * @see https://doc.babylonjs.com/how_to/video_texture
  90214. */
  90215. export class VideoTexture extends Texture {
  90216. /**
  90217. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  90218. */
  90219. readonly autoUpdateTexture: boolean;
  90220. /**
  90221. * The video instance used by the texture internally
  90222. */
  90223. readonly video: HTMLVideoElement;
  90224. private _onUserActionRequestedObservable;
  90225. /**
  90226. * Event triggerd when a dom action is required by the user to play the video.
  90227. * This happens due to recent changes in browser policies preventing video to auto start.
  90228. */
  90229. readonly onUserActionRequestedObservable: Observable<Texture>;
  90230. private _generateMipMaps;
  90231. private _engine;
  90232. private _stillImageCaptured;
  90233. private _displayingPosterTexture;
  90234. private _settings;
  90235. private _createInternalTextureOnEvent;
  90236. /**
  90237. * Creates a video texture.
  90238. * If you want to display a video in your scene, this is the special texture for that.
  90239. * This special texture works similar to other textures, with the exception of a few parameters.
  90240. * @see https://doc.babylonjs.com/how_to/video_texture
  90241. * @param name optional name, will detect from video source, if not defined
  90242. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  90243. * @param scene is obviously the current scene.
  90244. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  90245. * @param invertY is false by default but can be used to invert video on Y axis
  90246. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  90247. * @param settings allows finer control over video usage
  90248. */
  90249. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  90250. private _getName;
  90251. private _getVideo;
  90252. private _createInternalTexture;
  90253. private reset;
  90254. /**
  90255. * @hidden Internal method to initiate `update`.
  90256. */
  90257. _rebuild(): void;
  90258. /**
  90259. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  90260. */
  90261. update(): void;
  90262. /**
  90263. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  90264. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  90265. */
  90266. updateTexture(isVisible: boolean): void;
  90267. protected _updateInternalTexture: () => void;
  90268. /**
  90269. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  90270. * @param url New url.
  90271. */
  90272. updateURL(url: string): void;
  90273. /**
  90274. * Dispose the texture and release its associated resources.
  90275. */
  90276. dispose(): void;
  90277. /**
  90278. * Creates a video texture straight from a stream.
  90279. * @param scene Define the scene the texture should be created in
  90280. * @param stream Define the stream the texture should be created from
  90281. * @returns The created video texture as a promise
  90282. */
  90283. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  90284. /**
  90285. * Creates a video texture straight from your WebCam video feed.
  90286. * @param scene Define the scene the texture should be created in
  90287. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  90288. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  90289. * @returns The created video texture as a promise
  90290. */
  90291. static CreateFromWebCamAsync(scene: Scene, constraints: {
  90292. minWidth: number;
  90293. maxWidth: number;
  90294. minHeight: number;
  90295. maxHeight: number;
  90296. deviceId: string;
  90297. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  90298. /**
  90299. * Creates a video texture straight from your WebCam video feed.
  90300. * @param scene Define the scene the texture should be created in
  90301. * @param onReady Define a callback to triggered once the texture will be ready
  90302. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  90303. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  90304. */
  90305. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  90306. minWidth: number;
  90307. maxWidth: number;
  90308. minHeight: number;
  90309. maxHeight: number;
  90310. deviceId: string;
  90311. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  90312. }
  90313. }
  90314. declare module BABYLON {
  90315. /**
  90316. * Interface for attribute information associated with buffer instanciation
  90317. */
  90318. export class InstancingAttributeInfo {
  90319. /**
  90320. * Index/offset of the attribute in the vertex shader
  90321. */
  90322. index: number;
  90323. /**
  90324. * size of the attribute, 1, 2, 3 or 4
  90325. */
  90326. attributeSize: number;
  90327. /**
  90328. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  90329. * default is FLOAT
  90330. */
  90331. attribyteType: number;
  90332. /**
  90333. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  90334. */
  90335. normalized: boolean;
  90336. /**
  90337. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  90338. */
  90339. offset: number;
  90340. /**
  90341. * Name of the GLSL attribute, for debugging purpose only
  90342. */
  90343. attributeName: string;
  90344. }
  90345. /**
  90346. * Define options used to create a depth texture
  90347. */
  90348. export class DepthTextureCreationOptions {
  90349. /** Specifies whether or not a stencil should be allocated in the texture */
  90350. generateStencil?: boolean;
  90351. /** Specifies whether or not bilinear filtering is enable on the texture */
  90352. bilinearFiltering?: boolean;
  90353. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  90354. comparisonFunction?: number;
  90355. /** Specifies if the created texture is a cube texture */
  90356. isCube?: boolean;
  90357. }
  90358. /**
  90359. * Class used to describe the capabilities of the engine relatively to the current browser
  90360. */
  90361. export class EngineCapabilities {
  90362. /** Maximum textures units per fragment shader */
  90363. maxTexturesImageUnits: number;
  90364. /** Maximum texture units per vertex shader */
  90365. maxVertexTextureImageUnits: number;
  90366. /** Maximum textures units in the entire pipeline */
  90367. maxCombinedTexturesImageUnits: number;
  90368. /** Maximum texture size */
  90369. maxTextureSize: number;
  90370. /** Maximum cube texture size */
  90371. maxCubemapTextureSize: number;
  90372. /** Maximum render texture size */
  90373. maxRenderTextureSize: number;
  90374. /** Maximum number of vertex attributes */
  90375. maxVertexAttribs: number;
  90376. /** Maximum number of varyings */
  90377. maxVaryingVectors: number;
  90378. /** Maximum number of uniforms per vertex shader */
  90379. maxVertexUniformVectors: number;
  90380. /** Maximum number of uniforms per fragment shader */
  90381. maxFragmentUniformVectors: number;
  90382. /** Defines if standard derivates (dx/dy) are supported */
  90383. standardDerivatives: boolean;
  90384. /** Defines if s3tc texture compression is supported */
  90385. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  90386. /** Defines if pvrtc texture compression is supported */
  90387. pvrtc: any;
  90388. /** Defines if etc1 texture compression is supported */
  90389. etc1: any;
  90390. /** Defines if etc2 texture compression is supported */
  90391. etc2: any;
  90392. /** Defines if astc texture compression is supported */
  90393. astc: any;
  90394. /** Defines if float textures are supported */
  90395. textureFloat: boolean;
  90396. /** Defines if vertex array objects are supported */
  90397. vertexArrayObject: boolean;
  90398. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  90399. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  90400. /** Gets the maximum level of anisotropy supported */
  90401. maxAnisotropy: number;
  90402. /** Defines if instancing is supported */
  90403. instancedArrays: boolean;
  90404. /** Defines if 32 bits indices are supported */
  90405. uintIndices: boolean;
  90406. /** Defines if high precision shaders are supported */
  90407. highPrecisionShaderSupported: boolean;
  90408. /** Defines if depth reading in the fragment shader is supported */
  90409. fragmentDepthSupported: boolean;
  90410. /** Defines if float texture linear filtering is supported*/
  90411. textureFloatLinearFiltering: boolean;
  90412. /** Defines if rendering to float textures is supported */
  90413. textureFloatRender: boolean;
  90414. /** Defines if half float textures are supported*/
  90415. textureHalfFloat: boolean;
  90416. /** Defines if half float texture linear filtering is supported*/
  90417. textureHalfFloatLinearFiltering: boolean;
  90418. /** Defines if rendering to half float textures is supported */
  90419. textureHalfFloatRender: boolean;
  90420. /** Defines if textureLOD shader command is supported */
  90421. textureLOD: boolean;
  90422. /** Defines if draw buffers extension is supported */
  90423. drawBuffersExtension: boolean;
  90424. /** Defines if depth textures are supported */
  90425. depthTextureExtension: boolean;
  90426. /** Defines if float color buffer are supported */
  90427. colorBufferFloat: boolean;
  90428. /** Gets disjoint timer query extension (null if not supported) */
  90429. timerQuery: EXT_disjoint_timer_query;
  90430. /** Defines if timestamp can be used with timer query */
  90431. canUseTimestampForTimerQuery: boolean;
  90432. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  90433. multiview: any;
  90434. /** Function used to let the system compiles shaders in background */
  90435. parallelShaderCompile: {
  90436. COMPLETION_STATUS_KHR: number;
  90437. };
  90438. }
  90439. /** Interface defining initialization parameters for Engine class */
  90440. export interface EngineOptions extends WebGLContextAttributes {
  90441. /**
  90442. * Defines if the engine should no exceed a specified device ratio
  90443. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  90444. */
  90445. limitDeviceRatio?: number;
  90446. /**
  90447. * Defines if webvr should be enabled automatically
  90448. * @see http://doc.babylonjs.com/how_to/webvr_camera
  90449. */
  90450. autoEnableWebVR?: boolean;
  90451. /**
  90452. * Defines if webgl2 should be turned off even if supported
  90453. * @see http://doc.babylonjs.com/features/webgl2
  90454. */
  90455. disableWebGL2Support?: boolean;
  90456. /**
  90457. * Defines if webaudio should be initialized as well
  90458. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90459. */
  90460. audioEngine?: boolean;
  90461. /**
  90462. * Defines if animations should run using a deterministic lock step
  90463. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90464. */
  90465. deterministicLockstep?: boolean;
  90466. /** Defines the maximum steps to use with deterministic lock step mode */
  90467. lockstepMaxSteps?: number;
  90468. /**
  90469. * Defines that engine should ignore context lost events
  90470. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  90471. */
  90472. doNotHandleContextLost?: boolean;
  90473. /**
  90474. * Defines that engine should ignore modifying touch action attribute and style
  90475. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  90476. */
  90477. doNotHandleTouchAction?: boolean;
  90478. /**
  90479. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  90480. */
  90481. useHighPrecisionFloats?: boolean;
  90482. }
  90483. /**
  90484. * Defines the interface used by display changed events
  90485. */
  90486. export interface IDisplayChangedEventArgs {
  90487. /** Gets the vrDisplay object (if any) */
  90488. vrDisplay: Nullable<any>;
  90489. /** Gets a boolean indicating if webVR is supported */
  90490. vrSupported: boolean;
  90491. }
  90492. /**
  90493. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  90494. */
  90495. export class Engine {
  90496. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  90497. static ExceptionList: ({
  90498. key: string;
  90499. capture: string;
  90500. captureConstraint: number;
  90501. targets: string[];
  90502. } | {
  90503. key: string;
  90504. capture: null;
  90505. captureConstraint: null;
  90506. targets: string[];
  90507. })[];
  90508. /** Gets the list of created engines */
  90509. static readonly Instances: Engine[];
  90510. /**
  90511. * Gets the latest created engine
  90512. */
  90513. static readonly LastCreatedEngine: Nullable<Engine>;
  90514. /**
  90515. * Gets the latest created scene
  90516. */
  90517. static readonly LastCreatedScene: Nullable<Scene>;
  90518. /**
  90519. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  90520. * @param flag defines which part of the materials must be marked as dirty
  90521. * @param predicate defines a predicate used to filter which materials should be affected
  90522. */
  90523. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  90524. /** @hidden */
  90525. static _TextureLoaders: IInternalTextureLoader[];
  90526. /** Defines that alpha blending is disabled */
  90527. static readonly ALPHA_DISABLE: number;
  90528. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  90529. static readonly ALPHA_ADD: number;
  90530. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  90531. static readonly ALPHA_COMBINE: number;
  90532. /** Defines that alpha blending to DEST - SRC * DEST */
  90533. static readonly ALPHA_SUBTRACT: number;
  90534. /** Defines that alpha blending to SRC * DEST */
  90535. static readonly ALPHA_MULTIPLY: number;
  90536. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  90537. static readonly ALPHA_MAXIMIZED: number;
  90538. /** Defines that alpha blending to SRC + DEST */
  90539. static readonly ALPHA_ONEONE: number;
  90540. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  90541. static readonly ALPHA_PREMULTIPLIED: number;
  90542. /**
  90543. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  90544. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  90545. */
  90546. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  90547. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  90548. static readonly ALPHA_INTERPOLATE: number;
  90549. /**
  90550. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  90551. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  90552. */
  90553. static readonly ALPHA_SCREENMODE: number;
  90554. /** Defines that the ressource is not delayed*/
  90555. static readonly DELAYLOADSTATE_NONE: number;
  90556. /** Defines that the ressource was successfully delay loaded */
  90557. static readonly DELAYLOADSTATE_LOADED: number;
  90558. /** Defines that the ressource is currently delay loading */
  90559. static readonly DELAYLOADSTATE_LOADING: number;
  90560. /** Defines that the ressource is delayed and has not started loading */
  90561. static readonly DELAYLOADSTATE_NOTLOADED: number;
  90562. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  90563. static readonly NEVER: number;
  90564. /** 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 */
  90565. static readonly ALWAYS: number;
  90566. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  90567. static readonly LESS: number;
  90568. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  90569. static readonly EQUAL: number;
  90570. /** 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 */
  90571. static readonly LEQUAL: number;
  90572. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  90573. static readonly GREATER: number;
  90574. /** 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 */
  90575. static readonly GEQUAL: number;
  90576. /** 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 */
  90577. static readonly NOTEQUAL: number;
  90578. /** Passed to stencilOperation to specify that stencil value must be kept */
  90579. static readonly KEEP: number;
  90580. /** Passed to stencilOperation to specify that stencil value must be replaced */
  90581. static readonly REPLACE: number;
  90582. /** Passed to stencilOperation to specify that stencil value must be incremented */
  90583. static readonly INCR: number;
  90584. /** Passed to stencilOperation to specify that stencil value must be decremented */
  90585. static readonly DECR: number;
  90586. /** Passed to stencilOperation to specify that stencil value must be inverted */
  90587. static readonly INVERT: number;
  90588. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  90589. static readonly INCR_WRAP: number;
  90590. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  90591. static readonly DECR_WRAP: number;
  90592. /** Texture is not repeating outside of 0..1 UVs */
  90593. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  90594. /** Texture is repeating outside of 0..1 UVs */
  90595. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  90596. /** Texture is repeating and mirrored */
  90597. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  90598. /** ALPHA */
  90599. static readonly TEXTUREFORMAT_ALPHA: number;
  90600. /** LUMINANCE */
  90601. static readonly TEXTUREFORMAT_LUMINANCE: number;
  90602. /** LUMINANCE_ALPHA */
  90603. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  90604. /** RGB */
  90605. static readonly TEXTUREFORMAT_RGB: number;
  90606. /** RGBA */
  90607. static readonly TEXTUREFORMAT_RGBA: number;
  90608. /** RED */
  90609. static readonly TEXTUREFORMAT_RED: number;
  90610. /** RED (2nd reference) */
  90611. static readonly TEXTUREFORMAT_R: number;
  90612. /** RG */
  90613. static readonly TEXTUREFORMAT_RG: number;
  90614. /** RED_INTEGER */
  90615. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  90616. /** RED_INTEGER (2nd reference) */
  90617. static readonly TEXTUREFORMAT_R_INTEGER: number;
  90618. /** RG_INTEGER */
  90619. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  90620. /** RGB_INTEGER */
  90621. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  90622. /** RGBA_INTEGER */
  90623. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  90624. /** UNSIGNED_BYTE */
  90625. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  90626. /** UNSIGNED_BYTE (2nd reference) */
  90627. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  90628. /** FLOAT */
  90629. static readonly TEXTURETYPE_FLOAT: number;
  90630. /** HALF_FLOAT */
  90631. static readonly TEXTURETYPE_HALF_FLOAT: number;
  90632. /** BYTE */
  90633. static readonly TEXTURETYPE_BYTE: number;
  90634. /** SHORT */
  90635. static readonly TEXTURETYPE_SHORT: number;
  90636. /** UNSIGNED_SHORT */
  90637. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  90638. /** INT */
  90639. static readonly TEXTURETYPE_INT: number;
  90640. /** UNSIGNED_INT */
  90641. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  90642. /** UNSIGNED_SHORT_4_4_4_4 */
  90643. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  90644. /** UNSIGNED_SHORT_5_5_5_1 */
  90645. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  90646. /** UNSIGNED_SHORT_5_6_5 */
  90647. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  90648. /** UNSIGNED_INT_2_10_10_10_REV */
  90649. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  90650. /** UNSIGNED_INT_24_8 */
  90651. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  90652. /** UNSIGNED_INT_10F_11F_11F_REV */
  90653. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  90654. /** UNSIGNED_INT_5_9_9_9_REV */
  90655. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  90656. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  90657. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  90658. /** nearest is mag = nearest and min = nearest and mip = linear */
  90659. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  90660. /** Bilinear is mag = linear and min = linear and mip = nearest */
  90661. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  90662. /** Trilinear is mag = linear and min = linear and mip = linear */
  90663. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  90664. /** nearest is mag = nearest and min = nearest and mip = linear */
  90665. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  90666. /** Bilinear is mag = linear and min = linear and mip = nearest */
  90667. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  90668. /** Trilinear is mag = linear and min = linear and mip = linear */
  90669. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  90670. /** mag = nearest and min = nearest and mip = nearest */
  90671. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  90672. /** mag = nearest and min = linear and mip = nearest */
  90673. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  90674. /** mag = nearest and min = linear and mip = linear */
  90675. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  90676. /** mag = nearest and min = linear and mip = none */
  90677. static readonly TEXTURE_NEAREST_LINEAR: number;
  90678. /** mag = nearest and min = nearest and mip = none */
  90679. static readonly TEXTURE_NEAREST_NEAREST: number;
  90680. /** mag = linear and min = nearest and mip = nearest */
  90681. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  90682. /** mag = linear and min = nearest and mip = linear */
  90683. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  90684. /** mag = linear and min = linear and mip = none */
  90685. static readonly TEXTURE_LINEAR_LINEAR: number;
  90686. /** mag = linear and min = nearest and mip = none */
  90687. static readonly TEXTURE_LINEAR_NEAREST: number;
  90688. /** Explicit coordinates mode */
  90689. static readonly TEXTURE_EXPLICIT_MODE: number;
  90690. /** Spherical coordinates mode */
  90691. static readonly TEXTURE_SPHERICAL_MODE: number;
  90692. /** Planar coordinates mode */
  90693. static readonly TEXTURE_PLANAR_MODE: number;
  90694. /** Cubic coordinates mode */
  90695. static readonly TEXTURE_CUBIC_MODE: number;
  90696. /** Projection coordinates mode */
  90697. static readonly TEXTURE_PROJECTION_MODE: number;
  90698. /** Skybox coordinates mode */
  90699. static readonly TEXTURE_SKYBOX_MODE: number;
  90700. /** Inverse Cubic coordinates mode */
  90701. static readonly TEXTURE_INVCUBIC_MODE: number;
  90702. /** Equirectangular coordinates mode */
  90703. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  90704. /** Equirectangular Fixed coordinates mode */
  90705. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  90706. /** Equirectangular Fixed Mirrored coordinates mode */
  90707. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  90708. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  90709. static readonly SCALEMODE_FLOOR: number;
  90710. /** Defines that texture rescaling will look for the nearest power of 2 size */
  90711. static readonly SCALEMODE_NEAREST: number;
  90712. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  90713. static readonly SCALEMODE_CEILING: number;
  90714. /**
  90715. * Returns the current npm package of the sdk
  90716. */
  90717. static readonly NpmPackage: string;
  90718. /**
  90719. * Returns the current version of the framework
  90720. */
  90721. static readonly Version: string;
  90722. /**
  90723. * Returns a string describing the current engine
  90724. */
  90725. readonly description: string;
  90726. /**
  90727. * Gets or sets the epsilon value used by collision engine
  90728. */
  90729. static CollisionsEpsilon: number;
  90730. /**
  90731. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  90732. */
  90733. static ShadersRepository: string;
  90734. /**
  90735. * Method called to create the default loading screen.
  90736. * This can be overriden in your own app.
  90737. * @param canvas The rendering canvas element
  90738. * @returns The loading screen
  90739. */
  90740. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  90741. /**
  90742. * Method called to create the default rescale post process on each engine.
  90743. */
  90744. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  90745. /** @hidden */
  90746. _shaderProcessor: IShaderProcessor;
  90747. /**
  90748. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  90749. */
  90750. forcePOTTextures: boolean;
  90751. /**
  90752. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  90753. */
  90754. isFullscreen: boolean;
  90755. /**
  90756. * Gets a boolean indicating if the pointer is currently locked
  90757. */
  90758. isPointerLock: boolean;
  90759. /**
  90760. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  90761. */
  90762. cullBackFaces: boolean;
  90763. /**
  90764. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  90765. */
  90766. renderEvenInBackground: boolean;
  90767. /**
  90768. * Gets or sets a boolean indicating that cache can be kept between frames
  90769. */
  90770. preventCacheWipeBetweenFrames: boolean;
  90771. /**
  90772. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  90773. **/
  90774. enableOfflineSupport: boolean;
  90775. /**
  90776. * 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)
  90777. **/
  90778. disableManifestCheck: boolean;
  90779. /**
  90780. * Gets the list of created scenes
  90781. */
  90782. scenes: Scene[];
  90783. /**
  90784. * Event raised when a new scene is created
  90785. */
  90786. onNewSceneAddedObservable: Observable<Scene>;
  90787. /**
  90788. * Gets the list of created postprocesses
  90789. */
  90790. postProcesses: PostProcess[];
  90791. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  90792. validateShaderPrograms: boolean;
  90793. /**
  90794. * Observable event triggered each time the rendering canvas is resized
  90795. */
  90796. onResizeObservable: Observable<Engine>;
  90797. /**
  90798. * Observable event triggered each time the canvas loses focus
  90799. */
  90800. onCanvasBlurObservable: Observable<Engine>;
  90801. /**
  90802. * Observable event triggered each time the canvas gains focus
  90803. */
  90804. onCanvasFocusObservable: Observable<Engine>;
  90805. /**
  90806. * Observable event triggered each time the canvas receives pointerout event
  90807. */
  90808. onCanvasPointerOutObservable: Observable<PointerEvent>;
  90809. /**
  90810. * Observable event triggered before each texture is initialized
  90811. */
  90812. onBeforeTextureInitObservable: Observable<Texture>;
  90813. /**
  90814. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  90815. */
  90816. disableUniformBuffers: boolean;
  90817. /** @hidden */
  90818. _uniformBuffers: UniformBuffer[];
  90819. /**
  90820. * Gets a boolean indicating that the engine supports uniform buffers
  90821. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90822. */
  90823. readonly supportsUniformBuffers: boolean;
  90824. /**
  90825. * Observable raised when the engine begins a new frame
  90826. */
  90827. onBeginFrameObservable: Observable<Engine>;
  90828. /**
  90829. * If set, will be used to request the next animation frame for the render loop
  90830. */
  90831. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  90832. /**
  90833. * Observable raised when the engine ends the current frame
  90834. */
  90835. onEndFrameObservable: Observable<Engine>;
  90836. /**
  90837. * Observable raised when the engine is about to compile a shader
  90838. */
  90839. onBeforeShaderCompilationObservable: Observable<Engine>;
  90840. /**
  90841. * Observable raised when the engine has jsut compiled a shader
  90842. */
  90843. onAfterShaderCompilationObservable: Observable<Engine>;
  90844. /** @hidden */
  90845. _gl: WebGLRenderingContext;
  90846. private _renderingCanvas;
  90847. private _windowIsBackground;
  90848. private _webGLVersion;
  90849. protected _highPrecisionShadersAllowed: boolean;
  90850. /** @hidden */
  90851. readonly _shouldUseHighPrecisionShader: boolean;
  90852. /**
  90853. * Gets a boolean indicating that only power of 2 textures are supported
  90854. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  90855. */
  90856. readonly needPOTTextures: boolean;
  90857. /** @hidden */
  90858. _badOS: boolean;
  90859. /** @hidden */
  90860. _badDesktopOS: boolean;
  90861. /**
  90862. * Gets the audio engine
  90863. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90864. * @ignorenaming
  90865. */
  90866. static audioEngine: IAudioEngine;
  90867. /**
  90868. * Default AudioEngine factory responsible of creating the Audio Engine.
  90869. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  90870. */
  90871. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  90872. /**
  90873. * Default offline support factory responsible of creating a tool used to store data locally.
  90874. * By default, this will create a Database object if the workload has been embedded.
  90875. */
  90876. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  90877. private _onFocus;
  90878. private _onBlur;
  90879. private _onCanvasPointerOut;
  90880. private _onCanvasBlur;
  90881. private _onCanvasFocus;
  90882. private _onFullscreenChange;
  90883. private _onPointerLockChange;
  90884. private _hardwareScalingLevel;
  90885. /** @hidden */
  90886. _caps: EngineCapabilities;
  90887. private _pointerLockRequested;
  90888. private _isStencilEnable;
  90889. private _colorWrite;
  90890. private _loadingScreen;
  90891. /** @hidden */
  90892. _drawCalls: PerfCounter;
  90893. private _glVersion;
  90894. private _glRenderer;
  90895. private _glVendor;
  90896. private _videoTextureSupported;
  90897. private _renderingQueueLaunched;
  90898. private _activeRenderLoops;
  90899. private _deterministicLockstep;
  90900. private _lockstepMaxSteps;
  90901. /**
  90902. * Observable signaled when a context lost event is raised
  90903. */
  90904. onContextLostObservable: Observable<Engine>;
  90905. /**
  90906. * Observable signaled when a context restored event is raised
  90907. */
  90908. onContextRestoredObservable: Observable<Engine>;
  90909. private _onContextLost;
  90910. private _onContextRestored;
  90911. private _contextWasLost;
  90912. /** @hidden */
  90913. _doNotHandleContextLost: boolean;
  90914. /**
  90915. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  90916. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  90917. */
  90918. doNotHandleContextLost: boolean;
  90919. private _performanceMonitor;
  90920. private _fps;
  90921. private _deltaTime;
  90922. /**
  90923. * Turn this value on if you want to pause FPS computation when in background
  90924. */
  90925. disablePerformanceMonitorInBackground: boolean;
  90926. /**
  90927. * Gets the performance monitor attached to this engine
  90928. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  90929. */
  90930. readonly performanceMonitor: PerformanceMonitor;
  90931. /**
  90932. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  90933. */
  90934. disableVertexArrayObjects: boolean;
  90935. /** @hidden */
  90936. protected _depthCullingState: _DepthCullingState;
  90937. /** @hidden */
  90938. protected _stencilState: _StencilState;
  90939. /** @hidden */
  90940. protected _alphaState: _AlphaState;
  90941. /** @hidden */
  90942. protected _alphaMode: number;
  90943. /** @hidden */
  90944. _internalTexturesCache: InternalTexture[];
  90945. /** @hidden */
  90946. protected _activeChannel: number;
  90947. private _currentTextureChannel;
  90948. /** @hidden */
  90949. protected _boundTexturesCache: {
  90950. [key: string]: Nullable<InternalTexture>;
  90951. };
  90952. /** @hidden */
  90953. protected _currentEffect: Nullable<Effect>;
  90954. /** @hidden */
  90955. protected _currentProgram: Nullable<WebGLProgram>;
  90956. private _compiledEffects;
  90957. private _vertexAttribArraysEnabled;
  90958. /** @hidden */
  90959. protected _cachedViewport: Nullable<Viewport>;
  90960. private _cachedVertexArrayObject;
  90961. /** @hidden */
  90962. protected _cachedVertexBuffers: any;
  90963. /** @hidden */
  90964. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  90965. /** @hidden */
  90966. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  90967. /** @hidden */
  90968. _currentRenderTarget: Nullable<InternalTexture>;
  90969. private _uintIndicesCurrentlySet;
  90970. private _currentBoundBuffer;
  90971. /** @hidden */
  90972. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  90973. private _currentBufferPointers;
  90974. private _currentInstanceLocations;
  90975. private _currentInstanceBuffers;
  90976. private _textureUnits;
  90977. /** @hidden */
  90978. _workingCanvas: Nullable<HTMLCanvasElement>;
  90979. /** @hidden */
  90980. _workingContext: Nullable<CanvasRenderingContext2D>;
  90981. private _rescalePostProcess;
  90982. private _dummyFramebuffer;
  90983. private _externalData;
  90984. /** @hidden */
  90985. _bindedRenderFunction: any;
  90986. private _vaoRecordInProgress;
  90987. private _mustWipeVertexAttributes;
  90988. private _emptyTexture;
  90989. private _emptyCubeTexture;
  90990. private _emptyTexture3D;
  90991. /** @hidden */
  90992. _frameHandler: number;
  90993. private _nextFreeTextureSlots;
  90994. private _maxSimultaneousTextures;
  90995. private _activeRequests;
  90996. private _texturesSupported;
  90997. /** @hidden */
  90998. _textureFormatInUse: Nullable<string>;
  90999. /**
  91000. * Gets the list of texture formats supported
  91001. */
  91002. readonly texturesSupported: Array<string>;
  91003. /**
  91004. * Gets the list of texture formats in use
  91005. */
  91006. readonly textureFormatInUse: Nullable<string>;
  91007. /**
  91008. * Gets the current viewport
  91009. */
  91010. readonly currentViewport: Nullable<Viewport>;
  91011. /**
  91012. * Gets the default empty texture
  91013. */
  91014. readonly emptyTexture: InternalTexture;
  91015. /**
  91016. * Gets the default empty 3D texture
  91017. */
  91018. readonly emptyTexture3D: InternalTexture;
  91019. /**
  91020. * Gets the default empty cube texture
  91021. */
  91022. readonly emptyCubeTexture: InternalTexture;
  91023. /**
  91024. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  91025. */
  91026. readonly premultipliedAlpha: boolean;
  91027. /**
  91028. * Creates a new engine
  91029. * @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
  91030. * @param antialias defines enable antialiasing (default: false)
  91031. * @param options defines further options to be sent to the getContext() function
  91032. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  91033. */
  91034. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  91035. /**
  91036. * Initializes a webVR display and starts listening to display change events
  91037. * The onVRDisplayChangedObservable will be notified upon these changes
  91038. * @returns The onVRDisplayChangedObservable
  91039. */
  91040. initWebVR(): Observable<IDisplayChangedEventArgs>;
  91041. /** @hidden */
  91042. _prepareVRComponent(): void;
  91043. /** @hidden */
  91044. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  91045. /** @hidden */
  91046. _submitVRFrame(): void;
  91047. /**
  91048. * Call this function to leave webVR mode
  91049. * Will do nothing if webVR is not supported or if there is no webVR device
  91050. * @see http://doc.babylonjs.com/how_to/webvr_camera
  91051. */
  91052. disableVR(): void;
  91053. /**
  91054. * Gets a boolean indicating that the system is in VR mode and is presenting
  91055. * @returns true if VR mode is engaged
  91056. */
  91057. isVRPresenting(): boolean;
  91058. /** @hidden */
  91059. _requestVRFrame(): void;
  91060. private _disableTouchAction;
  91061. private _rebuildInternalTextures;
  91062. private _rebuildEffects;
  91063. /**
  91064. * Gets a boolean indicating if all created effects are ready
  91065. * @returns true if all effects are ready
  91066. */
  91067. areAllEffectsReady(): boolean;
  91068. private _rebuildBuffers;
  91069. private _initGLContext;
  91070. /**
  91071. * Gets version of the current webGL context
  91072. */
  91073. readonly webGLVersion: number;
  91074. /**
  91075. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  91076. */
  91077. readonly isStencilEnable: boolean;
  91078. /** @hidden */
  91079. _prepareWorkingCanvas(): void;
  91080. /**
  91081. * Reset the texture cache to empty state
  91082. */
  91083. resetTextureCache(): void;
  91084. /**
  91085. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  91086. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91087. * @returns true if engine is in deterministic lock step mode
  91088. */
  91089. isDeterministicLockStep(): boolean;
  91090. /**
  91091. * Gets the max steps when engine is running in deterministic lock step
  91092. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91093. * @returns the max steps
  91094. */
  91095. getLockstepMaxSteps(): number;
  91096. /**
  91097. * Gets an object containing information about the current webGL context
  91098. * @returns an object containing the vender, the renderer and the version of the current webGL context
  91099. */
  91100. getGlInfo(): {
  91101. vendor: string;
  91102. renderer: string;
  91103. version: string;
  91104. };
  91105. /**
  91106. * Gets current aspect ratio
  91107. * @param camera defines the camera to use to get the aspect ratio
  91108. * @param useScreen defines if screen size must be used (or the current render target if any)
  91109. * @returns a number defining the aspect ratio
  91110. */
  91111. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  91112. /**
  91113. * Gets current screen aspect ratio
  91114. * @returns a number defining the aspect ratio
  91115. */
  91116. getScreenAspectRatio(): number;
  91117. /**
  91118. * Gets the current render width
  91119. * @param useScreen defines if screen size must be used (or the current render target if any)
  91120. * @returns a number defining the current render width
  91121. */
  91122. getRenderWidth(useScreen?: boolean): number;
  91123. /**
  91124. * Gets the current render height
  91125. * @param useScreen defines if screen size must be used (or the current render target if any)
  91126. * @returns a number defining the current render height
  91127. */
  91128. getRenderHeight(useScreen?: boolean): number;
  91129. /**
  91130. * Gets the HTML canvas attached with the current webGL context
  91131. * @returns a HTML canvas
  91132. */
  91133. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  91134. /**
  91135. * Gets the client rect of the HTML canvas attached with the current webGL context
  91136. * @returns a client rectanglee
  91137. */
  91138. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  91139. /**
  91140. * Defines the hardware scaling level.
  91141. * By default the hardware scaling level is computed from the window device ratio.
  91142. * 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.
  91143. * @param level defines the level to use
  91144. */
  91145. setHardwareScalingLevel(level: number): void;
  91146. /**
  91147. * Gets the current hardware scaling level.
  91148. * By default the hardware scaling level is computed from the window device ratio.
  91149. * 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.
  91150. * @returns a number indicating the current hardware scaling level
  91151. */
  91152. getHardwareScalingLevel(): number;
  91153. /**
  91154. * Gets the list of loaded textures
  91155. * @returns an array containing all loaded textures
  91156. */
  91157. getLoadedTexturesCache(): InternalTexture[];
  91158. /**
  91159. * Gets the object containing all engine capabilities
  91160. * @returns the EngineCapabilities object
  91161. */
  91162. getCaps(): EngineCapabilities;
  91163. /**
  91164. * Gets the current depth function
  91165. * @returns a number defining the depth function
  91166. */
  91167. getDepthFunction(): Nullable<number>;
  91168. /**
  91169. * Sets the current depth function
  91170. * @param depthFunc defines the function to use
  91171. */
  91172. setDepthFunction(depthFunc: number): void;
  91173. /**
  91174. * Sets the current depth function to GREATER
  91175. */
  91176. setDepthFunctionToGreater(): void;
  91177. /**
  91178. * Sets the current depth function to GEQUAL
  91179. */
  91180. setDepthFunctionToGreaterOrEqual(): void;
  91181. /**
  91182. * Sets the current depth function to LESS
  91183. */
  91184. setDepthFunctionToLess(): void;
  91185. private _cachedStencilBuffer;
  91186. private _cachedStencilFunction;
  91187. private _cachedStencilMask;
  91188. private _cachedStencilOperationPass;
  91189. private _cachedStencilOperationFail;
  91190. private _cachedStencilOperationDepthFail;
  91191. private _cachedStencilReference;
  91192. /**
  91193. * Caches the the state of the stencil buffer
  91194. */
  91195. cacheStencilState(): void;
  91196. /**
  91197. * Restores the state of the stencil buffer
  91198. */
  91199. restoreStencilState(): void;
  91200. /**
  91201. * Sets the current depth function to LEQUAL
  91202. */
  91203. setDepthFunctionToLessOrEqual(): void;
  91204. /**
  91205. * Gets a boolean indicating if stencil buffer is enabled
  91206. * @returns the current stencil buffer state
  91207. */
  91208. getStencilBuffer(): boolean;
  91209. /**
  91210. * Enable or disable the stencil buffer
  91211. * @param enable defines if the stencil buffer must be enabled or disabled
  91212. */
  91213. setStencilBuffer(enable: boolean): void;
  91214. /**
  91215. * Gets the current stencil mask
  91216. * @returns a number defining the new stencil mask to use
  91217. */
  91218. getStencilMask(): number;
  91219. /**
  91220. * Sets the current stencil mask
  91221. * @param mask defines the new stencil mask to use
  91222. */
  91223. setStencilMask(mask: number): void;
  91224. /**
  91225. * Gets the current stencil function
  91226. * @returns a number defining the stencil function to use
  91227. */
  91228. getStencilFunction(): number;
  91229. /**
  91230. * Gets the current stencil reference value
  91231. * @returns a number defining the stencil reference value to use
  91232. */
  91233. getStencilFunctionReference(): number;
  91234. /**
  91235. * Gets the current stencil mask
  91236. * @returns a number defining the stencil mask to use
  91237. */
  91238. getStencilFunctionMask(): number;
  91239. /**
  91240. * Sets the current stencil function
  91241. * @param stencilFunc defines the new stencil function to use
  91242. */
  91243. setStencilFunction(stencilFunc: number): void;
  91244. /**
  91245. * Sets the current stencil reference
  91246. * @param reference defines the new stencil reference to use
  91247. */
  91248. setStencilFunctionReference(reference: number): void;
  91249. /**
  91250. * Sets the current stencil mask
  91251. * @param mask defines the new stencil mask to use
  91252. */
  91253. setStencilFunctionMask(mask: number): void;
  91254. /**
  91255. * Gets the current stencil operation when stencil fails
  91256. * @returns a number defining stencil operation to use when stencil fails
  91257. */
  91258. getStencilOperationFail(): number;
  91259. /**
  91260. * Gets the current stencil operation when depth fails
  91261. * @returns a number defining stencil operation to use when depth fails
  91262. */
  91263. getStencilOperationDepthFail(): number;
  91264. /**
  91265. * Gets the current stencil operation when stencil passes
  91266. * @returns a number defining stencil operation to use when stencil passes
  91267. */
  91268. getStencilOperationPass(): number;
  91269. /**
  91270. * Sets the stencil operation to use when stencil fails
  91271. * @param operation defines the stencil operation to use when stencil fails
  91272. */
  91273. setStencilOperationFail(operation: number): void;
  91274. /**
  91275. * Sets the stencil operation to use when depth fails
  91276. * @param operation defines the stencil operation to use when depth fails
  91277. */
  91278. setStencilOperationDepthFail(operation: number): void;
  91279. /**
  91280. * Sets the stencil operation to use when stencil passes
  91281. * @param operation defines the stencil operation to use when stencil passes
  91282. */
  91283. setStencilOperationPass(operation: number): void;
  91284. /**
  91285. * Sets a boolean indicating if the dithering state is enabled or disabled
  91286. * @param value defines the dithering state
  91287. */
  91288. setDitheringState(value: boolean): void;
  91289. /**
  91290. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  91291. * @param value defines the rasterizer state
  91292. */
  91293. setRasterizerState(value: boolean): void;
  91294. /**
  91295. * stop executing a render loop function and remove it from the execution array
  91296. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  91297. */
  91298. stopRenderLoop(renderFunction?: () => void): void;
  91299. /** @hidden */
  91300. _renderLoop(): void;
  91301. /**
  91302. * Register and execute a render loop. The engine can have more than one render function
  91303. * @param renderFunction defines the function to continuously execute
  91304. */
  91305. runRenderLoop(renderFunction: () => void): void;
  91306. /**
  91307. * Toggle full screen mode
  91308. * @param requestPointerLock defines if a pointer lock should be requested from the user
  91309. */
  91310. switchFullscreen(requestPointerLock: boolean): void;
  91311. /**
  91312. * Enters full screen mode
  91313. * @param requestPointerLock defines if a pointer lock should be requested from the user
  91314. */
  91315. enterFullscreen(requestPointerLock: boolean): void;
  91316. /**
  91317. * Exits full screen mode
  91318. */
  91319. exitFullscreen(): void;
  91320. /**
  91321. * Enters Pointerlock mode
  91322. */
  91323. enterPointerlock(): void;
  91324. /**
  91325. * Exits Pointerlock mode
  91326. */
  91327. exitPointerlock(): void;
  91328. /**
  91329. * Clear the current render buffer or the current render target (if any is set up)
  91330. * @param color defines the color to use
  91331. * @param backBuffer defines if the back buffer must be cleared
  91332. * @param depth defines if the depth buffer must be cleared
  91333. * @param stencil defines if the stencil buffer must be cleared
  91334. */
  91335. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  91336. /**
  91337. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  91338. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  91339. * @param y defines the y-coordinate of the corner of the clear rectangle
  91340. * @param width defines the width of the clear rectangle
  91341. * @param height defines the height of the clear rectangle
  91342. * @param clearColor defines the clear color
  91343. */
  91344. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  91345. /**
  91346. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  91347. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  91348. * @param y defines the y-coordinate of the corner of the clear rectangle
  91349. * @param width defines the width of the clear rectangle
  91350. * @param height defines the height of the clear rectangle
  91351. */
  91352. enableScissor(x: number, y: number, width: number, height: number): void;
  91353. /**
  91354. * Disable previously set scissor test rectangle
  91355. */
  91356. disableScissor(): void;
  91357. private _viewportCached;
  91358. /** @hidden */
  91359. _viewport(x: number, y: number, width: number, height: number): void;
  91360. /**
  91361. * Set the WebGL's viewport
  91362. * @param viewport defines the viewport element to be used
  91363. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  91364. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  91365. */
  91366. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  91367. /**
  91368. * Directly set the WebGL Viewport
  91369. * @param x defines the x coordinate of the viewport (in screen space)
  91370. * @param y defines the y coordinate of the viewport (in screen space)
  91371. * @param width defines the width of the viewport (in screen space)
  91372. * @param height defines the height of the viewport (in screen space)
  91373. * @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
  91374. */
  91375. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  91376. /**
  91377. * Begin a new frame
  91378. */
  91379. beginFrame(): void;
  91380. /**
  91381. * Enf the current frame
  91382. */
  91383. endFrame(): void;
  91384. /**
  91385. * Resize the view according to the canvas' size
  91386. */
  91387. resize(): void;
  91388. /**
  91389. * Force a specific size of the canvas
  91390. * @param width defines the new canvas' width
  91391. * @param height defines the new canvas' height
  91392. */
  91393. setSize(width: number, height: number): void;
  91394. /**
  91395. * Binds the frame buffer to the specified texture.
  91396. * @param texture The texture to render to or null for the default canvas
  91397. * @param faceIndex The face of the texture to render to in case of cube texture
  91398. * @param requiredWidth The width of the target to render to
  91399. * @param requiredHeight The height of the target to render to
  91400. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  91401. * @param depthStencilTexture The depth stencil texture to use to render
  91402. * @param lodLevel defines le lod level to bind to the frame buffer
  91403. */
  91404. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  91405. /** @hidden */
  91406. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  91407. /**
  91408. * Unbind the current render target texture from the webGL context
  91409. * @param texture defines the render target texture to unbind
  91410. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  91411. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  91412. */
  91413. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  91414. /**
  91415. * Force the mipmap generation for the given render target texture
  91416. * @param texture defines the render target texture to use
  91417. */
  91418. generateMipMapsForCubemap(texture: InternalTexture): void;
  91419. /**
  91420. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  91421. */
  91422. flushFramebuffer(): void;
  91423. /**
  91424. * Unbind the current render target and bind the default framebuffer
  91425. */
  91426. restoreDefaultFramebuffer(): void;
  91427. /**
  91428. * Create an uniform buffer
  91429. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  91430. * @param elements defines the content of the uniform buffer
  91431. * @returns the webGL uniform buffer
  91432. */
  91433. createUniformBuffer(elements: FloatArray): DataBuffer;
  91434. /**
  91435. * Create a dynamic uniform buffer
  91436. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  91437. * @param elements defines the content of the uniform buffer
  91438. * @returns the webGL uniform buffer
  91439. */
  91440. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  91441. /**
  91442. * Update an existing uniform buffer
  91443. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  91444. * @param uniformBuffer defines the target uniform buffer
  91445. * @param elements defines the content to update
  91446. * @param offset defines the offset in the uniform buffer where update should start
  91447. * @param count defines the size of the data to update
  91448. */
  91449. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  91450. private _resetVertexBufferBinding;
  91451. /**
  91452. * Creates a vertex buffer
  91453. * @param data the data for the vertex buffer
  91454. * @returns the new WebGL static buffer
  91455. */
  91456. createVertexBuffer(data: DataArray): DataBuffer;
  91457. /**
  91458. * Creates a dynamic vertex buffer
  91459. * @param data the data for the dynamic vertex buffer
  91460. * @returns the new WebGL dynamic buffer
  91461. */
  91462. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  91463. /**
  91464. * Update a dynamic index buffer
  91465. * @param indexBuffer defines the target index buffer
  91466. * @param indices defines the data to update
  91467. * @param offset defines the offset in the target index buffer where update should start
  91468. */
  91469. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  91470. /**
  91471. * Updates a dynamic vertex buffer.
  91472. * @param vertexBuffer the vertex buffer to update
  91473. * @param data the data used to update the vertex buffer
  91474. * @param byteOffset the byte offset of the data
  91475. * @param byteLength the byte length of the data
  91476. */
  91477. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  91478. private _resetIndexBufferBinding;
  91479. /**
  91480. * Creates a new index buffer
  91481. * @param indices defines the content of the index buffer
  91482. * @param updatable defines if the index buffer must be updatable
  91483. * @returns a new webGL buffer
  91484. */
  91485. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  91486. /**
  91487. * Bind a webGL buffer to the webGL context
  91488. * @param buffer defines the buffer to bind
  91489. */
  91490. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  91491. /**
  91492. * Bind an uniform buffer to the current webGL context
  91493. * @param buffer defines the buffer to bind
  91494. */
  91495. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  91496. /**
  91497. * Bind a buffer to the current webGL context at a given location
  91498. * @param buffer defines the buffer to bind
  91499. * @param location defines the index where to bind the buffer
  91500. */
  91501. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  91502. /**
  91503. * Bind a specific block at a given index in a specific shader program
  91504. * @param pipelineContext defines the pipeline context to use
  91505. * @param blockName defines the block name
  91506. * @param index defines the index where to bind the block
  91507. */
  91508. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  91509. private bindIndexBuffer;
  91510. private bindBuffer;
  91511. /**
  91512. * update the bound buffer with the given data
  91513. * @param data defines the data to update
  91514. */
  91515. updateArrayBuffer(data: Float32Array): void;
  91516. private _vertexAttribPointer;
  91517. private _bindIndexBufferWithCache;
  91518. private _bindVertexBuffersAttributes;
  91519. /**
  91520. * Records a vertex array object
  91521. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  91522. * @param vertexBuffers defines the list of vertex buffers to store
  91523. * @param indexBuffer defines the index buffer to store
  91524. * @param effect defines the effect to store
  91525. * @returns the new vertex array object
  91526. */
  91527. recordVertexArrayObject(vertexBuffers: {
  91528. [key: string]: VertexBuffer;
  91529. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  91530. /**
  91531. * Bind a specific vertex array object
  91532. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  91533. * @param vertexArrayObject defines the vertex array object to bind
  91534. * @param indexBuffer defines the index buffer to bind
  91535. */
  91536. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  91537. /**
  91538. * Bind webGl buffers directly to the webGL context
  91539. * @param vertexBuffer defines the vertex buffer to bind
  91540. * @param indexBuffer defines the index buffer to bind
  91541. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  91542. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  91543. * @param effect defines the effect associated with the vertex buffer
  91544. */
  91545. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  91546. private _unbindVertexArrayObject;
  91547. /**
  91548. * Bind a list of vertex buffers to the webGL context
  91549. * @param vertexBuffers defines the list of vertex buffers to bind
  91550. * @param indexBuffer defines the index buffer to bind
  91551. * @param effect defines the effect associated with the vertex buffers
  91552. */
  91553. bindBuffers(vertexBuffers: {
  91554. [key: string]: Nullable<VertexBuffer>;
  91555. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  91556. /**
  91557. * Unbind all instance attributes
  91558. */
  91559. unbindInstanceAttributes(): void;
  91560. /**
  91561. * Release and free the memory of a vertex array object
  91562. * @param vao defines the vertex array object to delete
  91563. */
  91564. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  91565. /** @hidden */
  91566. _releaseBuffer(buffer: DataBuffer): boolean;
  91567. /**
  91568. * Creates a webGL buffer to use with instanciation
  91569. * @param capacity defines the size of the buffer
  91570. * @returns the webGL buffer
  91571. */
  91572. createInstancesBuffer(capacity: number): DataBuffer;
  91573. /**
  91574. * Delete a webGL buffer used with instanciation
  91575. * @param buffer defines the webGL buffer to delete
  91576. */
  91577. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  91578. /**
  91579. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  91580. * @param instancesBuffer defines the webGL buffer to update and bind
  91581. * @param data defines the data to store in the buffer
  91582. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  91583. */
  91584. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  91585. /**
  91586. * Apply all cached states (depth, culling, stencil and alpha)
  91587. */
  91588. applyStates(): void;
  91589. /**
  91590. * Send a draw order
  91591. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  91592. * @param indexStart defines the starting index
  91593. * @param indexCount defines the number of index to draw
  91594. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91595. */
  91596. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  91597. /**
  91598. * Draw a list of points
  91599. * @param verticesStart defines the index of first vertex to draw
  91600. * @param verticesCount defines the count of vertices to draw
  91601. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91602. */
  91603. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91604. /**
  91605. * Draw a list of unindexed primitives
  91606. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  91607. * @param verticesStart defines the index of first vertex to draw
  91608. * @param verticesCount defines the count of vertices to draw
  91609. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91610. */
  91611. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91612. /**
  91613. * Draw a list of indexed primitives
  91614. * @param fillMode defines the primitive to use
  91615. * @param indexStart defines the starting index
  91616. * @param indexCount defines the number of index to draw
  91617. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91618. */
  91619. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  91620. /**
  91621. * Draw a list of unindexed primitives
  91622. * @param fillMode defines the primitive to use
  91623. * @param verticesStart defines the index of first vertex to draw
  91624. * @param verticesCount defines the count of vertices to draw
  91625. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91626. */
  91627. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91628. private _drawMode;
  91629. /** @hidden */
  91630. _releaseEffect(effect: Effect): void;
  91631. /** @hidden */
  91632. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  91633. /**
  91634. * Create a new effect (used to store vertex/fragment shaders)
  91635. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  91636. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  91637. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  91638. * @param samplers defines an array of string used to represent textures
  91639. * @param defines defines the string containing the defines to use to compile the shaders
  91640. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  91641. * @param onCompiled defines a function to call when the effect creation is successful
  91642. * @param onError defines a function to call when the effect creation has failed
  91643. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  91644. * @returns the new Effect
  91645. */
  91646. 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;
  91647. private _compileShader;
  91648. private _compileRawShader;
  91649. /**
  91650. * Directly creates a webGL program
  91651. * @param pipelineContext defines the pipeline context to attach to
  91652. * @param vertexCode defines the vertex shader code to use
  91653. * @param fragmentCode defines the fragment shader code to use
  91654. * @param context defines the webGL context to use (if not set, the current one will be used)
  91655. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  91656. * @returns the new webGL program
  91657. */
  91658. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  91659. /**
  91660. * Creates a webGL program
  91661. * @param pipelineContext defines the pipeline context to attach to
  91662. * @param vertexCode defines the vertex shader code to use
  91663. * @param fragmentCode defines the fragment shader code to use
  91664. * @param defines defines the string containing the defines to use to compile the shaders
  91665. * @param context defines the webGL context to use (if not set, the current one will be used)
  91666. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  91667. * @returns the new webGL program
  91668. */
  91669. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  91670. /**
  91671. * Creates a new pipeline context
  91672. * @returns the new pipeline
  91673. */
  91674. createPipelineContext(): WebGLPipelineContext;
  91675. private _createShaderProgram;
  91676. private _finalizePipelineContext;
  91677. /** @hidden */
  91678. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  91679. /** @hidden */
  91680. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  91681. /** @hidden */
  91682. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  91683. /**
  91684. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  91685. * @param pipelineContext defines the pipeline context to use
  91686. * @param uniformsNames defines the list of uniform names
  91687. * @returns an array of webGL uniform locations
  91688. */
  91689. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  91690. /**
  91691. * Gets the lsit of active attributes for a given webGL program
  91692. * @param pipelineContext defines the pipeline context to use
  91693. * @param attributesNames defines the list of attribute names to get
  91694. * @returns an array of indices indicating the offset of each attribute
  91695. */
  91696. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  91697. /**
  91698. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  91699. * @param effect defines the effect to activate
  91700. */
  91701. enableEffect(effect: Nullable<Effect>): void;
  91702. /**
  91703. * Set the value of an uniform to an array of int32
  91704. * @param uniform defines the webGL uniform location where to store the value
  91705. * @param array defines the array of int32 to store
  91706. */
  91707. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91708. /**
  91709. * Set the value of an uniform to an array of int32 (stored as vec2)
  91710. * @param uniform defines the webGL uniform location where to store the value
  91711. * @param array defines the array of int32 to store
  91712. */
  91713. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91714. /**
  91715. * Set the value of an uniform to an array of int32 (stored as vec3)
  91716. * @param uniform defines the webGL uniform location where to store the value
  91717. * @param array defines the array of int32 to store
  91718. */
  91719. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91720. /**
  91721. * Set the value of an uniform to an array of int32 (stored as vec4)
  91722. * @param uniform defines the webGL uniform location where to store the value
  91723. * @param array defines the array of int32 to store
  91724. */
  91725. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91726. /**
  91727. * Set the value of an uniform to an array of float32
  91728. * @param uniform defines the webGL uniform location where to store the value
  91729. * @param array defines the array of float32 to store
  91730. */
  91731. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91732. /**
  91733. * Set the value of an uniform to an array of float32 (stored as vec2)
  91734. * @param uniform defines the webGL uniform location where to store the value
  91735. * @param array defines the array of float32 to store
  91736. */
  91737. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91738. /**
  91739. * Set the value of an uniform to an array of float32 (stored as vec3)
  91740. * @param uniform defines the webGL uniform location where to store the value
  91741. * @param array defines the array of float32 to store
  91742. */
  91743. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91744. /**
  91745. * Set the value of an uniform to an array of float32 (stored as vec4)
  91746. * @param uniform defines the webGL uniform location where to store the value
  91747. * @param array defines the array of float32 to store
  91748. */
  91749. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91750. /**
  91751. * Set the value of an uniform to an array of number
  91752. * @param uniform defines the webGL uniform location where to store the value
  91753. * @param array defines the array of number to store
  91754. */
  91755. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91756. /**
  91757. * Set the value of an uniform to an array of number (stored as vec2)
  91758. * @param uniform defines the webGL uniform location where to store the value
  91759. * @param array defines the array of number to store
  91760. */
  91761. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91762. /**
  91763. * Set the value of an uniform to an array of number (stored as vec3)
  91764. * @param uniform defines the webGL uniform location where to store the value
  91765. * @param array defines the array of number to store
  91766. */
  91767. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91768. /**
  91769. * Set the value of an uniform to an array of number (stored as vec4)
  91770. * @param uniform defines the webGL uniform location where to store the value
  91771. * @param array defines the array of number to store
  91772. */
  91773. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91774. /**
  91775. * Set the value of an uniform to an array of float32 (stored as matrices)
  91776. * @param uniform defines the webGL uniform location where to store the value
  91777. * @param matrices defines the array of float32 to store
  91778. */
  91779. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  91780. /**
  91781. * Set the value of an uniform to a matrix
  91782. * @param uniform defines the webGL uniform location where to store the value
  91783. * @param matrix defines the matrix to store
  91784. */
  91785. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  91786. /**
  91787. * Set the value of an uniform to a matrix (3x3)
  91788. * @param uniform defines the webGL uniform location where to store the value
  91789. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  91790. */
  91791. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  91792. /**
  91793. * Set the value of an uniform to a matrix (2x2)
  91794. * @param uniform defines the webGL uniform location where to store the value
  91795. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  91796. */
  91797. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  91798. /**
  91799. * Set the value of an uniform to a number (int)
  91800. * @param uniform defines the webGL uniform location where to store the value
  91801. * @param value defines the int number to store
  91802. */
  91803. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  91804. /**
  91805. * Set the value of an uniform to a number (float)
  91806. * @param uniform defines the webGL uniform location where to store the value
  91807. * @param value defines the float number to store
  91808. */
  91809. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  91810. /**
  91811. * Set the value of an uniform to a vec2
  91812. * @param uniform defines the webGL uniform location where to store the value
  91813. * @param x defines the 1st component of the value
  91814. * @param y defines the 2nd component of the value
  91815. */
  91816. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  91817. /**
  91818. * Set the value of an uniform to a vec3
  91819. * @param uniform defines the webGL uniform location where to store the value
  91820. * @param x defines the 1st component of the value
  91821. * @param y defines the 2nd component of the value
  91822. * @param z defines the 3rd component of the value
  91823. */
  91824. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  91825. /**
  91826. * Set the value of an uniform to a boolean
  91827. * @param uniform defines the webGL uniform location where to store the value
  91828. * @param bool defines the boolean to store
  91829. */
  91830. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  91831. /**
  91832. * Set the value of an uniform to a vec4
  91833. * @param uniform defines the webGL uniform location where to store the value
  91834. * @param x defines the 1st component of the value
  91835. * @param y defines the 2nd component of the value
  91836. * @param z defines the 3rd component of the value
  91837. * @param w defines the 4th component of the value
  91838. */
  91839. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  91840. /**
  91841. * Set the value of an uniform to a Color3
  91842. * @param uniform defines the webGL uniform location where to store the value
  91843. * @param color3 defines the color to store
  91844. */
  91845. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  91846. /**
  91847. * Set the value of an uniform to a Color3 and an alpha value
  91848. * @param uniform defines the webGL uniform location where to store the value
  91849. * @param color3 defines the color to store
  91850. * @param alpha defines the alpha component to store
  91851. */
  91852. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  91853. /**
  91854. * Sets a Color4 on a uniform variable
  91855. * @param uniform defines the uniform location
  91856. * @param color4 defines the value to be set
  91857. */
  91858. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  91859. /**
  91860. * Set various states to the webGL context
  91861. * @param culling defines backface culling state
  91862. * @param zOffset defines the value to apply to zOffset (0 by default)
  91863. * @param force defines if states must be applied even if cache is up to date
  91864. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  91865. */
  91866. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  91867. /**
  91868. * Set the z offset to apply to current rendering
  91869. * @param value defines the offset to apply
  91870. */
  91871. setZOffset(value: number): void;
  91872. /**
  91873. * Gets the current value of the zOffset
  91874. * @returns the current zOffset state
  91875. */
  91876. getZOffset(): number;
  91877. /**
  91878. * Enable or disable depth buffering
  91879. * @param enable defines the state to set
  91880. */
  91881. setDepthBuffer(enable: boolean): void;
  91882. /**
  91883. * Gets a boolean indicating if depth writing is enabled
  91884. * @returns the current depth writing state
  91885. */
  91886. getDepthWrite(): boolean;
  91887. /**
  91888. * Enable or disable depth writing
  91889. * @param enable defines the state to set
  91890. */
  91891. setDepthWrite(enable: boolean): void;
  91892. /**
  91893. * Enable or disable color writing
  91894. * @param enable defines the state to set
  91895. */
  91896. setColorWrite(enable: boolean): void;
  91897. /**
  91898. * Gets a boolean indicating if color writing is enabled
  91899. * @returns the current color writing state
  91900. */
  91901. getColorWrite(): boolean;
  91902. /**
  91903. * Sets alpha constants used by some alpha blending modes
  91904. * @param r defines the red component
  91905. * @param g defines the green component
  91906. * @param b defines the blue component
  91907. * @param a defines the alpha component
  91908. */
  91909. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  91910. /**
  91911. * Sets the current alpha mode
  91912. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  91913. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  91914. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91915. */
  91916. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  91917. /**
  91918. * Gets the current alpha mode
  91919. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91920. * @returns the current alpha mode
  91921. */
  91922. getAlphaMode(): number;
  91923. /**
  91924. * Clears the list of texture accessible through engine.
  91925. * This can help preventing texture load conflict due to name collision.
  91926. */
  91927. clearInternalTexturesCache(): void;
  91928. /**
  91929. * Force the entire cache to be cleared
  91930. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  91931. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  91932. */
  91933. wipeCaches(bruteForce?: boolean): void;
  91934. /**
  91935. * Set the compressed texture format to use, based on the formats you have, and the formats
  91936. * supported by the hardware / browser.
  91937. *
  91938. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  91939. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  91940. * to API arguments needed to compressed textures. This puts the burden on the container
  91941. * generator to house the arcane code for determining these for current & future formats.
  91942. *
  91943. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  91944. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  91945. *
  91946. * Note: The result of this call is not taken into account when a texture is base64.
  91947. *
  91948. * @param formatsAvailable defines the list of those format families you have created
  91949. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  91950. *
  91951. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  91952. * @returns The extension selected.
  91953. */
  91954. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  91955. /** @hidden */
  91956. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  91957. min: number;
  91958. mag: number;
  91959. };
  91960. /** @hidden */
  91961. _createTexture(): WebGLTexture;
  91962. /**
  91963. * Usually called from Texture.ts.
  91964. * Passed information to create a WebGLTexture
  91965. * @param urlArg defines a value which contains one of the following:
  91966. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  91967. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  91968. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  91969. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  91970. * @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)
  91971. * @param scene needed for loading to the correct scene
  91972. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  91973. * @param onLoad optional callback to be called upon successful completion
  91974. * @param onError optional callback to be called upon failure
  91975. * @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
  91976. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  91977. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  91978. * @param forcedExtension defines the extension to use to pick the right loader
  91979. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  91980. * @returns a InternalTexture for assignment back into BABYLON.Texture
  91981. */
  91982. 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;
  91983. /**
  91984. * @hidden
  91985. * Rescales a texture
  91986. * @param source input texutre
  91987. * @param destination destination texture
  91988. * @param scene scene to use to render the resize
  91989. * @param internalFormat format to use when resizing
  91990. * @param onComplete callback to be called when resize has completed
  91991. */
  91992. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  91993. private _unpackFlipYCached;
  91994. /**
  91995. * In case you are sharing the context with other applications, it might
  91996. * be interested to not cache the unpack flip y state to ensure a consistent
  91997. * value would be set.
  91998. */
  91999. enableUnpackFlipYCached: boolean;
  92000. /** @hidden */
  92001. _unpackFlipY(value: boolean): void;
  92002. /** @hidden */
  92003. _getUnpackAlignement(): number;
  92004. /**
  92005. * Creates a dynamic texture
  92006. * @param width defines the width of the texture
  92007. * @param height defines the height of the texture
  92008. * @param generateMipMaps defines if the engine should generate the mip levels
  92009. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  92010. * @returns the dynamic texture inside an InternalTexture
  92011. */
  92012. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  92013. /**
  92014. * Update the sampling mode of a given texture
  92015. * @param samplingMode defines the required sampling mode
  92016. * @param texture defines the texture to update
  92017. */
  92018. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  92019. /**
  92020. * Update the content of a dynamic texture
  92021. * @param texture defines the texture to update
  92022. * @param canvas defines the canvas containing the source
  92023. * @param invertY defines if data must be stored with Y axis inverted
  92024. * @param premulAlpha defines if alpha is stored as premultiplied
  92025. * @param format defines the format of the data
  92026. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  92027. */
  92028. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  92029. /**
  92030. * Update a video texture
  92031. * @param texture defines the texture to update
  92032. * @param video defines the video element to use
  92033. * @param invertY defines if data must be stored with Y axis inverted
  92034. */
  92035. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  92036. /**
  92037. * Updates a depth texture Comparison Mode and Function.
  92038. * If the comparison Function is equal to 0, the mode will be set to none.
  92039. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  92040. * @param texture The texture to set the comparison function for
  92041. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  92042. */
  92043. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  92044. /** @hidden */
  92045. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  92046. width: number;
  92047. height: number;
  92048. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  92049. /**
  92050. * Creates a depth stencil texture.
  92051. * This is only available in WebGL 2 or with the depth texture extension available.
  92052. * @param size The size of face edge in the texture.
  92053. * @param options The options defining the texture.
  92054. * @returns The texture
  92055. */
  92056. createDepthStencilTexture(size: number | {
  92057. width: number;
  92058. height: number;
  92059. }, options: DepthTextureCreationOptions): InternalTexture;
  92060. /**
  92061. * Creates a depth stencil texture.
  92062. * This is only available in WebGL 2 or with the depth texture extension available.
  92063. * @param size The size of face edge in the texture.
  92064. * @param options The options defining the texture.
  92065. * @returns The texture
  92066. */
  92067. private _createDepthStencilTexture;
  92068. /**
  92069. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  92070. * @param renderTarget The render target to set the frame buffer for
  92071. */
  92072. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  92073. /**
  92074. * Creates a new render target texture
  92075. * @param size defines the size of the texture
  92076. * @param options defines the options used to create the texture
  92077. * @returns a new render target texture stored in an InternalTexture
  92078. */
  92079. createRenderTargetTexture(size: number | {
  92080. width: number;
  92081. height: number;
  92082. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  92083. /** @hidden */
  92084. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  92085. /**
  92086. * Updates the sample count of a render target texture
  92087. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  92088. * @param texture defines the texture to update
  92089. * @param samples defines the sample count to set
  92090. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  92091. */
  92092. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  92093. /** @hidden */
  92094. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  92095. /** @hidden */
  92096. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  92097. /** @hidden */
  92098. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  92099. /** @hidden */
  92100. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  92101. /**
  92102. * @hidden
  92103. */
  92104. _setCubeMapTextureParams(loadMipmap: boolean): void;
  92105. private _prepareWebGLTextureContinuation;
  92106. private _prepareWebGLTexture;
  92107. /** @hidden */
  92108. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  92109. /** @hidden */
  92110. _releaseFramebufferObjects(texture: InternalTexture): void;
  92111. /** @hidden */
  92112. _releaseTexture(texture: InternalTexture): void;
  92113. private setProgram;
  92114. private _boundUniforms;
  92115. /**
  92116. * Binds an effect to the webGL context
  92117. * @param effect defines the effect to bind
  92118. */
  92119. bindSamplers(effect: Effect): void;
  92120. private _activateCurrentTexture;
  92121. /** @hidden */
  92122. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  92123. /** @hidden */
  92124. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  92125. /**
  92126. * Sets a texture to the webGL context from a postprocess
  92127. * @param channel defines the channel to use
  92128. * @param postProcess defines the source postprocess
  92129. */
  92130. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  92131. /**
  92132. * Binds the output of the passed in post process to the texture channel specified
  92133. * @param channel The channel the texture should be bound to
  92134. * @param postProcess The post process which's output should be bound
  92135. */
  92136. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  92137. /**
  92138. * Unbind all textures from the webGL context
  92139. */
  92140. unbindAllTextures(): void;
  92141. /**
  92142. * Sets a texture to the according uniform.
  92143. * @param channel The texture channel
  92144. * @param uniform The uniform to set
  92145. * @param texture The texture to apply
  92146. */
  92147. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  92148. /**
  92149. * Sets a depth stencil texture from a render target to the according uniform.
  92150. * @param channel The texture channel
  92151. * @param uniform The uniform to set
  92152. * @param texture The render target texture containing the depth stencil texture to apply
  92153. */
  92154. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  92155. private _bindSamplerUniformToChannel;
  92156. private _getTextureWrapMode;
  92157. private _setTexture;
  92158. /**
  92159. * Sets an array of texture to the webGL context
  92160. * @param channel defines the channel where the texture array must be set
  92161. * @param uniform defines the associated uniform location
  92162. * @param textures defines the array of textures to bind
  92163. */
  92164. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  92165. /** @hidden */
  92166. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  92167. private _setTextureParameterFloat;
  92168. private _setTextureParameterInteger;
  92169. /**
  92170. * Reads pixels from the current frame buffer. Please note that this function can be slow
  92171. * @param x defines the x coordinate of the rectangle where pixels must be read
  92172. * @param y defines the y coordinate of the rectangle where pixels must be read
  92173. * @param width defines the width of the rectangle where pixels must be read
  92174. * @param height defines the height of the rectangle where pixels must be read
  92175. * @returns a Uint8Array containing RGBA colors
  92176. */
  92177. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  92178. /**
  92179. * Add an externaly attached data from its key.
  92180. * This method call will fail and return false, if such key already exists.
  92181. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  92182. * @param key the unique key that identifies the data
  92183. * @param data the data object to associate to the key for this Engine instance
  92184. * @return true if no such key were already present and the data was added successfully, false otherwise
  92185. */
  92186. addExternalData<T>(key: string, data: T): boolean;
  92187. /**
  92188. * Get an externaly attached data from its key
  92189. * @param key the unique key that identifies the data
  92190. * @return the associated data, if present (can be null), or undefined if not present
  92191. */
  92192. getExternalData<T>(key: string): T;
  92193. /**
  92194. * Get an externaly attached data from its key, create it using a factory if it's not already present
  92195. * @param key the unique key that identifies the data
  92196. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  92197. * @return the associated data, can be null if the factory returned null.
  92198. */
  92199. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  92200. /**
  92201. * Remove an externaly attached data from the Engine instance
  92202. * @param key the unique key that identifies the data
  92203. * @return true if the data was successfully removed, false if it doesn't exist
  92204. */
  92205. removeExternalData(key: string): boolean;
  92206. /**
  92207. * Unbind all vertex attributes from the webGL context
  92208. */
  92209. unbindAllAttributes(): void;
  92210. /**
  92211. * 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
  92212. */
  92213. releaseEffects(): void;
  92214. /**
  92215. * Dispose and release all associated resources
  92216. */
  92217. dispose(): void;
  92218. /**
  92219. * Display the loading screen
  92220. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92221. */
  92222. displayLoadingUI(): void;
  92223. /**
  92224. * Hide the loading screen
  92225. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92226. */
  92227. hideLoadingUI(): void;
  92228. /**
  92229. * Gets the current loading screen object
  92230. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92231. */
  92232. /**
  92233. * Sets the current loading screen object
  92234. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92235. */
  92236. loadingScreen: ILoadingScreen;
  92237. /**
  92238. * Sets the current loading screen text
  92239. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92240. */
  92241. loadingUIText: string;
  92242. /**
  92243. * Sets the current loading screen background color
  92244. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92245. */
  92246. loadingUIBackgroundColor: string;
  92247. /**
  92248. * Attach a new callback raised when context lost event is fired
  92249. * @param callback defines the callback to call
  92250. */
  92251. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  92252. /**
  92253. * Attach a new callback raised when context restored event is fired
  92254. * @param callback defines the callback to call
  92255. */
  92256. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  92257. /**
  92258. * Gets the source code of the vertex shader associated with a specific webGL program
  92259. * @param program defines the program to use
  92260. * @returns a string containing the source code of the vertex shader associated with the program
  92261. */
  92262. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  92263. /**
  92264. * Gets the source code of the fragment shader associated with a specific webGL program
  92265. * @param program defines the program to use
  92266. * @returns a string containing the source code of the fragment shader associated with the program
  92267. */
  92268. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  92269. /**
  92270. * Get the current error code of the webGL context
  92271. * @returns the error code
  92272. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  92273. */
  92274. getError(): number;
  92275. /**
  92276. * Gets the current framerate
  92277. * @returns a number representing the framerate
  92278. */
  92279. getFps(): number;
  92280. /**
  92281. * Gets the time spent between current and previous frame
  92282. * @returns a number representing the delta time in ms
  92283. */
  92284. getDeltaTime(): number;
  92285. private _measureFps;
  92286. /** @hidden */
  92287. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  92288. private _canRenderToFloatFramebuffer;
  92289. private _canRenderToHalfFloatFramebuffer;
  92290. private _canRenderToFramebuffer;
  92291. /** @hidden */
  92292. _getWebGLTextureType(type: number): number;
  92293. /** @hidden */
  92294. _getInternalFormat(format: number): number;
  92295. /** @hidden */
  92296. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  92297. /** @hidden */
  92298. _getRGBAMultiSampleBufferFormat(type: number): number;
  92299. /** @hidden */
  92300. _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;
  92301. /** @hidden */
  92302. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  92303. /**
  92304. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  92305. * @returns true if the engine can be created
  92306. * @ignorenaming
  92307. */
  92308. static isSupported(): boolean;
  92309. }
  92310. }
  92311. declare module BABYLON {
  92312. /**
  92313. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  92314. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  92315. */
  92316. export class EffectFallbacks {
  92317. private _defines;
  92318. private _currentRank;
  92319. private _maxRank;
  92320. private _mesh;
  92321. /**
  92322. * Removes the fallback from the bound mesh.
  92323. */
  92324. unBindMesh(): void;
  92325. /**
  92326. * Adds a fallback on the specified property.
  92327. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  92328. * @param define The name of the define in the shader
  92329. */
  92330. addFallback(rank: number, define: string): void;
  92331. /**
  92332. * Sets the mesh to use CPU skinning when needing to fallback.
  92333. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  92334. * @param mesh The mesh to use the fallbacks.
  92335. */
  92336. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  92337. /**
  92338. * Checks to see if more fallbacks are still availible.
  92339. */
  92340. readonly isMoreFallbacks: boolean;
  92341. /**
  92342. * Removes the defines that should be removed when falling back.
  92343. * @param currentDefines defines the current define statements for the shader.
  92344. * @param effect defines the current effect we try to compile
  92345. * @returns The resulting defines with defines of the current rank removed.
  92346. */
  92347. reduce(currentDefines: string, effect: Effect): string;
  92348. }
  92349. /**
  92350. * Options to be used when creating an effect.
  92351. */
  92352. export class EffectCreationOptions {
  92353. /**
  92354. * Atrributes that will be used in the shader.
  92355. */
  92356. attributes: string[];
  92357. /**
  92358. * Uniform varible names that will be set in the shader.
  92359. */
  92360. uniformsNames: string[];
  92361. /**
  92362. * Uniform buffer varible names that will be set in the shader.
  92363. */
  92364. uniformBuffersNames: string[];
  92365. /**
  92366. * Sampler texture variable names that will be set in the shader.
  92367. */
  92368. samplers: string[];
  92369. /**
  92370. * Define statements that will be set in the shader.
  92371. */
  92372. defines: any;
  92373. /**
  92374. * Possible fallbacks for this effect to improve performance when needed.
  92375. */
  92376. fallbacks: Nullable<EffectFallbacks>;
  92377. /**
  92378. * Callback that will be called when the shader is compiled.
  92379. */
  92380. onCompiled: Nullable<(effect: Effect) => void>;
  92381. /**
  92382. * Callback that will be called if an error occurs during shader compilation.
  92383. */
  92384. onError: Nullable<(effect: Effect, errors: string) => void>;
  92385. /**
  92386. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92387. */
  92388. indexParameters: any;
  92389. /**
  92390. * Max number of lights that can be used in the shader.
  92391. */
  92392. maxSimultaneousLights: number;
  92393. /**
  92394. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  92395. */
  92396. transformFeedbackVaryings: Nullable<string[]>;
  92397. }
  92398. /**
  92399. * Effect containing vertex and fragment shader that can be executed on an object.
  92400. */
  92401. export class Effect implements IDisposable {
  92402. /**
  92403. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  92404. */
  92405. static ShadersRepository: string;
  92406. /**
  92407. * Name of the effect.
  92408. */
  92409. name: any;
  92410. /**
  92411. * String container all the define statements that should be set on the shader.
  92412. */
  92413. defines: string;
  92414. /**
  92415. * Callback that will be called when the shader is compiled.
  92416. */
  92417. onCompiled: Nullable<(effect: Effect) => void>;
  92418. /**
  92419. * Callback that will be called if an error occurs during shader compilation.
  92420. */
  92421. onError: Nullable<(effect: Effect, errors: string) => void>;
  92422. /**
  92423. * Callback that will be called when effect is bound.
  92424. */
  92425. onBind: Nullable<(effect: Effect) => void>;
  92426. /**
  92427. * Unique ID of the effect.
  92428. */
  92429. uniqueId: number;
  92430. /**
  92431. * Observable that will be called when the shader is compiled.
  92432. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  92433. */
  92434. onCompileObservable: Observable<Effect>;
  92435. /**
  92436. * Observable that will be called if an error occurs during shader compilation.
  92437. */
  92438. onErrorObservable: Observable<Effect>;
  92439. /** @hidden */
  92440. _onBindObservable: Nullable<Observable<Effect>>;
  92441. /**
  92442. * Observable that will be called when effect is bound.
  92443. */
  92444. readonly onBindObservable: Observable<Effect>;
  92445. /** @hidden */
  92446. _bonesComputationForcedToCPU: boolean;
  92447. private static _uniqueIdSeed;
  92448. private _engine;
  92449. private _uniformBuffersNames;
  92450. private _uniformsNames;
  92451. private _samplerList;
  92452. private _samplers;
  92453. private _isReady;
  92454. private _compilationError;
  92455. private _attributesNames;
  92456. private _attributes;
  92457. private _uniforms;
  92458. /**
  92459. * Key for the effect.
  92460. * @hidden
  92461. */
  92462. _key: string;
  92463. private _indexParameters;
  92464. private _fallbacks;
  92465. private _vertexSourceCode;
  92466. private _fragmentSourceCode;
  92467. private _vertexSourceCodeOverride;
  92468. private _fragmentSourceCodeOverride;
  92469. private _transformFeedbackVaryings;
  92470. /**
  92471. * Compiled shader to webGL program.
  92472. * @hidden
  92473. */
  92474. _pipelineContext: Nullable<IPipelineContext>;
  92475. private _valueCache;
  92476. private static _baseCache;
  92477. /**
  92478. * Instantiates an effect.
  92479. * An effect can be used to create/manage/execute vertex and fragment shaders.
  92480. * @param baseName Name of the effect.
  92481. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  92482. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  92483. * @param samplers List of sampler variables that will be passed to the shader.
  92484. * @param engine Engine to be used to render the effect
  92485. * @param defines Define statements to be added to the shader.
  92486. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  92487. * @param onCompiled Callback that will be called when the shader is compiled.
  92488. * @param onError Callback that will be called if an error occurs during shader compilation.
  92489. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92490. */
  92491. 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);
  92492. private _useFinalCode;
  92493. /**
  92494. * Unique key for this effect
  92495. */
  92496. readonly key: string;
  92497. /**
  92498. * If the effect has been compiled and prepared.
  92499. * @returns if the effect is compiled and prepared.
  92500. */
  92501. isReady(): boolean;
  92502. /**
  92503. * The engine the effect was initialized with.
  92504. * @returns the engine.
  92505. */
  92506. getEngine(): Engine;
  92507. /**
  92508. * The pipeline context for this effect
  92509. * @returns the associated pipeline context
  92510. */
  92511. getPipelineContext(): Nullable<IPipelineContext>;
  92512. /**
  92513. * The set of names of attribute variables for the shader.
  92514. * @returns An array of attribute names.
  92515. */
  92516. getAttributesNames(): string[];
  92517. /**
  92518. * Returns the attribute at the given index.
  92519. * @param index The index of the attribute.
  92520. * @returns The location of the attribute.
  92521. */
  92522. getAttributeLocation(index: number): number;
  92523. /**
  92524. * Returns the attribute based on the name of the variable.
  92525. * @param name of the attribute to look up.
  92526. * @returns the attribute location.
  92527. */
  92528. getAttributeLocationByName(name: string): number;
  92529. /**
  92530. * The number of attributes.
  92531. * @returns the numnber of attributes.
  92532. */
  92533. getAttributesCount(): number;
  92534. /**
  92535. * Gets the index of a uniform variable.
  92536. * @param uniformName of the uniform to look up.
  92537. * @returns the index.
  92538. */
  92539. getUniformIndex(uniformName: string): number;
  92540. /**
  92541. * Returns the attribute based on the name of the variable.
  92542. * @param uniformName of the uniform to look up.
  92543. * @returns the location of the uniform.
  92544. */
  92545. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  92546. /**
  92547. * Returns an array of sampler variable names
  92548. * @returns The array of sampler variable neames.
  92549. */
  92550. getSamplers(): string[];
  92551. /**
  92552. * The error from the last compilation.
  92553. * @returns the error string.
  92554. */
  92555. getCompilationError(): string;
  92556. /**
  92557. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  92558. * @param func The callback to be used.
  92559. */
  92560. executeWhenCompiled(func: (effect: Effect) => void): void;
  92561. private _checkIsReady;
  92562. /** @hidden */
  92563. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  92564. /** @hidden */
  92565. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  92566. /** @hidden */
  92567. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  92568. /**
  92569. * Recompiles the webGL program
  92570. * @param vertexSourceCode The source code for the vertex shader.
  92571. * @param fragmentSourceCode The source code for the fragment shader.
  92572. * @param onCompiled Callback called when completed.
  92573. * @param onError Callback called on error.
  92574. * @hidden
  92575. */
  92576. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  92577. /**
  92578. * Prepares the effect
  92579. * @hidden
  92580. */
  92581. _prepareEffect(): void;
  92582. /**
  92583. * Checks if the effect is supported. (Must be called after compilation)
  92584. */
  92585. readonly isSupported: boolean;
  92586. /**
  92587. * Binds a texture to the engine to be used as output of the shader.
  92588. * @param channel Name of the output variable.
  92589. * @param texture Texture to bind.
  92590. * @hidden
  92591. */
  92592. _bindTexture(channel: string, texture: InternalTexture): void;
  92593. /**
  92594. * Sets a texture on the engine to be used in the shader.
  92595. * @param channel Name of the sampler variable.
  92596. * @param texture Texture to set.
  92597. */
  92598. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  92599. /**
  92600. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  92601. * @param channel Name of the sampler variable.
  92602. * @param texture Texture to set.
  92603. */
  92604. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  92605. /**
  92606. * Sets an array of textures on the engine to be used in the shader.
  92607. * @param channel Name of the variable.
  92608. * @param textures Textures to set.
  92609. */
  92610. setTextureArray(channel: string, textures: BaseTexture[]): void;
  92611. /**
  92612. * 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)
  92613. * @param channel Name of the sampler variable.
  92614. * @param postProcess Post process to get the input texture from.
  92615. */
  92616. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  92617. /**
  92618. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  92619. * 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)
  92620. * @param channel Name of the sampler variable.
  92621. * @param postProcess Post process to get the output texture from.
  92622. */
  92623. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  92624. /** @hidden */
  92625. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  92626. /** @hidden */
  92627. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  92628. /** @hidden */
  92629. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  92630. /** @hidden */
  92631. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  92632. /**
  92633. * Binds a buffer to a uniform.
  92634. * @param buffer Buffer to bind.
  92635. * @param name Name of the uniform variable to bind to.
  92636. */
  92637. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  92638. /**
  92639. * Binds block to a uniform.
  92640. * @param blockName Name of the block to bind.
  92641. * @param index Index to bind.
  92642. */
  92643. bindUniformBlock(blockName: string, index: number): void;
  92644. /**
  92645. * Sets an interger value on a uniform variable.
  92646. * @param uniformName Name of the variable.
  92647. * @param value Value to be set.
  92648. * @returns this effect.
  92649. */
  92650. setInt(uniformName: string, value: number): Effect;
  92651. /**
  92652. * Sets an int array on a uniform variable.
  92653. * @param uniformName Name of the variable.
  92654. * @param array array to be set.
  92655. * @returns this effect.
  92656. */
  92657. setIntArray(uniformName: string, array: Int32Array): Effect;
  92658. /**
  92659. * 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)
  92660. * @param uniformName Name of the variable.
  92661. * @param array array to be set.
  92662. * @returns this effect.
  92663. */
  92664. setIntArray2(uniformName: string, array: Int32Array): Effect;
  92665. /**
  92666. * 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)
  92667. * @param uniformName Name of the variable.
  92668. * @param array array to be set.
  92669. * @returns this effect.
  92670. */
  92671. setIntArray3(uniformName: string, array: Int32Array): Effect;
  92672. /**
  92673. * 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)
  92674. * @param uniformName Name of the variable.
  92675. * @param array array to be set.
  92676. * @returns this effect.
  92677. */
  92678. setIntArray4(uniformName: string, array: Int32Array): Effect;
  92679. /**
  92680. * Sets an float array on a uniform variable.
  92681. * @param uniformName Name of the variable.
  92682. * @param array array to be set.
  92683. * @returns this effect.
  92684. */
  92685. setFloatArray(uniformName: string, array: Float32Array): Effect;
  92686. /**
  92687. * 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)
  92688. * @param uniformName Name of the variable.
  92689. * @param array array to be set.
  92690. * @returns this effect.
  92691. */
  92692. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  92693. /**
  92694. * 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)
  92695. * @param uniformName Name of the variable.
  92696. * @param array array to be set.
  92697. * @returns this effect.
  92698. */
  92699. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  92700. /**
  92701. * 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)
  92702. * @param uniformName Name of the variable.
  92703. * @param array array to be set.
  92704. * @returns this effect.
  92705. */
  92706. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  92707. /**
  92708. * Sets an array on a uniform variable.
  92709. * @param uniformName Name of the variable.
  92710. * @param array array to be set.
  92711. * @returns this effect.
  92712. */
  92713. setArray(uniformName: string, array: number[]): Effect;
  92714. /**
  92715. * 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)
  92716. * @param uniformName Name of the variable.
  92717. * @param array array to be set.
  92718. * @returns this effect.
  92719. */
  92720. setArray2(uniformName: string, array: number[]): Effect;
  92721. /**
  92722. * 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)
  92723. * @param uniformName Name of the variable.
  92724. * @param array array to be set.
  92725. * @returns this effect.
  92726. */
  92727. setArray3(uniformName: string, array: number[]): Effect;
  92728. /**
  92729. * 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)
  92730. * @param uniformName Name of the variable.
  92731. * @param array array to be set.
  92732. * @returns this effect.
  92733. */
  92734. setArray4(uniformName: string, array: number[]): Effect;
  92735. /**
  92736. * Sets matrices on a uniform variable.
  92737. * @param uniformName Name of the variable.
  92738. * @param matrices matrices to be set.
  92739. * @returns this effect.
  92740. */
  92741. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  92742. /**
  92743. * Sets matrix on a uniform variable.
  92744. * @param uniformName Name of the variable.
  92745. * @param matrix matrix to be set.
  92746. * @returns this effect.
  92747. */
  92748. setMatrix(uniformName: string, matrix: Matrix): Effect;
  92749. /**
  92750. * 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)
  92751. * @param uniformName Name of the variable.
  92752. * @param matrix matrix to be set.
  92753. * @returns this effect.
  92754. */
  92755. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  92756. /**
  92757. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  92758. * @param uniformName Name of the variable.
  92759. * @param matrix matrix to be set.
  92760. * @returns this effect.
  92761. */
  92762. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  92763. /**
  92764. * Sets a float on a uniform variable.
  92765. * @param uniformName Name of the variable.
  92766. * @param value value to be set.
  92767. * @returns this effect.
  92768. */
  92769. setFloat(uniformName: string, value: number): Effect;
  92770. /**
  92771. * Sets a boolean on a uniform variable.
  92772. * @param uniformName Name of the variable.
  92773. * @param bool value to be set.
  92774. * @returns this effect.
  92775. */
  92776. setBool(uniformName: string, bool: boolean): Effect;
  92777. /**
  92778. * Sets a Vector2 on a uniform variable.
  92779. * @param uniformName Name of the variable.
  92780. * @param vector2 vector2 to be set.
  92781. * @returns this effect.
  92782. */
  92783. setVector2(uniformName: string, vector2: Vector2): Effect;
  92784. /**
  92785. * Sets a float2 on a uniform variable.
  92786. * @param uniformName Name of the variable.
  92787. * @param x First float in float2.
  92788. * @param y Second float in float2.
  92789. * @returns this effect.
  92790. */
  92791. setFloat2(uniformName: string, x: number, y: number): Effect;
  92792. /**
  92793. * Sets a Vector3 on a uniform variable.
  92794. * @param uniformName Name of the variable.
  92795. * @param vector3 Value to be set.
  92796. * @returns this effect.
  92797. */
  92798. setVector3(uniformName: string, vector3: Vector3): Effect;
  92799. /**
  92800. * Sets a float3 on a uniform variable.
  92801. * @param uniformName Name of the variable.
  92802. * @param x First float in float3.
  92803. * @param y Second float in float3.
  92804. * @param z Third float in float3.
  92805. * @returns this effect.
  92806. */
  92807. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  92808. /**
  92809. * Sets a Vector4 on a uniform variable.
  92810. * @param uniformName Name of the variable.
  92811. * @param vector4 Value to be set.
  92812. * @returns this effect.
  92813. */
  92814. setVector4(uniformName: string, vector4: Vector4): Effect;
  92815. /**
  92816. * Sets a float4 on a uniform variable.
  92817. * @param uniformName Name of the variable.
  92818. * @param x First float in float4.
  92819. * @param y Second float in float4.
  92820. * @param z Third float in float4.
  92821. * @param w Fourth float in float4.
  92822. * @returns this effect.
  92823. */
  92824. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  92825. /**
  92826. * Sets a Color3 on a uniform variable.
  92827. * @param uniformName Name of the variable.
  92828. * @param color3 Value to be set.
  92829. * @returns this effect.
  92830. */
  92831. setColor3(uniformName: string, color3: Color3): Effect;
  92832. /**
  92833. * Sets a Color4 on a uniform variable.
  92834. * @param uniformName Name of the variable.
  92835. * @param color3 Value to be set.
  92836. * @param alpha Alpha value to be set.
  92837. * @returns this effect.
  92838. */
  92839. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  92840. /**
  92841. * Sets a Color4 on a uniform variable
  92842. * @param uniformName defines the name of the variable
  92843. * @param color4 defines the value to be set
  92844. * @returns this effect.
  92845. */
  92846. setDirectColor4(uniformName: string, color4: Color4): Effect;
  92847. /** Release all associated resources */
  92848. dispose(): void;
  92849. /**
  92850. * This function will add a new shader to the shader store
  92851. * @param name the name of the shader
  92852. * @param pixelShader optional pixel shader content
  92853. * @param vertexShader optional vertex shader content
  92854. */
  92855. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  92856. /**
  92857. * Store of each shader (The can be looked up using effect.key)
  92858. */
  92859. static ShadersStore: {
  92860. [key: string]: string;
  92861. };
  92862. /**
  92863. * Store of each included file for a shader (The can be looked up using effect.key)
  92864. */
  92865. static IncludesShadersStore: {
  92866. [key: string]: string;
  92867. };
  92868. /**
  92869. * Resets the cache of effects.
  92870. */
  92871. static ResetCache(): void;
  92872. }
  92873. }
  92874. declare module BABYLON {
  92875. /**
  92876. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  92877. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  92878. * 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;
  92879. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  92880. */
  92881. export class ColorCurves {
  92882. private _dirty;
  92883. private _tempColor;
  92884. private _globalCurve;
  92885. private _highlightsCurve;
  92886. private _midtonesCurve;
  92887. private _shadowsCurve;
  92888. private _positiveCurve;
  92889. private _negativeCurve;
  92890. private _globalHue;
  92891. private _globalDensity;
  92892. private _globalSaturation;
  92893. private _globalExposure;
  92894. /**
  92895. * Gets the global Hue value.
  92896. * 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).
  92897. */
  92898. /**
  92899. * Sets the global Hue value.
  92900. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  92901. */
  92902. globalHue: number;
  92903. /**
  92904. * Gets the global Density value.
  92905. * 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.
  92906. * Values less than zero provide a filter of opposite hue.
  92907. */
  92908. /**
  92909. * Sets the global Density value.
  92910. * 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.
  92911. * Values less than zero provide a filter of opposite hue.
  92912. */
  92913. globalDensity: number;
  92914. /**
  92915. * Gets the global Saturation value.
  92916. * 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.
  92917. */
  92918. /**
  92919. * Sets the global Saturation value.
  92920. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  92921. */
  92922. globalSaturation: number;
  92923. /**
  92924. * Gets the global Exposure value.
  92925. * 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.
  92926. */
  92927. /**
  92928. * Sets the global Exposure value.
  92929. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  92930. */
  92931. globalExposure: number;
  92932. private _highlightsHue;
  92933. private _highlightsDensity;
  92934. private _highlightsSaturation;
  92935. private _highlightsExposure;
  92936. /**
  92937. * Gets the highlights Hue value.
  92938. * 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).
  92939. */
  92940. /**
  92941. * Sets the highlights Hue value.
  92942. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  92943. */
  92944. highlightsHue: number;
  92945. /**
  92946. * Gets the highlights Density value.
  92947. * 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.
  92948. * Values less than zero provide a filter of opposite hue.
  92949. */
  92950. /**
  92951. * Sets the highlights Density value.
  92952. * 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.
  92953. * Values less than zero provide a filter of opposite hue.
  92954. */
  92955. highlightsDensity: number;
  92956. /**
  92957. * Gets the highlights Saturation value.
  92958. * 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.
  92959. */
  92960. /**
  92961. * Sets the highlights Saturation value.
  92962. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  92963. */
  92964. highlightsSaturation: number;
  92965. /**
  92966. * Gets the highlights Exposure value.
  92967. * 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.
  92968. */
  92969. /**
  92970. * Sets the highlights Exposure value.
  92971. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  92972. */
  92973. highlightsExposure: number;
  92974. private _midtonesHue;
  92975. private _midtonesDensity;
  92976. private _midtonesSaturation;
  92977. private _midtonesExposure;
  92978. /**
  92979. * Gets the midtones Hue value.
  92980. * 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).
  92981. */
  92982. /**
  92983. * Sets the midtones Hue value.
  92984. * 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).
  92985. */
  92986. midtonesHue: number;
  92987. /**
  92988. * Gets the midtones Density value.
  92989. * 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.
  92990. * Values less than zero provide a filter of opposite hue.
  92991. */
  92992. /**
  92993. * Sets the midtones Density value.
  92994. * 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.
  92995. * Values less than zero provide a filter of opposite hue.
  92996. */
  92997. midtonesDensity: number;
  92998. /**
  92999. * Gets the midtones Saturation value.
  93000. * 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.
  93001. */
  93002. /**
  93003. * Sets the midtones Saturation value.
  93004. * 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.
  93005. */
  93006. midtonesSaturation: number;
  93007. /**
  93008. * Gets the midtones Exposure value.
  93009. * 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.
  93010. */
  93011. /**
  93012. * Sets the midtones Exposure value.
  93013. * 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.
  93014. */
  93015. midtonesExposure: number;
  93016. private _shadowsHue;
  93017. private _shadowsDensity;
  93018. private _shadowsSaturation;
  93019. private _shadowsExposure;
  93020. /**
  93021. * Gets the shadows Hue value.
  93022. * 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).
  93023. */
  93024. /**
  93025. * Sets the shadows Hue value.
  93026. * 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).
  93027. */
  93028. shadowsHue: number;
  93029. /**
  93030. * Gets the shadows Density value.
  93031. * 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.
  93032. * Values less than zero provide a filter of opposite hue.
  93033. */
  93034. /**
  93035. * Sets the shadows Density value.
  93036. * 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.
  93037. * Values less than zero provide a filter of opposite hue.
  93038. */
  93039. shadowsDensity: number;
  93040. /**
  93041. * Gets the shadows Saturation value.
  93042. * 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.
  93043. */
  93044. /**
  93045. * Sets the shadows Saturation value.
  93046. * 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.
  93047. */
  93048. shadowsSaturation: number;
  93049. /**
  93050. * Gets the shadows Exposure value.
  93051. * 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.
  93052. */
  93053. /**
  93054. * Sets the shadows Exposure value.
  93055. * 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.
  93056. */
  93057. shadowsExposure: number;
  93058. /**
  93059. * Returns the class name
  93060. * @returns The class name
  93061. */
  93062. getClassName(): string;
  93063. /**
  93064. * Binds the color curves to the shader.
  93065. * @param colorCurves The color curve to bind
  93066. * @param effect The effect to bind to
  93067. * @param positiveUniform The positive uniform shader parameter
  93068. * @param neutralUniform The neutral uniform shader parameter
  93069. * @param negativeUniform The negative uniform shader parameter
  93070. */
  93071. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  93072. /**
  93073. * Prepare the list of uniforms associated with the ColorCurves effects.
  93074. * @param uniformsList The list of uniforms used in the effect
  93075. */
  93076. static PrepareUniforms(uniformsList: string[]): void;
  93077. /**
  93078. * Returns color grading data based on a hue, density, saturation and exposure value.
  93079. * @param filterHue The hue of the color filter.
  93080. * @param filterDensity The density of the color filter.
  93081. * @param saturation The saturation.
  93082. * @param exposure The exposure.
  93083. * @param result The result data container.
  93084. */
  93085. private getColorGradingDataToRef;
  93086. /**
  93087. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  93088. * @param value The input slider value in range [-100,100].
  93089. * @returns Adjusted value.
  93090. */
  93091. private static applyColorGradingSliderNonlinear;
  93092. /**
  93093. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  93094. * @param hue The hue (H) input.
  93095. * @param saturation The saturation (S) input.
  93096. * @param brightness The brightness (B) input.
  93097. * @result An RGBA color represented as Vector4.
  93098. */
  93099. private static fromHSBToRef;
  93100. /**
  93101. * Returns a value clamped between min and max
  93102. * @param value The value to clamp
  93103. * @param min The minimum of value
  93104. * @param max The maximum of value
  93105. * @returns The clamped value.
  93106. */
  93107. private static clamp;
  93108. /**
  93109. * Clones the current color curve instance.
  93110. * @return The cloned curves
  93111. */
  93112. clone(): ColorCurves;
  93113. /**
  93114. * Serializes the current color curve instance to a json representation.
  93115. * @return a JSON representation
  93116. */
  93117. serialize(): any;
  93118. /**
  93119. * Parses the color curve from a json representation.
  93120. * @param source the JSON source to parse
  93121. * @return The parsed curves
  93122. */
  93123. static Parse(source: any): ColorCurves;
  93124. }
  93125. }
  93126. declare module BABYLON {
  93127. /**
  93128. * Interface to follow in your material defines to integrate easily the
  93129. * Image proccessing functions.
  93130. * @hidden
  93131. */
  93132. export interface IImageProcessingConfigurationDefines {
  93133. IMAGEPROCESSING: boolean;
  93134. VIGNETTE: boolean;
  93135. VIGNETTEBLENDMODEMULTIPLY: boolean;
  93136. VIGNETTEBLENDMODEOPAQUE: boolean;
  93137. TONEMAPPING: boolean;
  93138. TONEMAPPING_ACES: boolean;
  93139. CONTRAST: boolean;
  93140. EXPOSURE: boolean;
  93141. COLORCURVES: boolean;
  93142. COLORGRADING: boolean;
  93143. COLORGRADING3D: boolean;
  93144. SAMPLER3DGREENDEPTH: boolean;
  93145. SAMPLER3DBGRMAP: boolean;
  93146. IMAGEPROCESSINGPOSTPROCESS: boolean;
  93147. }
  93148. /**
  93149. * @hidden
  93150. */
  93151. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  93152. IMAGEPROCESSING: boolean;
  93153. VIGNETTE: boolean;
  93154. VIGNETTEBLENDMODEMULTIPLY: boolean;
  93155. VIGNETTEBLENDMODEOPAQUE: boolean;
  93156. TONEMAPPING: boolean;
  93157. TONEMAPPING_ACES: boolean;
  93158. CONTRAST: boolean;
  93159. COLORCURVES: boolean;
  93160. COLORGRADING: boolean;
  93161. COLORGRADING3D: boolean;
  93162. SAMPLER3DGREENDEPTH: boolean;
  93163. SAMPLER3DBGRMAP: boolean;
  93164. IMAGEPROCESSINGPOSTPROCESS: boolean;
  93165. EXPOSURE: boolean;
  93166. constructor();
  93167. }
  93168. /**
  93169. * This groups together the common properties used for image processing either in direct forward pass
  93170. * or through post processing effect depending on the use of the image processing pipeline in your scene
  93171. * or not.
  93172. */
  93173. export class ImageProcessingConfiguration {
  93174. /**
  93175. * Default tone mapping applied in BabylonJS.
  93176. */
  93177. static readonly TONEMAPPING_STANDARD: number;
  93178. /**
  93179. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  93180. * to other engines rendering to increase portability.
  93181. */
  93182. static readonly TONEMAPPING_ACES: number;
  93183. /**
  93184. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  93185. */
  93186. colorCurves: Nullable<ColorCurves>;
  93187. private _colorCurvesEnabled;
  93188. /**
  93189. * Gets wether the color curves effect is enabled.
  93190. */
  93191. /**
  93192. * Sets wether the color curves effect is enabled.
  93193. */
  93194. colorCurvesEnabled: boolean;
  93195. private _colorGradingTexture;
  93196. /**
  93197. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  93198. */
  93199. /**
  93200. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  93201. */
  93202. colorGradingTexture: Nullable<BaseTexture>;
  93203. private _colorGradingEnabled;
  93204. /**
  93205. * Gets wether the color grading effect is enabled.
  93206. */
  93207. /**
  93208. * Sets wether the color grading effect is enabled.
  93209. */
  93210. colorGradingEnabled: boolean;
  93211. private _colorGradingWithGreenDepth;
  93212. /**
  93213. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  93214. */
  93215. /**
  93216. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  93217. */
  93218. colorGradingWithGreenDepth: boolean;
  93219. private _colorGradingBGR;
  93220. /**
  93221. * Gets wether the color grading texture contains BGR values.
  93222. */
  93223. /**
  93224. * Sets wether the color grading texture contains BGR values.
  93225. */
  93226. colorGradingBGR: boolean;
  93227. /** @hidden */
  93228. _exposure: number;
  93229. /**
  93230. * Gets the Exposure used in the effect.
  93231. */
  93232. /**
  93233. * Sets the Exposure used in the effect.
  93234. */
  93235. exposure: number;
  93236. private _toneMappingEnabled;
  93237. /**
  93238. * Gets wether the tone mapping effect is enabled.
  93239. */
  93240. /**
  93241. * Sets wether the tone mapping effect is enabled.
  93242. */
  93243. toneMappingEnabled: boolean;
  93244. private _toneMappingType;
  93245. /**
  93246. * Gets the type of tone mapping effect.
  93247. */
  93248. /**
  93249. * Sets the type of tone mapping effect used in BabylonJS.
  93250. */
  93251. toneMappingType: number;
  93252. protected _contrast: number;
  93253. /**
  93254. * Gets the contrast used in the effect.
  93255. */
  93256. /**
  93257. * Sets the contrast used in the effect.
  93258. */
  93259. contrast: number;
  93260. /**
  93261. * Vignette stretch size.
  93262. */
  93263. vignetteStretch: number;
  93264. /**
  93265. * Vignette centre X Offset.
  93266. */
  93267. vignetteCentreX: number;
  93268. /**
  93269. * Vignette centre Y Offset.
  93270. */
  93271. vignetteCentreY: number;
  93272. /**
  93273. * Vignette weight or intensity of the vignette effect.
  93274. */
  93275. vignetteWeight: number;
  93276. /**
  93277. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  93278. * if vignetteEnabled is set to true.
  93279. */
  93280. vignetteColor: Color4;
  93281. /**
  93282. * Camera field of view used by the Vignette effect.
  93283. */
  93284. vignetteCameraFov: number;
  93285. private _vignetteBlendMode;
  93286. /**
  93287. * Gets the vignette blend mode allowing different kind of effect.
  93288. */
  93289. /**
  93290. * Sets the vignette blend mode allowing different kind of effect.
  93291. */
  93292. vignetteBlendMode: number;
  93293. private _vignetteEnabled;
  93294. /**
  93295. * Gets wether the vignette effect is enabled.
  93296. */
  93297. /**
  93298. * Sets wether the vignette effect is enabled.
  93299. */
  93300. vignetteEnabled: boolean;
  93301. private _applyByPostProcess;
  93302. /**
  93303. * Gets wether the image processing is applied through a post process or not.
  93304. */
  93305. /**
  93306. * Sets wether the image processing is applied through a post process or not.
  93307. */
  93308. applyByPostProcess: boolean;
  93309. private _isEnabled;
  93310. /**
  93311. * Gets wether the image processing is enabled or not.
  93312. */
  93313. /**
  93314. * Sets wether the image processing is enabled or not.
  93315. */
  93316. isEnabled: boolean;
  93317. /**
  93318. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  93319. */
  93320. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  93321. /**
  93322. * Method called each time the image processing information changes requires to recompile the effect.
  93323. */
  93324. protected _updateParameters(): void;
  93325. /**
  93326. * Gets the current class name.
  93327. * @return "ImageProcessingConfiguration"
  93328. */
  93329. getClassName(): string;
  93330. /**
  93331. * Prepare the list of uniforms associated with the Image Processing effects.
  93332. * @param uniforms The list of uniforms used in the effect
  93333. * @param defines the list of defines currently in use
  93334. */
  93335. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  93336. /**
  93337. * Prepare the list of samplers associated with the Image Processing effects.
  93338. * @param samplersList The list of uniforms used in the effect
  93339. * @param defines the list of defines currently in use
  93340. */
  93341. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  93342. /**
  93343. * Prepare the list of defines associated to the shader.
  93344. * @param defines the list of defines to complete
  93345. * @param forPostProcess Define if we are currently in post process mode or not
  93346. */
  93347. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  93348. /**
  93349. * Returns true if all the image processing information are ready.
  93350. * @returns True if ready, otherwise, false
  93351. */
  93352. isReady(): boolean;
  93353. /**
  93354. * Binds the image processing to the shader.
  93355. * @param effect The effect to bind to
  93356. * @param aspectRatio Define the current aspect ratio of the effect
  93357. */
  93358. bind(effect: Effect, aspectRatio?: number): void;
  93359. /**
  93360. * Clones the current image processing instance.
  93361. * @return The cloned image processing
  93362. */
  93363. clone(): ImageProcessingConfiguration;
  93364. /**
  93365. * Serializes the current image processing instance to a json representation.
  93366. * @return a JSON representation
  93367. */
  93368. serialize(): any;
  93369. /**
  93370. * Parses the image processing from a json representation.
  93371. * @param source the JSON source to parse
  93372. * @return The parsed image processing
  93373. */
  93374. static Parse(source: any): ImageProcessingConfiguration;
  93375. private static _VIGNETTEMODE_MULTIPLY;
  93376. private static _VIGNETTEMODE_OPAQUE;
  93377. /**
  93378. * Used to apply the vignette as a mix with the pixel color.
  93379. */
  93380. static readonly VIGNETTEMODE_MULTIPLY: number;
  93381. /**
  93382. * Used to apply the vignette as a replacement of the pixel color.
  93383. */
  93384. static readonly VIGNETTEMODE_OPAQUE: number;
  93385. }
  93386. }
  93387. declare module BABYLON {
  93388. /**
  93389. * This represents all the required information to add a fresnel effect on a material:
  93390. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93391. */
  93392. export class FresnelParameters {
  93393. private _isEnabled;
  93394. /**
  93395. * Define if the fresnel effect is enable or not.
  93396. */
  93397. isEnabled: boolean;
  93398. /**
  93399. * Define the color used on edges (grazing angle)
  93400. */
  93401. leftColor: Color3;
  93402. /**
  93403. * Define the color used on center
  93404. */
  93405. rightColor: Color3;
  93406. /**
  93407. * Define bias applied to computed fresnel term
  93408. */
  93409. bias: number;
  93410. /**
  93411. * Defined the power exponent applied to fresnel term
  93412. */
  93413. power: number;
  93414. /**
  93415. * Clones the current fresnel and its valuues
  93416. * @returns a clone fresnel configuration
  93417. */
  93418. clone(): FresnelParameters;
  93419. /**
  93420. * Serializes the current fresnel parameters to a JSON representation.
  93421. * @return the JSON serialization
  93422. */
  93423. serialize(): any;
  93424. /**
  93425. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  93426. * @param parsedFresnelParameters Define the JSON representation
  93427. * @returns the parsed parameters
  93428. */
  93429. static Parse(parsedFresnelParameters: any): FresnelParameters;
  93430. }
  93431. }
  93432. declare module BABYLON {
  93433. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  93434. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93435. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93436. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93437. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93438. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93439. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93440. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93441. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93442. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93443. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93444. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93445. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93446. /**
  93447. * Decorator used to define property that can be serialized as reference to a camera
  93448. * @param sourceName defines the name of the property to decorate
  93449. */
  93450. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93451. /**
  93452. * Class used to help serialization objects
  93453. */
  93454. export class SerializationHelper {
  93455. /** @hidden */
  93456. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  93457. /** @hidden */
  93458. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  93459. /** @hidden */
  93460. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  93461. /** @hidden */
  93462. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  93463. /**
  93464. * Appends the serialized animations from the source animations
  93465. * @param source Source containing the animations
  93466. * @param destination Target to store the animations
  93467. */
  93468. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  93469. /**
  93470. * Static function used to serialized a specific entity
  93471. * @param entity defines the entity to serialize
  93472. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  93473. * @returns a JSON compatible object representing the serialization of the entity
  93474. */
  93475. static Serialize<T>(entity: T, serializationObject?: any): any;
  93476. /**
  93477. * Creates a new entity from a serialization data object
  93478. * @param creationFunction defines a function used to instanciated the new entity
  93479. * @param source defines the source serialization data
  93480. * @param scene defines the hosting scene
  93481. * @param rootUrl defines the root url for resources
  93482. * @returns a new entity
  93483. */
  93484. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  93485. /**
  93486. * Clones an object
  93487. * @param creationFunction defines the function used to instanciate the new object
  93488. * @param source defines the source object
  93489. * @returns the cloned object
  93490. */
  93491. static Clone<T>(creationFunction: () => T, source: T): T;
  93492. /**
  93493. * Instanciates a new object based on a source one (some data will be shared between both object)
  93494. * @param creationFunction defines the function used to instanciate the new object
  93495. * @param source defines the source object
  93496. * @returns the new object
  93497. */
  93498. static Instanciate<T>(creationFunction: () => T, source: T): T;
  93499. }
  93500. }
  93501. declare module BABYLON {
  93502. /**
  93503. * This is the base class of all the camera used in the application.
  93504. * @see http://doc.babylonjs.com/features/cameras
  93505. */
  93506. export class Camera extends Node {
  93507. /** @hidden */
  93508. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  93509. /**
  93510. * This is the default projection mode used by the cameras.
  93511. * It helps recreating a feeling of perspective and better appreciate depth.
  93512. * This is the best way to simulate real life cameras.
  93513. */
  93514. static readonly PERSPECTIVE_CAMERA: number;
  93515. /**
  93516. * This helps creating camera with an orthographic mode.
  93517. * 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.
  93518. */
  93519. static readonly ORTHOGRAPHIC_CAMERA: number;
  93520. /**
  93521. * This is the default FOV mode for perspective cameras.
  93522. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  93523. */
  93524. static readonly FOVMODE_VERTICAL_FIXED: number;
  93525. /**
  93526. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  93527. */
  93528. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  93529. /**
  93530. * This specifies ther is no need for a camera rig.
  93531. * Basically only one eye is rendered corresponding to the camera.
  93532. */
  93533. static readonly RIG_MODE_NONE: number;
  93534. /**
  93535. * Simulates a camera Rig with one blue eye and one red eye.
  93536. * This can be use with 3d blue and red glasses.
  93537. */
  93538. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  93539. /**
  93540. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  93541. */
  93542. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  93543. /**
  93544. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  93545. */
  93546. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  93547. /**
  93548. * Defines that both eyes of the camera will be rendered over under each other.
  93549. */
  93550. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  93551. /**
  93552. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  93553. */
  93554. static readonly RIG_MODE_VR: number;
  93555. /**
  93556. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  93557. */
  93558. static readonly RIG_MODE_WEBVR: number;
  93559. /**
  93560. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  93561. */
  93562. static readonly RIG_MODE_CUSTOM: number;
  93563. /**
  93564. * Defines if by default attaching controls should prevent the default javascript event to continue.
  93565. */
  93566. static ForceAttachControlToAlwaysPreventDefault: boolean;
  93567. /**
  93568. * Define the input manager associated with the camera.
  93569. */
  93570. inputs: CameraInputsManager<Camera>;
  93571. /** @hidden */
  93572. _position: Vector3;
  93573. /**
  93574. * Define the current local position of the camera in the scene
  93575. */
  93576. position: Vector3;
  93577. /**
  93578. * The vector the camera should consider as up.
  93579. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  93580. */
  93581. upVector: Vector3;
  93582. /**
  93583. * Define the current limit on the left side for an orthographic camera
  93584. * In scene unit
  93585. */
  93586. orthoLeft: Nullable<number>;
  93587. /**
  93588. * Define the current limit on the right side for an orthographic camera
  93589. * In scene unit
  93590. */
  93591. orthoRight: Nullable<number>;
  93592. /**
  93593. * Define the current limit on the bottom side for an orthographic camera
  93594. * In scene unit
  93595. */
  93596. orthoBottom: Nullable<number>;
  93597. /**
  93598. * Define the current limit on the top side for an orthographic camera
  93599. * In scene unit
  93600. */
  93601. orthoTop: Nullable<number>;
  93602. /**
  93603. * Field Of View is set in Radians. (default is 0.8)
  93604. */
  93605. fov: number;
  93606. /**
  93607. * Define the minimum distance the camera can see from.
  93608. * This is important to note that the depth buffer are not infinite and the closer it starts
  93609. * the more your scene might encounter depth fighting issue.
  93610. */
  93611. minZ: number;
  93612. /**
  93613. * Define the maximum distance the camera can see to.
  93614. * This is important to note that the depth buffer are not infinite and the further it end
  93615. * the more your scene might encounter depth fighting issue.
  93616. */
  93617. maxZ: number;
  93618. /**
  93619. * Define the default inertia of the camera.
  93620. * This helps giving a smooth feeling to the camera movement.
  93621. */
  93622. inertia: number;
  93623. /**
  93624. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  93625. */
  93626. mode: number;
  93627. /**
  93628. * Define wether the camera is intermediate.
  93629. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  93630. */
  93631. isIntermediate: boolean;
  93632. /**
  93633. * Define the viewport of the camera.
  93634. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  93635. */
  93636. viewport: Viewport;
  93637. /**
  93638. * Restricts the camera to viewing objects with the same layerMask.
  93639. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  93640. */
  93641. layerMask: number;
  93642. /**
  93643. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  93644. */
  93645. fovMode: number;
  93646. /**
  93647. * Rig mode of the camera.
  93648. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  93649. * This is normally controlled byt the camera themselves as internal use.
  93650. */
  93651. cameraRigMode: number;
  93652. /**
  93653. * Defines the distance between both "eyes" in case of a RIG
  93654. */
  93655. interaxialDistance: number;
  93656. /**
  93657. * Defines if stereoscopic rendering is done side by side or over under.
  93658. */
  93659. isStereoscopicSideBySide: boolean;
  93660. /**
  93661. * 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
  93662. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  93663. * else in the scene.
  93664. */
  93665. customRenderTargets: RenderTargetTexture[];
  93666. /**
  93667. * When set, the camera will render to this render target instead of the default canvas
  93668. */
  93669. outputRenderTarget: Nullable<RenderTargetTexture>;
  93670. /**
  93671. * Observable triggered when the camera view matrix has changed.
  93672. */
  93673. onViewMatrixChangedObservable: Observable<Camera>;
  93674. /**
  93675. * Observable triggered when the camera Projection matrix has changed.
  93676. */
  93677. onProjectionMatrixChangedObservable: Observable<Camera>;
  93678. /**
  93679. * Observable triggered when the inputs have been processed.
  93680. */
  93681. onAfterCheckInputsObservable: Observable<Camera>;
  93682. /**
  93683. * Observable triggered when reset has been called and applied to the camera.
  93684. */
  93685. onRestoreStateObservable: Observable<Camera>;
  93686. /** @hidden */
  93687. _cameraRigParams: any;
  93688. /** @hidden */
  93689. _rigCameras: Camera[];
  93690. /** @hidden */
  93691. _rigPostProcess: Nullable<PostProcess>;
  93692. protected _webvrViewMatrix: Matrix;
  93693. /** @hidden */
  93694. _skipRendering: boolean;
  93695. /** @hidden */
  93696. _projectionMatrix: Matrix;
  93697. /** @hidden */
  93698. _postProcesses: Nullable<PostProcess>[];
  93699. /** @hidden */
  93700. _activeMeshes: SmartArray<AbstractMesh>;
  93701. protected _globalPosition: Vector3;
  93702. /** @hidden */
  93703. _computedViewMatrix: Matrix;
  93704. private _doNotComputeProjectionMatrix;
  93705. private _transformMatrix;
  93706. private _frustumPlanes;
  93707. private _refreshFrustumPlanes;
  93708. private _storedFov;
  93709. private _stateStored;
  93710. /**
  93711. * Instantiates a new camera object.
  93712. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  93713. * @see http://doc.babylonjs.com/features/cameras
  93714. * @param name Defines the name of the camera in the scene
  93715. * @param position Defines the position of the camera
  93716. * @param scene Defines the scene the camera belongs too
  93717. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  93718. */
  93719. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93720. /**
  93721. * Store current camera state (fov, position, etc..)
  93722. * @returns the camera
  93723. */
  93724. storeState(): Camera;
  93725. /**
  93726. * Restores the camera state values if it has been stored. You must call storeState() first
  93727. */
  93728. protected _restoreStateValues(): boolean;
  93729. /**
  93730. * Restored camera state. You must call storeState() first.
  93731. * @returns true if restored and false otherwise
  93732. */
  93733. restoreState(): boolean;
  93734. /**
  93735. * Gets the class name of the camera.
  93736. * @returns the class name
  93737. */
  93738. getClassName(): string;
  93739. /** @hidden */
  93740. readonly _isCamera: boolean;
  93741. /**
  93742. * Gets a string representation of the camera useful for debug purpose.
  93743. * @param fullDetails Defines that a more verboe level of logging is required
  93744. * @returns the string representation
  93745. */
  93746. toString(fullDetails?: boolean): string;
  93747. /**
  93748. * Gets the current world space position of the camera.
  93749. */
  93750. readonly globalPosition: Vector3;
  93751. /**
  93752. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  93753. * @returns the active meshe list
  93754. */
  93755. getActiveMeshes(): SmartArray<AbstractMesh>;
  93756. /**
  93757. * Check wether a mesh is part of the current active mesh list of the camera
  93758. * @param mesh Defines the mesh to check
  93759. * @returns true if active, false otherwise
  93760. */
  93761. isActiveMesh(mesh: Mesh): boolean;
  93762. /**
  93763. * Is this camera ready to be used/rendered
  93764. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  93765. * @return true if the camera is ready
  93766. */
  93767. isReady(completeCheck?: boolean): boolean;
  93768. /** @hidden */
  93769. _initCache(): void;
  93770. /** @hidden */
  93771. _updateCache(ignoreParentClass?: boolean): void;
  93772. /** @hidden */
  93773. _isSynchronized(): boolean;
  93774. /** @hidden */
  93775. _isSynchronizedViewMatrix(): boolean;
  93776. /** @hidden */
  93777. _isSynchronizedProjectionMatrix(): boolean;
  93778. /**
  93779. * Attach the input controls to a specific dom element to get the input from.
  93780. * @param element Defines the element the controls should be listened from
  93781. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93782. */
  93783. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93784. /**
  93785. * Detach the current controls from the specified dom element.
  93786. * @param element Defines the element to stop listening the inputs from
  93787. */
  93788. detachControl(element: HTMLElement): void;
  93789. /**
  93790. * Update the camera state according to the different inputs gathered during the frame.
  93791. */
  93792. update(): void;
  93793. /** @hidden */
  93794. _checkInputs(): void;
  93795. /** @hidden */
  93796. readonly rigCameras: Camera[];
  93797. /**
  93798. * Gets the post process used by the rig cameras
  93799. */
  93800. readonly rigPostProcess: Nullable<PostProcess>;
  93801. /**
  93802. * Internal, gets the first post proces.
  93803. * @returns the first post process to be run on this camera.
  93804. */
  93805. _getFirstPostProcess(): Nullable<PostProcess>;
  93806. private _cascadePostProcessesToRigCams;
  93807. /**
  93808. * Attach a post process to the camera.
  93809. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93810. * @param postProcess The post process to attach to the camera
  93811. * @param insertAt The position of the post process in case several of them are in use in the scene
  93812. * @returns the position the post process has been inserted at
  93813. */
  93814. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  93815. /**
  93816. * Detach a post process to the camera.
  93817. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93818. * @param postProcess The post process to detach from the camera
  93819. */
  93820. detachPostProcess(postProcess: PostProcess): void;
  93821. /**
  93822. * Gets the current world matrix of the camera
  93823. */
  93824. getWorldMatrix(): Matrix;
  93825. /** @hidden */
  93826. _getViewMatrix(): Matrix;
  93827. /**
  93828. * Gets the current view matrix of the camera.
  93829. * @param force forces the camera to recompute the matrix without looking at the cached state
  93830. * @returns the view matrix
  93831. */
  93832. getViewMatrix(force?: boolean): Matrix;
  93833. /**
  93834. * Freeze the projection matrix.
  93835. * It will prevent the cache check of the camera projection compute and can speed up perf
  93836. * if no parameter of the camera are meant to change
  93837. * @param projection Defines manually a projection if necessary
  93838. */
  93839. freezeProjectionMatrix(projection?: Matrix): void;
  93840. /**
  93841. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  93842. */
  93843. unfreezeProjectionMatrix(): void;
  93844. /**
  93845. * Gets the current projection matrix of the camera.
  93846. * @param force forces the camera to recompute the matrix without looking at the cached state
  93847. * @returns the projection matrix
  93848. */
  93849. getProjectionMatrix(force?: boolean): Matrix;
  93850. /**
  93851. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  93852. * @returns a Matrix
  93853. */
  93854. getTransformationMatrix(): Matrix;
  93855. private _updateFrustumPlanes;
  93856. /**
  93857. * Checks if a cullable object (mesh...) is in the camera frustum
  93858. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  93859. * @param target The object to check
  93860. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  93861. * @returns true if the object is in frustum otherwise false
  93862. */
  93863. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  93864. /**
  93865. * Checks if a cullable object (mesh...) is in the camera frustum
  93866. * Unlike isInFrustum this cheks the full bounding box
  93867. * @param target The object to check
  93868. * @returns true if the object is in frustum otherwise false
  93869. */
  93870. isCompletelyInFrustum(target: ICullable): boolean;
  93871. /**
  93872. * Gets a ray in the forward direction from the camera.
  93873. * @param length Defines the length of the ray to create
  93874. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  93875. * @param origin Defines the start point of the ray which defaults to the camera position
  93876. * @returns the forward ray
  93877. */
  93878. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  93879. /**
  93880. * Releases resources associated with this node.
  93881. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93882. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93883. */
  93884. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93885. /** @hidden */
  93886. _isLeftCamera: boolean;
  93887. /**
  93888. * Gets the left camera of a rig setup in case of Rigged Camera
  93889. */
  93890. readonly isLeftCamera: boolean;
  93891. /** @hidden */
  93892. _isRightCamera: boolean;
  93893. /**
  93894. * Gets the right camera of a rig setup in case of Rigged Camera
  93895. */
  93896. readonly isRightCamera: boolean;
  93897. /**
  93898. * Gets the left camera of a rig setup in case of Rigged Camera
  93899. */
  93900. readonly leftCamera: Nullable<FreeCamera>;
  93901. /**
  93902. * Gets the right camera of a rig setup in case of Rigged Camera
  93903. */
  93904. readonly rightCamera: Nullable<FreeCamera>;
  93905. /**
  93906. * Gets the left camera target of a rig setup in case of Rigged Camera
  93907. * @returns the target position
  93908. */
  93909. getLeftTarget(): Nullable<Vector3>;
  93910. /**
  93911. * Gets the right camera target of a rig setup in case of Rigged Camera
  93912. * @returns the target position
  93913. */
  93914. getRightTarget(): Nullable<Vector3>;
  93915. /**
  93916. * @hidden
  93917. */
  93918. setCameraRigMode(mode: number, rigParams: any): void;
  93919. /** @hidden */
  93920. static _setStereoscopicRigMode(camera: Camera): void;
  93921. /** @hidden */
  93922. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  93923. /** @hidden */
  93924. static _setVRRigMode(camera: Camera, rigParams: any): void;
  93925. /** @hidden */
  93926. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  93927. /** @hidden */
  93928. _getVRProjectionMatrix(): Matrix;
  93929. protected _updateCameraRotationMatrix(): void;
  93930. protected _updateWebVRCameraRotationMatrix(): void;
  93931. /**
  93932. * This function MUST be overwritten by the different WebVR cameras available.
  93933. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93934. * @hidden
  93935. */
  93936. _getWebVRProjectionMatrix(): Matrix;
  93937. /**
  93938. * This function MUST be overwritten by the different WebVR cameras available.
  93939. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93940. * @hidden
  93941. */
  93942. _getWebVRViewMatrix(): Matrix;
  93943. /** @hidden */
  93944. setCameraRigParameter(name: string, value: any): void;
  93945. /**
  93946. * needs to be overridden by children so sub has required properties to be copied
  93947. * @hidden
  93948. */
  93949. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  93950. /**
  93951. * May need to be overridden by children
  93952. * @hidden
  93953. */
  93954. _updateRigCameras(): void;
  93955. /** @hidden */
  93956. _setupInputs(): void;
  93957. /**
  93958. * Serialiaze the camera setup to a json represention
  93959. * @returns the JSON representation
  93960. */
  93961. serialize(): any;
  93962. /**
  93963. * Clones the current camera.
  93964. * @param name The cloned camera name
  93965. * @returns the cloned camera
  93966. */
  93967. clone(name: string): Camera;
  93968. /**
  93969. * Gets the direction of the camera relative to a given local axis.
  93970. * @param localAxis Defines the reference axis to provide a relative direction.
  93971. * @return the direction
  93972. */
  93973. getDirection(localAxis: Vector3): Vector3;
  93974. /**
  93975. * Gets the direction of the camera relative to a given local axis into a passed vector.
  93976. * @param localAxis Defines the reference axis to provide a relative direction.
  93977. * @param result Defines the vector to store the result in
  93978. */
  93979. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  93980. /**
  93981. * Gets a camera constructor for a given camera type
  93982. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  93983. * @param name The name of the camera the result will be able to instantiate
  93984. * @param scene The scene the result will construct the camera in
  93985. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  93986. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  93987. * @returns a factory method to construc the camera
  93988. */
  93989. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  93990. /**
  93991. * Compute the world matrix of the camera.
  93992. * @returns the camera workd matrix
  93993. */
  93994. computeWorldMatrix(): Matrix;
  93995. /**
  93996. * Parse a JSON and creates the camera from the parsed information
  93997. * @param parsedCamera The JSON to parse
  93998. * @param scene The scene to instantiate the camera in
  93999. * @returns the newly constructed camera
  94000. */
  94001. static Parse(parsedCamera: any, scene: Scene): Camera;
  94002. }
  94003. }
  94004. declare module BABYLON {
  94005. /**
  94006. * Interface for any object that can request an animation frame
  94007. */
  94008. export interface ICustomAnimationFrameRequester {
  94009. /**
  94010. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  94011. */
  94012. renderFunction?: Function;
  94013. /**
  94014. * Called to request the next frame to render to
  94015. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  94016. */
  94017. requestAnimationFrame: Function;
  94018. /**
  94019. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  94020. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  94021. */
  94022. requestID?: number;
  94023. }
  94024. /**
  94025. * Interface containing an array of animations
  94026. */
  94027. export interface IAnimatable {
  94028. /**
  94029. * Array of animations
  94030. */
  94031. animations: Nullable<Array<Animation>>;
  94032. }
  94033. /** Interface used by value gradients (color, factor, ...) */
  94034. export interface IValueGradient {
  94035. /**
  94036. * Gets or sets the gradient value (between 0 and 1)
  94037. */
  94038. gradient: number;
  94039. }
  94040. /** Class used to store color4 gradient */
  94041. export class ColorGradient implements IValueGradient {
  94042. /**
  94043. * Gets or sets the gradient value (between 0 and 1)
  94044. */
  94045. gradient: number;
  94046. /**
  94047. * Gets or sets first associated color
  94048. */
  94049. color1: Color4;
  94050. /**
  94051. * Gets or sets second associated color
  94052. */
  94053. color2?: Color4;
  94054. /**
  94055. * Will get a color picked randomly between color1 and color2.
  94056. * If color2 is undefined then color1 will be used
  94057. * @param result defines the target Color4 to store the result in
  94058. */
  94059. getColorToRef(result: Color4): void;
  94060. }
  94061. /** Class used to store color 3 gradient */
  94062. export class Color3Gradient implements IValueGradient {
  94063. /**
  94064. * Gets or sets the gradient value (between 0 and 1)
  94065. */
  94066. gradient: number;
  94067. /**
  94068. * Gets or sets the associated color
  94069. */
  94070. color: Color3;
  94071. }
  94072. /** Class used to store factor gradient */
  94073. export class FactorGradient implements IValueGradient {
  94074. /**
  94075. * Gets or sets the gradient value (between 0 and 1)
  94076. */
  94077. gradient: number;
  94078. /**
  94079. * Gets or sets first associated factor
  94080. */
  94081. factor1: number;
  94082. /**
  94083. * Gets or sets second associated factor
  94084. */
  94085. factor2?: number;
  94086. /**
  94087. * Will get a number picked randomly between factor1 and factor2.
  94088. * If factor2 is undefined then factor1 will be used
  94089. * @returns the picked number
  94090. */
  94091. getFactor(): number;
  94092. }
  94093. /**
  94094. * @ignore
  94095. * Application error to support additional information when loading a file
  94096. */
  94097. export class LoadFileError extends Error {
  94098. /** defines the optional web request */
  94099. request?: WebRequest | undefined;
  94100. private static _setPrototypeOf;
  94101. /**
  94102. * Creates a new LoadFileError
  94103. * @param message defines the message of the error
  94104. * @param request defines the optional web request
  94105. */
  94106. constructor(message: string,
  94107. /** defines the optional web request */
  94108. request?: WebRequest | undefined);
  94109. }
  94110. /**
  94111. * Class used to define a retry strategy when error happens while loading assets
  94112. */
  94113. export class RetryStrategy {
  94114. /**
  94115. * Function used to defines an exponential back off strategy
  94116. * @param maxRetries defines the maximum number of retries (3 by default)
  94117. * @param baseInterval defines the interval between retries
  94118. * @returns the strategy function to use
  94119. */
  94120. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  94121. }
  94122. /**
  94123. * File request interface
  94124. */
  94125. export interface IFileRequest {
  94126. /**
  94127. * Raised when the request is complete (success or error).
  94128. */
  94129. onCompleteObservable: Observable<IFileRequest>;
  94130. /**
  94131. * Aborts the request for a file.
  94132. */
  94133. abort: () => void;
  94134. }
  94135. /**
  94136. * Class containing a set of static utilities functions
  94137. */
  94138. export class Tools {
  94139. /**
  94140. * Gets or sets the base URL to use to load assets
  94141. */
  94142. static BaseUrl: string;
  94143. /**
  94144. * Enable/Disable Custom HTTP Request Headers globally.
  94145. * default = false
  94146. * @see CustomRequestHeaders
  94147. */
  94148. static UseCustomRequestHeaders: boolean;
  94149. /**
  94150. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  94151. * i.e. when loading files, where the server/service expects an Authorization header
  94152. */
  94153. static CustomRequestHeaders: {
  94154. [key: string]: string;
  94155. };
  94156. /**
  94157. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  94158. */
  94159. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  94160. /**
  94161. * Default behaviour for cors in the application.
  94162. * It can be a string if the expected behavior is identical in the entire app.
  94163. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  94164. */
  94165. static CorsBehavior: string | ((url: string | string[]) => string);
  94166. /**
  94167. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  94168. * @ignorenaming
  94169. */
  94170. static UseFallbackTexture: boolean;
  94171. /**
  94172. * Use this object to register external classes like custom textures or material
  94173. * to allow the laoders to instantiate them
  94174. */
  94175. static RegisteredExternalClasses: {
  94176. [key: string]: Object;
  94177. };
  94178. /**
  94179. * Texture content used if a texture cannot loaded
  94180. * @ignorenaming
  94181. */
  94182. static fallbackTexture: string;
  94183. /**
  94184. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  94185. * @param u defines the coordinate on X axis
  94186. * @param v defines the coordinate on Y axis
  94187. * @param width defines the width of the source data
  94188. * @param height defines the height of the source data
  94189. * @param pixels defines the source byte array
  94190. * @param color defines the output color
  94191. */
  94192. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  94193. /**
  94194. * Interpolates between a and b via alpha
  94195. * @param a The lower value (returned when alpha = 0)
  94196. * @param b The upper value (returned when alpha = 1)
  94197. * @param alpha The interpolation-factor
  94198. * @return The mixed value
  94199. */
  94200. static Mix(a: number, b: number, alpha: number): number;
  94201. /**
  94202. * Tries to instantiate a new object from a given class name
  94203. * @param className defines the class name to instantiate
  94204. * @returns the new object or null if the system was not able to do the instantiation
  94205. */
  94206. static Instantiate(className: string): any;
  94207. /**
  94208. * Provides a slice function that will work even on IE
  94209. * @param data defines the array to slice
  94210. * @param start defines the start of the data (optional)
  94211. * @param end defines the end of the data (optional)
  94212. * @returns the new sliced array
  94213. */
  94214. static Slice<T>(data: T, start?: number, end?: number): T;
  94215. /**
  94216. * Polyfill for setImmediate
  94217. * @param action defines the action to execute after the current execution block
  94218. */
  94219. static SetImmediate(action: () => void): void;
  94220. /**
  94221. * Function indicating if a number is an exponent of 2
  94222. * @param value defines the value to test
  94223. * @returns true if the value is an exponent of 2
  94224. */
  94225. static IsExponentOfTwo(value: number): boolean;
  94226. private static _tmpFloatArray;
  94227. /**
  94228. * Returns the nearest 32-bit single precision float representation of a Number
  94229. * @param value A Number. If the parameter is of a different type, it will get converted
  94230. * to a number or to NaN if it cannot be converted
  94231. * @returns number
  94232. */
  94233. static FloatRound(value: number): number;
  94234. /**
  94235. * Find the next highest power of two.
  94236. * @param x Number to start search from.
  94237. * @return Next highest power of two.
  94238. */
  94239. static CeilingPOT(x: number): number;
  94240. /**
  94241. * Find the next lowest power of two.
  94242. * @param x Number to start search from.
  94243. * @return Next lowest power of two.
  94244. */
  94245. static FloorPOT(x: number): number;
  94246. /**
  94247. * Find the nearest power of two.
  94248. * @param x Number to start search from.
  94249. * @return Next nearest power of two.
  94250. */
  94251. static NearestPOT(x: number): number;
  94252. /**
  94253. * Get the closest exponent of two
  94254. * @param value defines the value to approximate
  94255. * @param max defines the maximum value to return
  94256. * @param mode defines how to define the closest value
  94257. * @returns closest exponent of two of the given value
  94258. */
  94259. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  94260. /**
  94261. * Extracts the filename from a path
  94262. * @param path defines the path to use
  94263. * @returns the filename
  94264. */
  94265. static GetFilename(path: string): string;
  94266. /**
  94267. * Extracts the "folder" part of a path (everything before the filename).
  94268. * @param uri The URI to extract the info from
  94269. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  94270. * @returns The "folder" part of the path
  94271. */
  94272. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  94273. /**
  94274. * Extracts text content from a DOM element hierarchy
  94275. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  94276. */
  94277. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  94278. /**
  94279. * Convert an angle in radians to degrees
  94280. * @param angle defines the angle to convert
  94281. * @returns the angle in degrees
  94282. */
  94283. static ToDegrees(angle: number): number;
  94284. /**
  94285. * Convert an angle in degrees to radians
  94286. * @param angle defines the angle to convert
  94287. * @returns the angle in radians
  94288. */
  94289. static ToRadians(angle: number): number;
  94290. /**
  94291. * Encode a buffer to a base64 string
  94292. * @param buffer defines the buffer to encode
  94293. * @returns the encoded string
  94294. */
  94295. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  94296. /**
  94297. * Extracts minimum and maximum values from a list of indexed positions
  94298. * @param positions defines the positions to use
  94299. * @param indices defines the indices to the positions
  94300. * @param indexStart defines the start index
  94301. * @param indexCount defines the end index
  94302. * @param bias defines bias value to add to the result
  94303. * @return minimum and maximum values
  94304. */
  94305. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  94306. minimum: Vector3;
  94307. maximum: Vector3;
  94308. };
  94309. /**
  94310. * Extracts minimum and maximum values from a list of positions
  94311. * @param positions defines the positions to use
  94312. * @param start defines the start index in the positions array
  94313. * @param count defines the number of positions to handle
  94314. * @param bias defines bias value to add to the result
  94315. * @param stride defines the stride size to use (distance between two positions in the positions array)
  94316. * @return minimum and maximum values
  94317. */
  94318. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  94319. minimum: Vector3;
  94320. maximum: Vector3;
  94321. };
  94322. /**
  94323. * Returns an array if obj is not an array
  94324. * @param obj defines the object to evaluate as an array
  94325. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  94326. * @returns either obj directly if obj is an array or a new array containing obj
  94327. */
  94328. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  94329. /**
  94330. * Gets the pointer prefix to use
  94331. * @returns "pointer" if touch is enabled. Else returns "mouse"
  94332. */
  94333. static GetPointerPrefix(): string;
  94334. /**
  94335. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  94336. * @param func - the function to be called
  94337. * @param requester - the object that will request the next frame. Falls back to window.
  94338. * @returns frame number
  94339. */
  94340. static QueueNewFrame(func: () => void, requester?: any): number;
  94341. /**
  94342. * Ask the browser to promote the current element to fullscreen rendering mode
  94343. * @param element defines the DOM element to promote
  94344. */
  94345. static RequestFullscreen(element: HTMLElement): void;
  94346. /**
  94347. * Asks the browser to exit fullscreen mode
  94348. */
  94349. static ExitFullscreen(): void;
  94350. /**
  94351. * Ask the browser to promote the current element to pointerlock mode
  94352. * @param element defines the DOM element to promote
  94353. */
  94354. static RequestPointerlock(element: HTMLElement): void;
  94355. /**
  94356. * Asks the browser to exit pointerlock mode
  94357. */
  94358. static ExitPointerlock(): void;
  94359. /**
  94360. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  94361. * @param url define the url we are trying
  94362. * @param element define the dom element where to configure the cors policy
  94363. */
  94364. static SetCorsBehavior(url: string | string[], element: {
  94365. crossOrigin: string | null;
  94366. }): void;
  94367. /**
  94368. * Removes unwanted characters from an url
  94369. * @param url defines the url to clean
  94370. * @returns the cleaned url
  94371. */
  94372. static CleanUrl(url: string): string;
  94373. /**
  94374. * Gets or sets a function used to pre-process url before using them to load assets
  94375. */
  94376. static PreprocessUrl: (url: string) => string;
  94377. /**
  94378. * Loads an image as an HTMLImageElement.
  94379. * @param input url string, ArrayBuffer, or Blob to load
  94380. * @param onLoad callback called when the image successfully loads
  94381. * @param onError callback called when the image fails to load
  94382. * @param offlineProvider offline provider for caching
  94383. * @returns the HTMLImageElement of the loaded image
  94384. */
  94385. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  94386. /**
  94387. * Loads a file
  94388. * @param url url string, ArrayBuffer, or Blob to load
  94389. * @param onSuccess callback called when the file successfully loads
  94390. * @param onProgress callback called while file is loading (if the server supports this mode)
  94391. * @param offlineProvider defines the offline provider for caching
  94392. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  94393. * @param onError callback called when the file fails to load
  94394. * @returns a file request object
  94395. */
  94396. 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;
  94397. /**
  94398. * Loads a file from a url
  94399. * @param url the file url to load
  94400. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  94401. */
  94402. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  94403. /**
  94404. * Load a script (identified by an url). When the url returns, the
  94405. * content of this file is added into a new script element, attached to the DOM (body element)
  94406. * @param scriptUrl defines the url of the script to laod
  94407. * @param onSuccess defines the callback called when the script is loaded
  94408. * @param onError defines the callback to call if an error occurs
  94409. * @param scriptId defines the id of the script element
  94410. */
  94411. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  94412. /**
  94413. * Load an asynchronous script (identified by an url). When the url returns, the
  94414. * content of this file is added into a new script element, attached to the DOM (body element)
  94415. * @param scriptUrl defines the url of the script to laod
  94416. * @param scriptId defines the id of the script element
  94417. * @returns a promise request object
  94418. */
  94419. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  94420. /**
  94421. * Loads a file from a blob
  94422. * @param fileToLoad defines the blob to use
  94423. * @param callback defines the callback to call when data is loaded
  94424. * @param progressCallback defines the callback to call during loading process
  94425. * @returns a file request object
  94426. */
  94427. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  94428. /**
  94429. * Loads a file
  94430. * @param fileToLoad defines the file to load
  94431. * @param callback defines the callback to call when data is loaded
  94432. * @param progressCallBack defines the callback to call during loading process
  94433. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  94434. * @returns a file request object
  94435. */
  94436. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  94437. /**
  94438. * Creates a data url from a given string content
  94439. * @param content defines the content to convert
  94440. * @returns the new data url link
  94441. */
  94442. static FileAsURL(content: string): string;
  94443. /**
  94444. * Format the given number to a specific decimal format
  94445. * @param value defines the number to format
  94446. * @param decimals defines the number of decimals to use
  94447. * @returns the formatted string
  94448. */
  94449. static Format(value: number, decimals?: number): string;
  94450. /**
  94451. * Checks if a given vector is inside a specific range
  94452. * @param v defines the vector to test
  94453. * @param min defines the minimum range
  94454. * @param max defines the maximum range
  94455. */
  94456. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  94457. /**
  94458. * Tries to copy an object by duplicating every property
  94459. * @param source defines the source object
  94460. * @param destination defines the target object
  94461. * @param doNotCopyList defines a list of properties to avoid
  94462. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  94463. */
  94464. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  94465. /**
  94466. * Gets a boolean indicating if the given object has no own property
  94467. * @param obj defines the object to test
  94468. * @returns true if object has no own property
  94469. */
  94470. static IsEmpty(obj: any): boolean;
  94471. /**
  94472. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  94473. * @param str Source string
  94474. * @param suffix Suffix to search for in the source string
  94475. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  94476. */
  94477. static EndsWith(str: string, suffix: string): boolean;
  94478. /**
  94479. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  94480. * @param str Source string
  94481. * @param suffix Suffix to search for in the source string
  94482. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  94483. */
  94484. static StartsWith(str: string, suffix: string): boolean;
  94485. /**
  94486. * Function used to register events at window level
  94487. * @param events defines the events to register
  94488. */
  94489. static RegisterTopRootEvents(events: {
  94490. name: string;
  94491. handler: Nullable<(e: FocusEvent) => any>;
  94492. }[]): void;
  94493. /**
  94494. * Function used to unregister events from window level
  94495. * @param events defines the events to unregister
  94496. */
  94497. static UnregisterTopRootEvents(events: {
  94498. name: string;
  94499. handler: Nullable<(e: FocusEvent) => any>;
  94500. }[]): void;
  94501. /**
  94502. * @ignore
  94503. */
  94504. static _ScreenshotCanvas: HTMLCanvasElement;
  94505. /**
  94506. * Dumps the current bound framebuffer
  94507. * @param width defines the rendering width
  94508. * @param height defines the rendering height
  94509. * @param engine defines the hosting engine
  94510. * @param successCallback defines the callback triggered once the data are available
  94511. * @param mimeType defines the mime type of the result
  94512. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  94513. */
  94514. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  94515. /**
  94516. * Converts the canvas data to blob.
  94517. * This acts as a polyfill for browsers not supporting the to blob function.
  94518. * @param canvas Defines the canvas to extract the data from
  94519. * @param successCallback Defines the callback triggered once the data are available
  94520. * @param mimeType Defines the mime type of the result
  94521. */
  94522. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  94523. /**
  94524. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  94525. * @param successCallback defines the callback triggered once the data are available
  94526. * @param mimeType defines the mime type of the result
  94527. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  94528. */
  94529. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  94530. /**
  94531. * Downloads a blob in the browser
  94532. * @param blob defines the blob to download
  94533. * @param fileName defines the name of the downloaded file
  94534. */
  94535. static Download(blob: Blob, fileName: string): void;
  94536. /**
  94537. * Captures a screenshot of the current rendering
  94538. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  94539. * @param engine defines the rendering engine
  94540. * @param camera defines the source camera
  94541. * @param size This parameter can be set to a single number or to an object with the
  94542. * following (optional) properties: precision, width, height. If a single number is passed,
  94543. * it will be used for both width and height. If an object is passed, the screenshot size
  94544. * will be derived from the parameters. The precision property is a multiplier allowing
  94545. * rendering at a higher or lower resolution
  94546. * @param successCallback defines the callback receives a single parameter which contains the
  94547. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  94548. * src parameter of an <img> to display it
  94549. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  94550. * Check your browser for supported MIME types
  94551. */
  94552. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  94553. /**
  94554. * Generates an image screenshot from the specified camera.
  94555. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  94556. * @param engine The engine to use for rendering
  94557. * @param camera The camera to use for rendering
  94558. * @param size This parameter can be set to a single number or to an object with the
  94559. * following (optional) properties: precision, width, height. If a single number is passed,
  94560. * it will be used for both width and height. If an object is passed, the screenshot size
  94561. * will be derived from the parameters. The precision property is a multiplier allowing
  94562. * rendering at a higher or lower resolution
  94563. * @param successCallback The callback receives a single parameter which contains the
  94564. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  94565. * src parameter of an <img> to display it
  94566. * @param mimeType The MIME type of the screenshot image (default: image/png).
  94567. * Check your browser for supported MIME types
  94568. * @param samples Texture samples (default: 1)
  94569. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  94570. * @param fileName A name for for the downloaded file.
  94571. */
  94572. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  94573. /**
  94574. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  94575. * Be aware Math.random() could cause collisions, but:
  94576. * "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"
  94577. * @returns a pseudo random id
  94578. */
  94579. static RandomId(): string;
  94580. /**
  94581. * Test if the given uri is a base64 string
  94582. * @param uri The uri to test
  94583. * @return True if the uri is a base64 string or false otherwise
  94584. */
  94585. static IsBase64(uri: string): boolean;
  94586. /**
  94587. * Decode the given base64 uri.
  94588. * @param uri The uri to decode
  94589. * @return The decoded base64 data.
  94590. */
  94591. static DecodeBase64(uri: string): ArrayBuffer;
  94592. /**
  94593. * Gets the absolute url.
  94594. * @param url the input url
  94595. * @return the absolute url
  94596. */
  94597. static GetAbsoluteUrl(url: string): string;
  94598. /**
  94599. * No log
  94600. */
  94601. static readonly NoneLogLevel: number;
  94602. /**
  94603. * Only message logs
  94604. */
  94605. static readonly MessageLogLevel: number;
  94606. /**
  94607. * Only warning logs
  94608. */
  94609. static readonly WarningLogLevel: number;
  94610. /**
  94611. * Only error logs
  94612. */
  94613. static readonly ErrorLogLevel: number;
  94614. /**
  94615. * All logs
  94616. */
  94617. static readonly AllLogLevel: number;
  94618. /**
  94619. * Gets a value indicating the number of loading errors
  94620. * @ignorenaming
  94621. */
  94622. static readonly errorsCount: number;
  94623. /**
  94624. * Callback called when a new log is added
  94625. */
  94626. static OnNewCacheEntry: (entry: string) => void;
  94627. /**
  94628. * Log a message to the console
  94629. * @param message defines the message to log
  94630. */
  94631. static Log(message: string): void;
  94632. /**
  94633. * Write a warning message to the console
  94634. * @param message defines the message to log
  94635. */
  94636. static Warn(message: string): void;
  94637. /**
  94638. * Write an error message to the console
  94639. * @param message defines the message to log
  94640. */
  94641. static Error(message: string): void;
  94642. /**
  94643. * Gets current log cache (list of logs)
  94644. */
  94645. static readonly LogCache: string;
  94646. /**
  94647. * Clears the log cache
  94648. */
  94649. static ClearLogCache(): void;
  94650. /**
  94651. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  94652. */
  94653. static LogLevels: number;
  94654. /**
  94655. * Checks if the loaded document was accessed via `file:`-Protocol.
  94656. * @returns boolean
  94657. */
  94658. static IsFileURL(): boolean;
  94659. /**
  94660. * Checks if the window object exists
  94661. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  94662. */
  94663. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  94664. /**
  94665. * No performance log
  94666. */
  94667. static readonly PerformanceNoneLogLevel: number;
  94668. /**
  94669. * Use user marks to log performance
  94670. */
  94671. static readonly PerformanceUserMarkLogLevel: number;
  94672. /**
  94673. * Log performance to the console
  94674. */
  94675. static readonly PerformanceConsoleLogLevel: number;
  94676. private static _performance;
  94677. /**
  94678. * Sets the current performance log level
  94679. */
  94680. static PerformanceLogLevel: number;
  94681. private static _StartPerformanceCounterDisabled;
  94682. private static _EndPerformanceCounterDisabled;
  94683. private static _StartUserMark;
  94684. private static _EndUserMark;
  94685. private static _StartPerformanceConsole;
  94686. private static _EndPerformanceConsole;
  94687. /**
  94688. * Starts a performance counter
  94689. */
  94690. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  94691. /**
  94692. * Ends a specific performance coutner
  94693. */
  94694. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  94695. /**
  94696. * Gets either window.performance.now() if supported or Date.now() else
  94697. */
  94698. static readonly Now: number;
  94699. /**
  94700. * This method will return the name of the class used to create the instance of the given object.
  94701. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  94702. * @param object the object to get the class name from
  94703. * @param isType defines if the object is actually a type
  94704. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  94705. */
  94706. static GetClassName(object: any, isType?: boolean): string;
  94707. /**
  94708. * Gets the first element of an array satisfying a given predicate
  94709. * @param array defines the array to browse
  94710. * @param predicate defines the predicate to use
  94711. * @returns null if not found or the element
  94712. */
  94713. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  94714. /**
  94715. * This method will return the name of the full name of the class, including its owning module (if any).
  94716. * 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).
  94717. * @param object the object to get the class name from
  94718. * @param isType defines if the object is actually a type
  94719. * @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.
  94720. * @ignorenaming
  94721. */
  94722. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  94723. /**
  94724. * Returns a promise that resolves after the given amount of time.
  94725. * @param delay Number of milliseconds to delay
  94726. * @returns Promise that resolves after the given amount of time
  94727. */
  94728. static DelayAsync(delay: number): Promise<void>;
  94729. /**
  94730. * Gets the current gradient from an array of IValueGradient
  94731. * @param ratio defines the current ratio to get
  94732. * @param gradients defines the array of IValueGradient
  94733. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  94734. */
  94735. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  94736. }
  94737. /**
  94738. * This class is used to track a performance counter which is number based.
  94739. * The user has access to many properties which give statistics of different nature.
  94740. *
  94741. * The implementer can track two kinds of Performance Counter: time and count.
  94742. * 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.
  94743. * 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.
  94744. */
  94745. export class PerfCounter {
  94746. /**
  94747. * Gets or sets a global boolean to turn on and off all the counters
  94748. */
  94749. static Enabled: boolean;
  94750. /**
  94751. * Returns the smallest value ever
  94752. */
  94753. readonly min: number;
  94754. /**
  94755. * Returns the biggest value ever
  94756. */
  94757. readonly max: number;
  94758. /**
  94759. * Returns the average value since the performance counter is running
  94760. */
  94761. readonly average: number;
  94762. /**
  94763. * Returns the average value of the last second the counter was monitored
  94764. */
  94765. readonly lastSecAverage: number;
  94766. /**
  94767. * Returns the current value
  94768. */
  94769. readonly current: number;
  94770. /**
  94771. * Gets the accumulated total
  94772. */
  94773. readonly total: number;
  94774. /**
  94775. * Gets the total value count
  94776. */
  94777. readonly count: number;
  94778. /**
  94779. * Creates a new counter
  94780. */
  94781. constructor();
  94782. /**
  94783. * Call this method to start monitoring a new frame.
  94784. * 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.
  94785. */
  94786. fetchNewFrame(): void;
  94787. /**
  94788. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  94789. * @param newCount the count value to add to the monitored count
  94790. * @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.
  94791. */
  94792. addCount(newCount: number, fetchResult: boolean): void;
  94793. /**
  94794. * Start monitoring this performance counter
  94795. */
  94796. beginMonitoring(): void;
  94797. /**
  94798. * Compute the time lapsed since the previous beginMonitoring() call.
  94799. * @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
  94800. */
  94801. endMonitoring(newFrame?: boolean): void;
  94802. private _fetchResult;
  94803. private _startMonitoringTime;
  94804. private _min;
  94805. private _max;
  94806. private _average;
  94807. private _current;
  94808. private _totalValueCount;
  94809. private _totalAccumulated;
  94810. private _lastSecAverage;
  94811. private _lastSecAccumulated;
  94812. private _lastSecTime;
  94813. private _lastSecValueCount;
  94814. }
  94815. /**
  94816. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  94817. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  94818. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  94819. * @param name The name of the class, case should be preserved
  94820. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  94821. */
  94822. export function className(name: string, module?: string): (target: Object) => void;
  94823. /**
  94824. * An implementation of a loop for asynchronous functions.
  94825. */
  94826. export class AsyncLoop {
  94827. /**
  94828. * Defines the number of iterations for the loop
  94829. */
  94830. iterations: number;
  94831. /**
  94832. * Defines the current index of the loop.
  94833. */
  94834. index: number;
  94835. private _done;
  94836. private _fn;
  94837. private _successCallback;
  94838. /**
  94839. * Constructor.
  94840. * @param iterations the number of iterations.
  94841. * @param func the function to run each iteration
  94842. * @param successCallback the callback that will be called upon succesful execution
  94843. * @param offset starting offset.
  94844. */
  94845. constructor(
  94846. /**
  94847. * Defines the number of iterations for the loop
  94848. */
  94849. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  94850. /**
  94851. * Execute the next iteration. Must be called after the last iteration was finished.
  94852. */
  94853. executeNext(): void;
  94854. /**
  94855. * Break the loop and run the success callback.
  94856. */
  94857. breakLoop(): void;
  94858. /**
  94859. * Create and run an async loop.
  94860. * @param iterations the number of iterations.
  94861. * @param fn the function to run each iteration
  94862. * @param successCallback the callback that will be called upon succesful execution
  94863. * @param offset starting offset.
  94864. * @returns the created async loop object
  94865. */
  94866. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  94867. /**
  94868. * A for-loop that will run a given number of iterations synchronous and the rest async.
  94869. * @param iterations total number of iterations
  94870. * @param syncedIterations number of synchronous iterations in each async iteration.
  94871. * @param fn the function to call each iteration.
  94872. * @param callback a success call back that will be called when iterating stops.
  94873. * @param breakFunction a break condition (optional)
  94874. * @param timeout timeout settings for the setTimeout function. default - 0.
  94875. * @returns the created async loop object
  94876. */
  94877. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  94878. }
  94879. }
  94880. declare module BABYLON {
  94881. /** @hidden */
  94882. export interface ICollisionCoordinator {
  94883. createCollider(): Collider;
  94884. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  94885. init(scene: Scene): void;
  94886. }
  94887. /** @hidden */
  94888. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  94889. private _scene;
  94890. private _scaledPosition;
  94891. private _scaledVelocity;
  94892. private _finalPosition;
  94893. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  94894. createCollider(): Collider;
  94895. init(scene: Scene): void;
  94896. private _collideWithWorld;
  94897. }
  94898. }
  94899. declare module BABYLON {
  94900. /**
  94901. * Class used to manage all inputs for the scene.
  94902. */
  94903. export class InputManager {
  94904. /** The distance in pixel that you have to move to prevent some events */
  94905. static DragMovementThreshold: number;
  94906. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  94907. static LongPressDelay: number;
  94908. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  94909. static DoubleClickDelay: number;
  94910. /** If you need to check double click without raising a single click at first click, enable this flag */
  94911. static ExclusiveDoubleClickMode: boolean;
  94912. private _wheelEventName;
  94913. private _onPointerMove;
  94914. private _onPointerDown;
  94915. private _onPointerUp;
  94916. private _initClickEvent;
  94917. private _initActionManager;
  94918. private _delayedSimpleClick;
  94919. private _delayedSimpleClickTimeout;
  94920. private _previousDelayedSimpleClickTimeout;
  94921. private _meshPickProceed;
  94922. private _previousButtonPressed;
  94923. private _currentPickResult;
  94924. private _previousPickResult;
  94925. private _totalPointersPressed;
  94926. private _doubleClickOccured;
  94927. private _pointerOverMesh;
  94928. private _pickedDownMesh;
  94929. private _pickedUpMesh;
  94930. private _pointerX;
  94931. private _pointerY;
  94932. private _unTranslatedPointerX;
  94933. private _unTranslatedPointerY;
  94934. private _startingPointerPosition;
  94935. private _previousStartingPointerPosition;
  94936. private _startingPointerTime;
  94937. private _previousStartingPointerTime;
  94938. private _pointerCaptures;
  94939. private _onKeyDown;
  94940. private _onKeyUp;
  94941. private _onCanvasFocusObserver;
  94942. private _onCanvasBlurObserver;
  94943. private _scene;
  94944. /**
  94945. * Creates a new InputManager
  94946. * @param scene defines the hosting scene
  94947. */
  94948. constructor(scene: Scene);
  94949. /**
  94950. * Gets the mesh that is currently under the pointer
  94951. */
  94952. readonly meshUnderPointer: Nullable<AbstractMesh>;
  94953. /**
  94954. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  94955. */
  94956. readonly unTranslatedPointer: Vector2;
  94957. /**
  94958. * Gets or sets the current on-screen X position of the pointer
  94959. */
  94960. pointerX: number;
  94961. /**
  94962. * Gets or sets the current on-screen Y position of the pointer
  94963. */
  94964. pointerY: number;
  94965. private _updatePointerPosition;
  94966. private _processPointerMove;
  94967. private _setRayOnPointerInfo;
  94968. private _checkPrePointerObservable;
  94969. /**
  94970. * Use this method to simulate a pointer move on a mesh
  94971. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94972. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94973. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94974. */
  94975. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  94976. /**
  94977. * Use this method to simulate a pointer down on a mesh
  94978. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94979. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94980. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94981. */
  94982. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  94983. private _processPointerDown;
  94984. /** @hidden */
  94985. _isPointerSwiping(): boolean;
  94986. /**
  94987. * Use this method to simulate a pointer up on a mesh
  94988. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94989. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94990. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94991. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  94992. */
  94993. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  94994. private _processPointerUp;
  94995. /**
  94996. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  94997. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  94998. * @returns true if the pointer was captured
  94999. */
  95000. isPointerCaptured(pointerId?: number): boolean;
  95001. /**
  95002. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  95003. * @param attachUp defines if you want to attach events to pointerup
  95004. * @param attachDown defines if you want to attach events to pointerdown
  95005. * @param attachMove defines if you want to attach events to pointermove
  95006. */
  95007. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  95008. /**
  95009. * Detaches all event handlers
  95010. */
  95011. detachControl(): void;
  95012. /**
  95013. * Force the value of meshUnderPointer
  95014. * @param mesh defines the mesh to use
  95015. */
  95016. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  95017. /**
  95018. * Gets the mesh under the pointer
  95019. * @returns a Mesh or null if no mesh is under the pointer
  95020. */
  95021. getPointerOverMesh(): Nullable<AbstractMesh>;
  95022. }
  95023. }
  95024. declare module BABYLON {
  95025. /**
  95026. * This class defines the direct association between an animation and a target
  95027. */
  95028. export class TargetedAnimation {
  95029. /**
  95030. * Animation to perform
  95031. */
  95032. animation: Animation;
  95033. /**
  95034. * Target to animate
  95035. */
  95036. target: any;
  95037. /**
  95038. * Serialize the object
  95039. * @returns the JSON object representing the current entity
  95040. */
  95041. serialize(): any;
  95042. }
  95043. /**
  95044. * Use this class to create coordinated animations on multiple targets
  95045. */
  95046. export class AnimationGroup implements IDisposable {
  95047. /** The name of the animation group */
  95048. name: string;
  95049. private _scene;
  95050. private _targetedAnimations;
  95051. private _animatables;
  95052. private _from;
  95053. private _to;
  95054. private _isStarted;
  95055. private _isPaused;
  95056. private _speedRatio;
  95057. private _loopAnimation;
  95058. /**
  95059. * Gets or sets the unique id of the node
  95060. */
  95061. uniqueId: number;
  95062. /**
  95063. * This observable will notify when one animation have ended
  95064. */
  95065. onAnimationEndObservable: Observable<TargetedAnimation>;
  95066. /**
  95067. * Observer raised when one animation loops
  95068. */
  95069. onAnimationLoopObservable: Observable<TargetedAnimation>;
  95070. /**
  95071. * This observable will notify when all animations have ended.
  95072. */
  95073. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  95074. /**
  95075. * This observable will notify when all animations have paused.
  95076. */
  95077. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  95078. /**
  95079. * This observable will notify when all animations are playing.
  95080. */
  95081. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  95082. /**
  95083. * Gets the first frame
  95084. */
  95085. readonly from: number;
  95086. /**
  95087. * Gets the last frame
  95088. */
  95089. readonly to: number;
  95090. /**
  95091. * Define if the animations are started
  95092. */
  95093. readonly isStarted: boolean;
  95094. /**
  95095. * Gets a value indicating that the current group is playing
  95096. */
  95097. readonly isPlaying: boolean;
  95098. /**
  95099. * Gets or sets the speed ratio to use for all animations
  95100. */
  95101. /**
  95102. * Gets or sets the speed ratio to use for all animations
  95103. */
  95104. speedRatio: number;
  95105. /**
  95106. * Gets or sets if all animations should loop or not
  95107. */
  95108. loopAnimation: boolean;
  95109. /**
  95110. * Gets the targeted animations for this animation group
  95111. */
  95112. readonly targetedAnimations: Array<TargetedAnimation>;
  95113. /**
  95114. * returning the list of animatables controlled by this animation group.
  95115. */
  95116. readonly animatables: Array<Animatable>;
  95117. /**
  95118. * Instantiates a new Animation Group.
  95119. * This helps managing several animations at once.
  95120. * @see http://doc.babylonjs.com/how_to/group
  95121. * @param name Defines the name of the group
  95122. * @param scene Defines the scene the group belongs to
  95123. */
  95124. constructor(
  95125. /** The name of the animation group */
  95126. name: string, scene?: Nullable<Scene>);
  95127. /**
  95128. * Add an animation (with its target) in the group
  95129. * @param animation defines the animation we want to add
  95130. * @param target defines the target of the animation
  95131. * @returns the TargetedAnimation object
  95132. */
  95133. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  95134. /**
  95135. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  95136. * It can add constant keys at begin or end
  95137. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  95138. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  95139. * @returns the animation group
  95140. */
  95141. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  95142. /**
  95143. * Start all animations on given targets
  95144. * @param loop defines if animations must loop
  95145. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  95146. * @param from defines the from key (optional)
  95147. * @param to defines the to key (optional)
  95148. * @returns the current animation group
  95149. */
  95150. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  95151. /**
  95152. * Pause all animations
  95153. * @returns the animation group
  95154. */
  95155. pause(): AnimationGroup;
  95156. /**
  95157. * Play all animations to initial state
  95158. * This function will start() the animations if they were not started or will restart() them if they were paused
  95159. * @param loop defines if animations must loop
  95160. * @returns the animation group
  95161. */
  95162. play(loop?: boolean): AnimationGroup;
  95163. /**
  95164. * Reset all animations to initial state
  95165. * @returns the animation group
  95166. */
  95167. reset(): AnimationGroup;
  95168. /**
  95169. * Restart animations from key 0
  95170. * @returns the animation group
  95171. */
  95172. restart(): AnimationGroup;
  95173. /**
  95174. * Stop all animations
  95175. * @returns the animation group
  95176. */
  95177. stop(): AnimationGroup;
  95178. /**
  95179. * Set animation weight for all animatables
  95180. * @param weight defines the weight to use
  95181. * @return the animationGroup
  95182. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  95183. */
  95184. setWeightForAllAnimatables(weight: number): AnimationGroup;
  95185. /**
  95186. * Synchronize and normalize all animatables with a source animatable
  95187. * @param root defines the root animatable to synchronize with
  95188. * @return the animationGroup
  95189. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  95190. */
  95191. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  95192. /**
  95193. * Goes to a specific frame in this animation group
  95194. * @param frame the frame number to go to
  95195. * @return the animationGroup
  95196. */
  95197. goToFrame(frame: number): AnimationGroup;
  95198. /**
  95199. * Dispose all associated resources
  95200. */
  95201. dispose(): void;
  95202. private _checkAnimationGroupEnded;
  95203. /**
  95204. * Clone the current animation group and returns a copy
  95205. * @param newName defines the name of the new group
  95206. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  95207. * @returns the new aniamtion group
  95208. */
  95209. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  95210. /**
  95211. * Serializes the animationGroup to an object
  95212. * @returns Serialized object
  95213. */
  95214. serialize(): any;
  95215. /**
  95216. * Returns a new AnimationGroup object parsed from the source provided.
  95217. * @param parsedAnimationGroup defines the source
  95218. * @param scene defines the scene that will receive the animationGroup
  95219. * @returns a new AnimationGroup
  95220. */
  95221. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  95222. /**
  95223. * Returns the string "AnimationGroup"
  95224. * @returns "AnimationGroup"
  95225. */
  95226. getClassName(): string;
  95227. /**
  95228. * Creates a detailled string about the object
  95229. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  95230. * @returns a string representing the object
  95231. */
  95232. toString(fullDetails?: boolean): string;
  95233. }
  95234. }
  95235. declare module BABYLON {
  95236. /**
  95237. * Define an interface for all classes that will hold resources
  95238. */
  95239. export interface IDisposable {
  95240. /**
  95241. * Releases all held resources
  95242. */
  95243. dispose(): void;
  95244. }
  95245. /** Interface defining initialization parameters for Scene class */
  95246. export interface SceneOptions {
  95247. /**
  95248. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  95249. * It will improve performance when the number of geometries becomes important.
  95250. */
  95251. useGeometryUniqueIdsMap?: boolean;
  95252. /**
  95253. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  95254. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  95255. */
  95256. useMaterialMeshMap?: boolean;
  95257. /**
  95258. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  95259. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  95260. */
  95261. useClonedMeshhMap?: boolean;
  95262. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  95263. virtual?: boolean;
  95264. }
  95265. /**
  95266. * Represents a scene to be rendered by the engine.
  95267. * @see http://doc.babylonjs.com/features/scene
  95268. */
  95269. export class Scene extends AbstractScene implements IAnimatable {
  95270. private static _uniqueIdCounter;
  95271. /** The fog is deactivated */
  95272. static readonly FOGMODE_NONE: number;
  95273. /** The fog density is following an exponential function */
  95274. static readonly FOGMODE_EXP: number;
  95275. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  95276. static readonly FOGMODE_EXP2: number;
  95277. /** The fog density is following a linear function. */
  95278. static readonly FOGMODE_LINEAR: number;
  95279. /**
  95280. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  95281. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95282. */
  95283. static MinDeltaTime: number;
  95284. /**
  95285. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  95286. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95287. */
  95288. static MaxDeltaTime: number;
  95289. /**
  95290. * Factory used to create the default material.
  95291. * @param name The name of the material to create
  95292. * @param scene The scene to create the material for
  95293. * @returns The default material
  95294. */
  95295. static DefaultMaterialFactory(scene: Scene): Material;
  95296. /**
  95297. * Factory used to create the a collision coordinator.
  95298. * @returns The collision coordinator
  95299. */
  95300. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  95301. /** @hidden */
  95302. _inputManager: InputManager;
  95303. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  95304. cameraToUseForPointers: Nullable<Camera>;
  95305. /** @hidden */
  95306. readonly _isScene: boolean;
  95307. /**
  95308. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  95309. */
  95310. autoClear: boolean;
  95311. /**
  95312. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  95313. */
  95314. autoClearDepthAndStencil: boolean;
  95315. /**
  95316. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  95317. */
  95318. clearColor: Color4;
  95319. /**
  95320. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  95321. */
  95322. ambientColor: Color3;
  95323. /**
  95324. * This is use to store the default BRDF lookup for PBR materials in your scene.
  95325. * It should only be one of the following (if not the default embedded one):
  95326. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  95327. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  95328. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  95329. * The material properties need to be setup according to the type of texture in use.
  95330. */
  95331. environmentBRDFTexture: BaseTexture;
  95332. /** @hidden */
  95333. protected _environmentTexture: Nullable<BaseTexture>;
  95334. /**
  95335. * Texture used in all pbr material as the reflection texture.
  95336. * As in the majority of the scene they are the same (exception for multi room and so on),
  95337. * this is easier to reference from here than from all the materials.
  95338. */
  95339. /**
  95340. * Texture used in all pbr material as the reflection texture.
  95341. * As in the majority of the scene they are the same (exception for multi room and so on),
  95342. * this is easier to set here than in all the materials.
  95343. */
  95344. environmentTexture: Nullable<BaseTexture>;
  95345. /** @hidden */
  95346. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95347. /**
  95348. * Default image processing configuration used either in the rendering
  95349. * Forward main pass or through the imageProcessingPostProcess if present.
  95350. * As in the majority of the scene they are the same (exception for multi camera),
  95351. * this is easier to reference from here than from all the materials and post process.
  95352. *
  95353. * No setter as we it is a shared configuration, you can set the values instead.
  95354. */
  95355. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  95356. private _forceWireframe;
  95357. /**
  95358. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  95359. */
  95360. forceWireframe: boolean;
  95361. private _forcePointsCloud;
  95362. /**
  95363. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  95364. */
  95365. forcePointsCloud: boolean;
  95366. /**
  95367. * Gets or sets the active clipplane 1
  95368. */
  95369. clipPlane: Nullable<Plane>;
  95370. /**
  95371. * Gets or sets the active clipplane 2
  95372. */
  95373. clipPlane2: Nullable<Plane>;
  95374. /**
  95375. * Gets or sets the active clipplane 3
  95376. */
  95377. clipPlane3: Nullable<Plane>;
  95378. /**
  95379. * Gets or sets the active clipplane 4
  95380. */
  95381. clipPlane4: Nullable<Plane>;
  95382. /**
  95383. * Gets or sets a boolean indicating if animations are enabled
  95384. */
  95385. animationsEnabled: boolean;
  95386. private _animationPropertiesOverride;
  95387. /**
  95388. * Gets or sets the animation properties override
  95389. */
  95390. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  95391. /**
  95392. * Gets or sets a boolean indicating if a constant deltatime has to be used
  95393. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  95394. */
  95395. useConstantAnimationDeltaTime: boolean;
  95396. /**
  95397. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  95398. * Please note that it requires to run a ray cast through the scene on every frame
  95399. */
  95400. constantlyUpdateMeshUnderPointer: boolean;
  95401. /**
  95402. * Defines the HTML cursor to use when hovering over interactive elements
  95403. */
  95404. hoverCursor: string;
  95405. /**
  95406. * Defines the HTML default cursor to use (empty by default)
  95407. */
  95408. defaultCursor: string;
  95409. /**
  95410. * This is used to call preventDefault() on pointer down
  95411. * in order to block unwanted artifacts like system double clicks
  95412. */
  95413. preventDefaultOnPointerDown: boolean;
  95414. /**
  95415. * This is used to call preventDefault() on pointer up
  95416. * in order to block unwanted artifacts like system double clicks
  95417. */
  95418. preventDefaultOnPointerUp: boolean;
  95419. /**
  95420. * Gets or sets user defined metadata
  95421. */
  95422. metadata: any;
  95423. /**
  95424. * For internal use only. Please do not use.
  95425. */
  95426. reservedDataStore: any;
  95427. /**
  95428. * Gets the name of the plugin used to load this scene (null by default)
  95429. */
  95430. loadingPluginName: string;
  95431. /**
  95432. * Use this array to add regular expressions used to disable offline support for specific urls
  95433. */
  95434. disableOfflineSupportExceptionRules: RegExp[];
  95435. /**
  95436. * An event triggered when the scene is disposed.
  95437. */
  95438. onDisposeObservable: Observable<Scene>;
  95439. private _onDisposeObserver;
  95440. /** Sets a function to be executed when this scene is disposed. */
  95441. onDispose: () => void;
  95442. /**
  95443. * An event triggered before rendering the scene (right after animations and physics)
  95444. */
  95445. onBeforeRenderObservable: Observable<Scene>;
  95446. private _onBeforeRenderObserver;
  95447. /** Sets a function to be executed before rendering this scene */
  95448. beforeRender: Nullable<() => void>;
  95449. /**
  95450. * An event triggered after rendering the scene
  95451. */
  95452. onAfterRenderObservable: Observable<Scene>;
  95453. /**
  95454. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  95455. */
  95456. onAfterRenderCameraObservable: Observable<Camera>;
  95457. private _onAfterRenderObserver;
  95458. /** Sets a function to be executed after rendering this scene */
  95459. afterRender: Nullable<() => void>;
  95460. /**
  95461. * An event triggered before animating the scene
  95462. */
  95463. onBeforeAnimationsObservable: Observable<Scene>;
  95464. /**
  95465. * An event triggered after animations processing
  95466. */
  95467. onAfterAnimationsObservable: Observable<Scene>;
  95468. /**
  95469. * An event triggered before draw calls are ready to be sent
  95470. */
  95471. onBeforeDrawPhaseObservable: Observable<Scene>;
  95472. /**
  95473. * An event triggered after draw calls have been sent
  95474. */
  95475. onAfterDrawPhaseObservable: Observable<Scene>;
  95476. /**
  95477. * An event triggered when the scene is ready
  95478. */
  95479. onReadyObservable: Observable<Scene>;
  95480. /**
  95481. * An event triggered before rendering a camera
  95482. */
  95483. onBeforeCameraRenderObservable: Observable<Camera>;
  95484. private _onBeforeCameraRenderObserver;
  95485. /** Sets a function to be executed before rendering a camera*/
  95486. beforeCameraRender: () => void;
  95487. /**
  95488. * An event triggered after rendering a camera
  95489. */
  95490. onAfterCameraRenderObservable: Observable<Camera>;
  95491. private _onAfterCameraRenderObserver;
  95492. /** Sets a function to be executed after rendering a camera*/
  95493. afterCameraRender: () => void;
  95494. /**
  95495. * An event triggered when active meshes evaluation is about to start
  95496. */
  95497. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  95498. /**
  95499. * An event triggered when active meshes evaluation is done
  95500. */
  95501. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  95502. /**
  95503. * An event triggered when particles rendering is about to start
  95504. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  95505. */
  95506. onBeforeParticlesRenderingObservable: Observable<Scene>;
  95507. /**
  95508. * An event triggered when particles rendering is done
  95509. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  95510. */
  95511. onAfterParticlesRenderingObservable: Observable<Scene>;
  95512. /**
  95513. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  95514. */
  95515. onDataLoadedObservable: Observable<Scene>;
  95516. /**
  95517. * An event triggered when a camera is created
  95518. */
  95519. onNewCameraAddedObservable: Observable<Camera>;
  95520. /**
  95521. * An event triggered when a camera is removed
  95522. */
  95523. onCameraRemovedObservable: Observable<Camera>;
  95524. /**
  95525. * An event triggered when a light is created
  95526. */
  95527. onNewLightAddedObservable: Observable<Light>;
  95528. /**
  95529. * An event triggered when a light is removed
  95530. */
  95531. onLightRemovedObservable: Observable<Light>;
  95532. /**
  95533. * An event triggered when a geometry is created
  95534. */
  95535. onNewGeometryAddedObservable: Observable<Geometry>;
  95536. /**
  95537. * An event triggered when a geometry is removed
  95538. */
  95539. onGeometryRemovedObservable: Observable<Geometry>;
  95540. /**
  95541. * An event triggered when a transform node is created
  95542. */
  95543. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  95544. /**
  95545. * An event triggered when a transform node is removed
  95546. */
  95547. onTransformNodeRemovedObservable: Observable<TransformNode>;
  95548. /**
  95549. * An event triggered when a mesh is created
  95550. */
  95551. onNewMeshAddedObservable: Observable<AbstractMesh>;
  95552. /**
  95553. * An event triggered when a mesh is removed
  95554. */
  95555. onMeshRemovedObservable: Observable<AbstractMesh>;
  95556. /**
  95557. * An event triggered when a skeleton is created
  95558. */
  95559. onNewSkeletonAddedObservable: Observable<Skeleton>;
  95560. /**
  95561. * An event triggered when a skeleton is removed
  95562. */
  95563. onSkeletonRemovedObservable: Observable<Skeleton>;
  95564. /**
  95565. * An event triggered when a material is created
  95566. */
  95567. onNewMaterialAddedObservable: Observable<Material>;
  95568. /**
  95569. * An event triggered when a material is removed
  95570. */
  95571. onMaterialRemovedObservable: Observable<Material>;
  95572. /**
  95573. * An event triggered when a texture is created
  95574. */
  95575. onNewTextureAddedObservable: Observable<BaseTexture>;
  95576. /**
  95577. * An event triggered when a texture is removed
  95578. */
  95579. onTextureRemovedObservable: Observable<BaseTexture>;
  95580. /**
  95581. * An event triggered when render targets are about to be rendered
  95582. * Can happen multiple times per frame.
  95583. */
  95584. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  95585. /**
  95586. * An event triggered when render targets were rendered.
  95587. * Can happen multiple times per frame.
  95588. */
  95589. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  95590. /**
  95591. * An event triggered before calculating deterministic simulation step
  95592. */
  95593. onBeforeStepObservable: Observable<Scene>;
  95594. /**
  95595. * An event triggered after calculating deterministic simulation step
  95596. */
  95597. onAfterStepObservable: Observable<Scene>;
  95598. /**
  95599. * An event triggered when the activeCamera property is updated
  95600. */
  95601. onActiveCameraChanged: Observable<Scene>;
  95602. /**
  95603. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  95604. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  95605. * 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)
  95606. */
  95607. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  95608. /**
  95609. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  95610. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  95611. * 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)
  95612. */
  95613. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  95614. /**
  95615. * This Observable will when a mesh has been imported into the scene.
  95616. */
  95617. onMeshImportedObservable: Observable<AbstractMesh>;
  95618. /**
  95619. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  95620. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  95621. */
  95622. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  95623. /** @hidden */
  95624. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  95625. /**
  95626. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  95627. */
  95628. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  95629. /**
  95630. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  95631. */
  95632. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  95633. /**
  95634. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  95635. */
  95636. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  95637. /** Callback called when a pointer move is detected */
  95638. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  95639. /** Callback called when a pointer down is detected */
  95640. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  95641. /** Callback called when a pointer up is detected */
  95642. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  95643. /** Callback called when a pointer pick is detected */
  95644. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  95645. /**
  95646. * 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).
  95647. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  95648. */
  95649. onPrePointerObservable: Observable<PointerInfoPre>;
  95650. /**
  95651. * Observable event triggered each time an input event is received from the rendering canvas
  95652. */
  95653. onPointerObservable: Observable<PointerInfo>;
  95654. /**
  95655. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  95656. */
  95657. readonly unTranslatedPointer: Vector2;
  95658. /**
  95659. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  95660. */
  95661. static DragMovementThreshold: number;
  95662. /**
  95663. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  95664. */
  95665. static LongPressDelay: number;
  95666. /**
  95667. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  95668. */
  95669. static DoubleClickDelay: number;
  95670. /** If you need to check double click without raising a single click at first click, enable this flag */
  95671. static ExclusiveDoubleClickMode: boolean;
  95672. /** @hidden */
  95673. _mirroredCameraPosition: Nullable<Vector3>;
  95674. /**
  95675. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  95676. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  95677. */
  95678. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  95679. /**
  95680. * Observable event triggered each time an keyboard event is received from the hosting window
  95681. */
  95682. onKeyboardObservable: Observable<KeyboardInfo>;
  95683. private _useRightHandedSystem;
  95684. /**
  95685. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  95686. */
  95687. useRightHandedSystem: boolean;
  95688. private _timeAccumulator;
  95689. private _currentStepId;
  95690. private _currentInternalStep;
  95691. /**
  95692. * Sets the step Id used by deterministic lock step
  95693. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95694. * @param newStepId defines the step Id
  95695. */
  95696. setStepId(newStepId: number): void;
  95697. /**
  95698. * Gets the step Id used by deterministic lock step
  95699. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95700. * @returns the step Id
  95701. */
  95702. getStepId(): number;
  95703. /**
  95704. * Gets the internal step used by deterministic lock step
  95705. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95706. * @returns the internal step
  95707. */
  95708. getInternalStep(): number;
  95709. private _fogEnabled;
  95710. /**
  95711. * Gets or sets a boolean indicating if fog is enabled on this scene
  95712. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95713. * (Default is true)
  95714. */
  95715. fogEnabled: boolean;
  95716. private _fogMode;
  95717. /**
  95718. * Gets or sets the fog mode to use
  95719. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95720. * | mode | value |
  95721. * | --- | --- |
  95722. * | FOGMODE_NONE | 0 |
  95723. * | FOGMODE_EXP | 1 |
  95724. * | FOGMODE_EXP2 | 2 |
  95725. * | FOGMODE_LINEAR | 3 |
  95726. */
  95727. fogMode: number;
  95728. /**
  95729. * Gets or sets the fog color to use
  95730. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95731. * (Default is Color3(0.2, 0.2, 0.3))
  95732. */
  95733. fogColor: Color3;
  95734. /**
  95735. * Gets or sets the fog density to use
  95736. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95737. * (Default is 0.1)
  95738. */
  95739. fogDensity: number;
  95740. /**
  95741. * Gets or sets the fog start distance to use
  95742. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95743. * (Default is 0)
  95744. */
  95745. fogStart: number;
  95746. /**
  95747. * Gets or sets the fog end distance to use
  95748. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95749. * (Default is 1000)
  95750. */
  95751. fogEnd: number;
  95752. private _shadowsEnabled;
  95753. /**
  95754. * Gets or sets a boolean indicating if shadows are enabled on this scene
  95755. */
  95756. shadowsEnabled: boolean;
  95757. private _lightsEnabled;
  95758. /**
  95759. * Gets or sets a boolean indicating if lights are enabled on this scene
  95760. */
  95761. lightsEnabled: boolean;
  95762. /** All of the active cameras added to this scene. */
  95763. activeCameras: Camera[];
  95764. /** @hidden */
  95765. _activeCamera: Nullable<Camera>;
  95766. /** Gets or sets the current active camera */
  95767. activeCamera: Nullable<Camera>;
  95768. private _defaultMaterial;
  95769. /** The default material used on meshes when no material is affected */
  95770. /** The default material used on meshes when no material is affected */
  95771. defaultMaterial: Material;
  95772. private _texturesEnabled;
  95773. /**
  95774. * Gets or sets a boolean indicating if textures are enabled on this scene
  95775. */
  95776. texturesEnabled: boolean;
  95777. /**
  95778. * Gets or sets a boolean indicating if particles are enabled on this scene
  95779. */
  95780. particlesEnabled: boolean;
  95781. /**
  95782. * Gets or sets a boolean indicating if sprites are enabled on this scene
  95783. */
  95784. spritesEnabled: boolean;
  95785. private _skeletonsEnabled;
  95786. /**
  95787. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  95788. */
  95789. skeletonsEnabled: boolean;
  95790. /**
  95791. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  95792. */
  95793. lensFlaresEnabled: boolean;
  95794. /**
  95795. * Gets or sets a boolean indicating if collisions are enabled on this scene
  95796. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95797. */
  95798. collisionsEnabled: boolean;
  95799. private _collisionCoordinator;
  95800. /** @hidden */
  95801. readonly collisionCoordinator: ICollisionCoordinator;
  95802. /**
  95803. * Defines the gravity applied to this scene (used only for collisions)
  95804. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95805. */
  95806. gravity: Vector3;
  95807. /**
  95808. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  95809. */
  95810. postProcessesEnabled: boolean;
  95811. /**
  95812. * The list of postprocesses added to the scene
  95813. */
  95814. postProcesses: PostProcess[];
  95815. /**
  95816. * Gets the current postprocess manager
  95817. */
  95818. postProcessManager: PostProcessManager;
  95819. /**
  95820. * Gets or sets a boolean indicating if render targets are enabled on this scene
  95821. */
  95822. renderTargetsEnabled: boolean;
  95823. /**
  95824. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  95825. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  95826. */
  95827. dumpNextRenderTargets: boolean;
  95828. /**
  95829. * The list of user defined render targets added to the scene
  95830. */
  95831. customRenderTargets: RenderTargetTexture[];
  95832. /**
  95833. * Defines if texture loading must be delayed
  95834. * If true, textures will only be loaded when they need to be rendered
  95835. */
  95836. useDelayedTextureLoading: boolean;
  95837. /**
  95838. * Gets the list of meshes imported to the scene through SceneLoader
  95839. */
  95840. importedMeshesFiles: String[];
  95841. /**
  95842. * Gets or sets a boolean indicating if probes are enabled on this scene
  95843. */
  95844. probesEnabled: boolean;
  95845. /**
  95846. * Gets or sets the current offline provider to use to store scene data
  95847. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  95848. */
  95849. offlineProvider: IOfflineProvider;
  95850. /**
  95851. * Gets or sets the action manager associated with the scene
  95852. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  95853. */
  95854. actionManager: AbstractActionManager;
  95855. private _meshesForIntersections;
  95856. /**
  95857. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  95858. */
  95859. proceduralTexturesEnabled: boolean;
  95860. private _engine;
  95861. private _totalVertices;
  95862. /** @hidden */
  95863. _activeIndices: PerfCounter;
  95864. /** @hidden */
  95865. _activeParticles: PerfCounter;
  95866. /** @hidden */
  95867. _activeBones: PerfCounter;
  95868. private _animationRatio;
  95869. /** @hidden */
  95870. _animationTimeLast: number;
  95871. /** @hidden */
  95872. _animationTime: number;
  95873. /**
  95874. * Gets or sets a general scale for animation speed
  95875. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  95876. */
  95877. animationTimeScale: number;
  95878. /** @hidden */
  95879. _cachedMaterial: Nullable<Material>;
  95880. /** @hidden */
  95881. _cachedEffect: Nullable<Effect>;
  95882. /** @hidden */
  95883. _cachedVisibility: Nullable<number>;
  95884. private _renderId;
  95885. private _frameId;
  95886. private _executeWhenReadyTimeoutId;
  95887. private _intermediateRendering;
  95888. private _viewUpdateFlag;
  95889. private _projectionUpdateFlag;
  95890. /** @hidden */
  95891. _toBeDisposed: Nullable<IDisposable>[];
  95892. private _activeRequests;
  95893. /** @hidden */
  95894. _pendingData: any[];
  95895. private _isDisposed;
  95896. /**
  95897. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  95898. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  95899. */
  95900. dispatchAllSubMeshesOfActiveMeshes: boolean;
  95901. private _activeMeshes;
  95902. private _processedMaterials;
  95903. private _renderTargets;
  95904. /** @hidden */
  95905. _activeParticleSystems: SmartArray<IParticleSystem>;
  95906. private _activeSkeletons;
  95907. private _softwareSkinnedMeshes;
  95908. private _renderingManager;
  95909. /** @hidden */
  95910. _activeAnimatables: Animatable[];
  95911. private _transformMatrix;
  95912. private _sceneUbo;
  95913. /** @hidden */
  95914. _viewMatrix: Matrix;
  95915. private _projectionMatrix;
  95916. /** @hidden */
  95917. _forcedViewPosition: Nullable<Vector3>;
  95918. /** @hidden */
  95919. _frustumPlanes: Plane[];
  95920. /**
  95921. * Gets the list of frustum planes (built from the active camera)
  95922. */
  95923. readonly frustumPlanes: Plane[];
  95924. /**
  95925. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  95926. * This is useful if there are more lights that the maximum simulteanous authorized
  95927. */
  95928. requireLightSorting: boolean;
  95929. /** @hidden */
  95930. readonly useMaterialMeshMap: boolean;
  95931. /** @hidden */
  95932. readonly useClonedMeshhMap: boolean;
  95933. private _externalData;
  95934. private _uid;
  95935. /**
  95936. * @hidden
  95937. * Backing store of defined scene components.
  95938. */
  95939. _components: ISceneComponent[];
  95940. /**
  95941. * @hidden
  95942. * Backing store of defined scene components.
  95943. */
  95944. _serializableComponents: ISceneSerializableComponent[];
  95945. /**
  95946. * List of components to register on the next registration step.
  95947. */
  95948. private _transientComponents;
  95949. /**
  95950. * Registers the transient components if needed.
  95951. */
  95952. private _registerTransientComponents;
  95953. /**
  95954. * @hidden
  95955. * Add a component to the scene.
  95956. * Note that the ccomponent could be registered on th next frame if this is called after
  95957. * the register component stage.
  95958. * @param component Defines the component to add to the scene
  95959. */
  95960. _addComponent(component: ISceneComponent): void;
  95961. /**
  95962. * @hidden
  95963. * Gets a component from the scene.
  95964. * @param name defines the name of the component to retrieve
  95965. * @returns the component or null if not present
  95966. */
  95967. _getComponent(name: string): Nullable<ISceneComponent>;
  95968. /**
  95969. * @hidden
  95970. * Defines the actions happening before camera updates.
  95971. */
  95972. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  95973. /**
  95974. * @hidden
  95975. * Defines the actions happening before clear the canvas.
  95976. */
  95977. _beforeClearStage: Stage<SimpleStageAction>;
  95978. /**
  95979. * @hidden
  95980. * Defines the actions when collecting render targets for the frame.
  95981. */
  95982. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  95983. /**
  95984. * @hidden
  95985. * Defines the actions happening for one camera in the frame.
  95986. */
  95987. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  95988. /**
  95989. * @hidden
  95990. * Defines the actions happening during the per mesh ready checks.
  95991. */
  95992. _isReadyForMeshStage: Stage<MeshStageAction>;
  95993. /**
  95994. * @hidden
  95995. * Defines the actions happening before evaluate active mesh checks.
  95996. */
  95997. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  95998. /**
  95999. * @hidden
  96000. * Defines the actions happening during the evaluate sub mesh checks.
  96001. */
  96002. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  96003. /**
  96004. * @hidden
  96005. * Defines the actions happening during the active mesh stage.
  96006. */
  96007. _activeMeshStage: Stage<ActiveMeshStageAction>;
  96008. /**
  96009. * @hidden
  96010. * Defines the actions happening during the per camera render target step.
  96011. */
  96012. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  96013. /**
  96014. * @hidden
  96015. * Defines the actions happening just before the active camera is drawing.
  96016. */
  96017. _beforeCameraDrawStage: Stage<CameraStageAction>;
  96018. /**
  96019. * @hidden
  96020. * Defines the actions happening just before a render target is drawing.
  96021. */
  96022. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  96023. /**
  96024. * @hidden
  96025. * Defines the actions happening just before a rendering group is drawing.
  96026. */
  96027. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  96028. /**
  96029. * @hidden
  96030. * Defines the actions happening just before a mesh is drawing.
  96031. */
  96032. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  96033. /**
  96034. * @hidden
  96035. * Defines the actions happening just after a mesh has been drawn.
  96036. */
  96037. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  96038. /**
  96039. * @hidden
  96040. * Defines the actions happening just after a rendering group has been drawn.
  96041. */
  96042. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  96043. /**
  96044. * @hidden
  96045. * Defines the actions happening just after the active camera has been drawn.
  96046. */
  96047. _afterCameraDrawStage: Stage<CameraStageAction>;
  96048. /**
  96049. * @hidden
  96050. * Defines the actions happening just after a render target has been drawn.
  96051. */
  96052. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  96053. /**
  96054. * @hidden
  96055. * Defines the actions happening just after rendering all cameras and computing intersections.
  96056. */
  96057. _afterRenderStage: Stage<SimpleStageAction>;
  96058. /**
  96059. * @hidden
  96060. * Defines the actions happening when a pointer move event happens.
  96061. */
  96062. _pointerMoveStage: Stage<PointerMoveStageAction>;
  96063. /**
  96064. * @hidden
  96065. * Defines the actions happening when a pointer down event happens.
  96066. */
  96067. _pointerDownStage: Stage<PointerUpDownStageAction>;
  96068. /**
  96069. * @hidden
  96070. * Defines the actions happening when a pointer up event happens.
  96071. */
  96072. _pointerUpStage: Stage<PointerUpDownStageAction>;
  96073. /**
  96074. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  96075. */
  96076. private geometriesByUniqueId;
  96077. /**
  96078. * Creates a new Scene
  96079. * @param engine defines the engine to use to render this scene
  96080. * @param options defines the scene options
  96081. */
  96082. constructor(engine: Engine, options?: SceneOptions);
  96083. /**
  96084. * Gets a string idenfifying the name of the class
  96085. * @returns "Scene" string
  96086. */
  96087. getClassName(): string;
  96088. private _defaultMeshCandidates;
  96089. /**
  96090. * @hidden
  96091. */
  96092. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  96093. private _defaultSubMeshCandidates;
  96094. /**
  96095. * @hidden
  96096. */
  96097. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  96098. /**
  96099. * Sets the default candidate providers for the scene.
  96100. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  96101. * and getCollidingSubMeshCandidates to their default function
  96102. */
  96103. setDefaultCandidateProviders(): void;
  96104. /**
  96105. * Gets the mesh that is currently under the pointer
  96106. */
  96107. readonly meshUnderPointer: Nullable<AbstractMesh>;
  96108. /**
  96109. * Gets or sets the current on-screen X position of the pointer
  96110. */
  96111. pointerX: number;
  96112. /**
  96113. * Gets or sets the current on-screen Y position of the pointer
  96114. */
  96115. pointerY: number;
  96116. /**
  96117. * Gets the cached material (ie. the latest rendered one)
  96118. * @returns the cached material
  96119. */
  96120. getCachedMaterial(): Nullable<Material>;
  96121. /**
  96122. * Gets the cached effect (ie. the latest rendered one)
  96123. * @returns the cached effect
  96124. */
  96125. getCachedEffect(): Nullable<Effect>;
  96126. /**
  96127. * Gets the cached visibility state (ie. the latest rendered one)
  96128. * @returns the cached visibility state
  96129. */
  96130. getCachedVisibility(): Nullable<number>;
  96131. /**
  96132. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  96133. * @param material defines the current material
  96134. * @param effect defines the current effect
  96135. * @param visibility defines the current visibility state
  96136. * @returns true if one parameter is not cached
  96137. */
  96138. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  96139. /**
  96140. * Gets the engine associated with the scene
  96141. * @returns an Engine
  96142. */
  96143. getEngine(): Engine;
  96144. /**
  96145. * Gets the total number of vertices rendered per frame
  96146. * @returns the total number of vertices rendered per frame
  96147. */
  96148. getTotalVertices(): number;
  96149. /**
  96150. * Gets the performance counter for total vertices
  96151. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  96152. */
  96153. readonly totalVerticesPerfCounter: PerfCounter;
  96154. /**
  96155. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  96156. * @returns the total number of active indices rendered per frame
  96157. */
  96158. getActiveIndices(): number;
  96159. /**
  96160. * Gets the performance counter for active indices
  96161. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  96162. */
  96163. readonly totalActiveIndicesPerfCounter: PerfCounter;
  96164. /**
  96165. * Gets the total number of active particles rendered per frame
  96166. * @returns the total number of active particles rendered per frame
  96167. */
  96168. getActiveParticles(): number;
  96169. /**
  96170. * Gets the performance counter for active particles
  96171. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  96172. */
  96173. readonly activeParticlesPerfCounter: PerfCounter;
  96174. /**
  96175. * Gets the total number of active bones rendered per frame
  96176. * @returns the total number of active bones rendered per frame
  96177. */
  96178. getActiveBones(): number;
  96179. /**
  96180. * Gets the performance counter for active bones
  96181. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  96182. */
  96183. readonly activeBonesPerfCounter: PerfCounter;
  96184. /**
  96185. * Gets the array of active meshes
  96186. * @returns an array of AbstractMesh
  96187. */
  96188. getActiveMeshes(): SmartArray<AbstractMesh>;
  96189. /**
  96190. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  96191. * @returns a number
  96192. */
  96193. getAnimationRatio(): number;
  96194. /**
  96195. * Gets an unique Id for the current render phase
  96196. * @returns a number
  96197. */
  96198. getRenderId(): number;
  96199. /**
  96200. * Gets an unique Id for the current frame
  96201. * @returns a number
  96202. */
  96203. getFrameId(): number;
  96204. /** Call this function if you want to manually increment the render Id*/
  96205. incrementRenderId(): void;
  96206. private _createUbo;
  96207. /**
  96208. * Use this method to simulate a pointer move on a mesh
  96209. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96210. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96211. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96212. * @returns the current scene
  96213. */
  96214. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  96215. /**
  96216. * Use this method to simulate a pointer down on a mesh
  96217. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96218. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96219. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96220. * @returns the current scene
  96221. */
  96222. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  96223. /**
  96224. * Use this method to simulate a pointer up on a mesh
  96225. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96226. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96227. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96228. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  96229. * @returns the current scene
  96230. */
  96231. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  96232. /**
  96233. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  96234. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  96235. * @returns true if the pointer was captured
  96236. */
  96237. isPointerCaptured(pointerId?: number): boolean;
  96238. /**
  96239. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  96240. * @param attachUp defines if you want to attach events to pointerup
  96241. * @param attachDown defines if you want to attach events to pointerdown
  96242. * @param attachMove defines if you want to attach events to pointermove
  96243. */
  96244. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  96245. /** Detaches all event handlers*/
  96246. detachControl(): void;
  96247. /**
  96248. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  96249. * Delay loaded resources are not taking in account
  96250. * @return true if all required resources are ready
  96251. */
  96252. isReady(): boolean;
  96253. /** Resets all cached information relative to material (including effect and visibility) */
  96254. resetCachedMaterial(): void;
  96255. /**
  96256. * Registers a function to be called before every frame render
  96257. * @param func defines the function to register
  96258. */
  96259. registerBeforeRender(func: () => void): void;
  96260. /**
  96261. * Unregisters a function called before every frame render
  96262. * @param func defines the function to unregister
  96263. */
  96264. unregisterBeforeRender(func: () => void): void;
  96265. /**
  96266. * Registers a function to be called after every frame render
  96267. * @param func defines the function to register
  96268. */
  96269. registerAfterRender(func: () => void): void;
  96270. /**
  96271. * Unregisters a function called after every frame render
  96272. * @param func defines the function to unregister
  96273. */
  96274. unregisterAfterRender(func: () => void): void;
  96275. private _executeOnceBeforeRender;
  96276. /**
  96277. * The provided function will run before render once and will be disposed afterwards.
  96278. * A timeout delay can be provided so that the function will be executed in N ms.
  96279. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  96280. * @param func The function to be executed.
  96281. * @param timeout optional delay in ms
  96282. */
  96283. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  96284. /** @hidden */
  96285. _addPendingData(data: any): void;
  96286. /** @hidden */
  96287. _removePendingData(data: any): void;
  96288. /**
  96289. * Returns the number of items waiting to be loaded
  96290. * @returns the number of items waiting to be loaded
  96291. */
  96292. getWaitingItemsCount(): number;
  96293. /**
  96294. * Returns a boolean indicating if the scene is still loading data
  96295. */
  96296. readonly isLoading: boolean;
  96297. /**
  96298. * Registers a function to be executed when the scene is ready
  96299. * @param {Function} func - the function to be executed
  96300. */
  96301. executeWhenReady(func: () => void): void;
  96302. /**
  96303. * Returns a promise that resolves when the scene is ready
  96304. * @returns A promise that resolves when the scene is ready
  96305. */
  96306. whenReadyAsync(): Promise<void>;
  96307. /** @hidden */
  96308. _checkIsReady(): void;
  96309. /**
  96310. * Gets all animatable attached to the scene
  96311. */
  96312. readonly animatables: Animatable[];
  96313. /**
  96314. * Resets the last animation time frame.
  96315. * Useful to override when animations start running when loading a scene for the first time.
  96316. */
  96317. resetLastAnimationTimeFrame(): void;
  96318. /**
  96319. * Gets the current view matrix
  96320. * @returns a Matrix
  96321. */
  96322. getViewMatrix(): Matrix;
  96323. /**
  96324. * Gets the current projection matrix
  96325. * @returns a Matrix
  96326. */
  96327. getProjectionMatrix(): Matrix;
  96328. /**
  96329. * Gets the current transform matrix
  96330. * @returns a Matrix made of View * Projection
  96331. */
  96332. getTransformMatrix(): Matrix;
  96333. /**
  96334. * Sets the current transform matrix
  96335. * @param viewL defines the View matrix to use
  96336. * @param projectionL defines the Projection matrix to use
  96337. * @param viewR defines the right View matrix to use (if provided)
  96338. * @param projectionR defines the right Projection matrix to use (if provided)
  96339. */
  96340. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  96341. /**
  96342. * Gets the uniform buffer used to store scene data
  96343. * @returns a UniformBuffer
  96344. */
  96345. getSceneUniformBuffer(): UniformBuffer;
  96346. /**
  96347. * Gets an unique (relatively to the current scene) Id
  96348. * @returns an unique number for the scene
  96349. */
  96350. getUniqueId(): number;
  96351. /**
  96352. * Add a mesh to the list of scene's meshes
  96353. * @param newMesh defines the mesh to add
  96354. * @param recursive if all child meshes should also be added to the scene
  96355. */
  96356. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  96357. /**
  96358. * Remove a mesh for the list of scene's meshes
  96359. * @param toRemove defines the mesh to remove
  96360. * @param recursive if all child meshes should also be removed from the scene
  96361. * @returns the index where the mesh was in the mesh list
  96362. */
  96363. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  96364. /**
  96365. * Add a transform node to the list of scene's transform nodes
  96366. * @param newTransformNode defines the transform node to add
  96367. */
  96368. addTransformNode(newTransformNode: TransformNode): void;
  96369. /**
  96370. * Remove a transform node for the list of scene's transform nodes
  96371. * @param toRemove defines the transform node to remove
  96372. * @returns the index where the transform node was in the transform node list
  96373. */
  96374. removeTransformNode(toRemove: TransformNode): number;
  96375. /**
  96376. * Remove a skeleton for the list of scene's skeletons
  96377. * @param toRemove defines the skeleton to remove
  96378. * @returns the index where the skeleton was in the skeleton list
  96379. */
  96380. removeSkeleton(toRemove: Skeleton): number;
  96381. /**
  96382. * Remove a morph target for the list of scene's morph targets
  96383. * @param toRemove defines the morph target to remove
  96384. * @returns the index where the morph target was in the morph target list
  96385. */
  96386. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  96387. /**
  96388. * Remove a light for the list of scene's lights
  96389. * @param toRemove defines the light to remove
  96390. * @returns the index where the light was in the light list
  96391. */
  96392. removeLight(toRemove: Light): number;
  96393. /**
  96394. * Remove a camera for the list of scene's cameras
  96395. * @param toRemove defines the camera to remove
  96396. * @returns the index where the camera was in the camera list
  96397. */
  96398. removeCamera(toRemove: Camera): number;
  96399. /**
  96400. * Remove a particle system for the list of scene's particle systems
  96401. * @param toRemove defines the particle system to remove
  96402. * @returns the index where the particle system was in the particle system list
  96403. */
  96404. removeParticleSystem(toRemove: IParticleSystem): number;
  96405. /**
  96406. * Remove a animation for the list of scene's animations
  96407. * @param toRemove defines the animation to remove
  96408. * @returns the index where the animation was in the animation list
  96409. */
  96410. removeAnimation(toRemove: Animation): number;
  96411. /**
  96412. * Will stop the animation of the given target
  96413. * @param target - the target
  96414. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  96415. * @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)
  96416. */
  96417. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  96418. /**
  96419. * Removes the given animation group from this scene.
  96420. * @param toRemove The animation group to remove
  96421. * @returns The index of the removed animation group
  96422. */
  96423. removeAnimationGroup(toRemove: AnimationGroup): number;
  96424. /**
  96425. * Removes the given multi-material from this scene.
  96426. * @param toRemove The multi-material to remove
  96427. * @returns The index of the removed multi-material
  96428. */
  96429. removeMultiMaterial(toRemove: MultiMaterial): number;
  96430. /**
  96431. * Removes the given material from this scene.
  96432. * @param toRemove The material to remove
  96433. * @returns The index of the removed material
  96434. */
  96435. removeMaterial(toRemove: Material): number;
  96436. /**
  96437. * Removes the given action manager from this scene.
  96438. * @param toRemove The action manager to remove
  96439. * @returns The index of the removed action manager
  96440. */
  96441. removeActionManager(toRemove: AbstractActionManager): number;
  96442. /**
  96443. * Removes the given texture from this scene.
  96444. * @param toRemove The texture to remove
  96445. * @returns The index of the removed texture
  96446. */
  96447. removeTexture(toRemove: BaseTexture): number;
  96448. /**
  96449. * Adds the given light to this scene
  96450. * @param newLight The light to add
  96451. */
  96452. addLight(newLight: Light): void;
  96453. /**
  96454. * Sorts the list list based on light priorities
  96455. */
  96456. sortLightsByPriority(): void;
  96457. /**
  96458. * Adds the given camera to this scene
  96459. * @param newCamera The camera to add
  96460. */
  96461. addCamera(newCamera: Camera): void;
  96462. /**
  96463. * Adds the given skeleton to this scene
  96464. * @param newSkeleton The skeleton to add
  96465. */
  96466. addSkeleton(newSkeleton: Skeleton): void;
  96467. /**
  96468. * Adds the given particle system to this scene
  96469. * @param newParticleSystem The particle system to add
  96470. */
  96471. addParticleSystem(newParticleSystem: IParticleSystem): void;
  96472. /**
  96473. * Adds the given animation to this scene
  96474. * @param newAnimation The animation to add
  96475. */
  96476. addAnimation(newAnimation: Animation): void;
  96477. /**
  96478. * Adds the given animation group to this scene.
  96479. * @param newAnimationGroup The animation group to add
  96480. */
  96481. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  96482. /**
  96483. * Adds the given multi-material to this scene
  96484. * @param newMultiMaterial The multi-material to add
  96485. */
  96486. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  96487. /**
  96488. * Adds the given material to this scene
  96489. * @param newMaterial The material to add
  96490. */
  96491. addMaterial(newMaterial: Material): void;
  96492. /**
  96493. * Adds the given morph target to this scene
  96494. * @param newMorphTargetManager The morph target to add
  96495. */
  96496. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  96497. /**
  96498. * Adds the given geometry to this scene
  96499. * @param newGeometry The geometry to add
  96500. */
  96501. addGeometry(newGeometry: Geometry): void;
  96502. /**
  96503. * Adds the given action manager to this scene
  96504. * @param newActionManager The action manager to add
  96505. */
  96506. addActionManager(newActionManager: AbstractActionManager): void;
  96507. /**
  96508. * Adds the given texture to this scene.
  96509. * @param newTexture The texture to add
  96510. */
  96511. addTexture(newTexture: BaseTexture): void;
  96512. /**
  96513. * Switch active camera
  96514. * @param newCamera defines the new active camera
  96515. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  96516. */
  96517. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  96518. /**
  96519. * sets the active camera of the scene using its ID
  96520. * @param id defines the camera's ID
  96521. * @return the new active camera or null if none found.
  96522. */
  96523. setActiveCameraByID(id: string): Nullable<Camera>;
  96524. /**
  96525. * sets the active camera of the scene using its name
  96526. * @param name defines the camera's name
  96527. * @returns the new active camera or null if none found.
  96528. */
  96529. setActiveCameraByName(name: string): Nullable<Camera>;
  96530. /**
  96531. * get an animation group using its name
  96532. * @param name defines the material's name
  96533. * @return the animation group or null if none found.
  96534. */
  96535. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  96536. /**
  96537. * Get a material using its unique id
  96538. * @param uniqueId defines the material's unique id
  96539. * @return the material or null if none found.
  96540. */
  96541. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  96542. /**
  96543. * get a material using its id
  96544. * @param id defines the material's ID
  96545. * @return the material or null if none found.
  96546. */
  96547. getMaterialByID(id: string): Nullable<Material>;
  96548. /**
  96549. * Gets a the last added material using a given id
  96550. * @param id defines the material's ID
  96551. * @return the last material with the given id or null if none found.
  96552. */
  96553. getLastMaterialByID(id: string): Nullable<Material>;
  96554. /**
  96555. * Gets a material using its name
  96556. * @param name defines the material's name
  96557. * @return the material or null if none found.
  96558. */
  96559. getMaterialByName(name: string): Nullable<Material>;
  96560. /**
  96561. * Gets a camera using its id
  96562. * @param id defines the id to look for
  96563. * @returns the camera or null if not found
  96564. */
  96565. getCameraByID(id: string): Nullable<Camera>;
  96566. /**
  96567. * Gets a camera using its unique id
  96568. * @param uniqueId defines the unique id to look for
  96569. * @returns the camera or null if not found
  96570. */
  96571. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  96572. /**
  96573. * Gets a camera using its name
  96574. * @param name defines the camera's name
  96575. * @return the camera or null if none found.
  96576. */
  96577. getCameraByName(name: string): Nullable<Camera>;
  96578. /**
  96579. * Gets a bone using its id
  96580. * @param id defines the bone's id
  96581. * @return the bone or null if not found
  96582. */
  96583. getBoneByID(id: string): Nullable<Bone>;
  96584. /**
  96585. * Gets a bone using its id
  96586. * @param name defines the bone's name
  96587. * @return the bone or null if not found
  96588. */
  96589. getBoneByName(name: string): Nullable<Bone>;
  96590. /**
  96591. * Gets a light node using its name
  96592. * @param name defines the the light's name
  96593. * @return the light or null if none found.
  96594. */
  96595. getLightByName(name: string): Nullable<Light>;
  96596. /**
  96597. * Gets a light node using its id
  96598. * @param id defines the light's id
  96599. * @return the light or null if none found.
  96600. */
  96601. getLightByID(id: string): Nullable<Light>;
  96602. /**
  96603. * Gets a light node using its scene-generated unique ID
  96604. * @param uniqueId defines the light's unique id
  96605. * @return the light or null if none found.
  96606. */
  96607. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  96608. /**
  96609. * Gets a particle system by id
  96610. * @param id defines the particle system id
  96611. * @return the corresponding system or null if none found
  96612. */
  96613. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  96614. /**
  96615. * Gets a geometry using its ID
  96616. * @param id defines the geometry's id
  96617. * @return the geometry or null if none found.
  96618. */
  96619. getGeometryByID(id: string): Nullable<Geometry>;
  96620. private _getGeometryByUniqueID;
  96621. /**
  96622. * Add a new geometry to this scene
  96623. * @param geometry defines the geometry to be added to the scene.
  96624. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  96625. * @return a boolean defining if the geometry was added or not
  96626. */
  96627. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  96628. /**
  96629. * Removes an existing geometry
  96630. * @param geometry defines the geometry to be removed from the scene
  96631. * @return a boolean defining if the geometry was removed or not
  96632. */
  96633. removeGeometry(geometry: Geometry): boolean;
  96634. /**
  96635. * Gets the list of geometries attached to the scene
  96636. * @returns an array of Geometry
  96637. */
  96638. getGeometries(): Geometry[];
  96639. /**
  96640. * Gets the first added mesh found of a given ID
  96641. * @param id defines the id to search for
  96642. * @return the mesh found or null if not found at all
  96643. */
  96644. getMeshByID(id: string): Nullable<AbstractMesh>;
  96645. /**
  96646. * Gets a list of meshes using their id
  96647. * @param id defines the id to search for
  96648. * @returns a list of meshes
  96649. */
  96650. getMeshesByID(id: string): Array<AbstractMesh>;
  96651. /**
  96652. * Gets the first added transform node found of a given ID
  96653. * @param id defines the id to search for
  96654. * @return the found transform node or null if not found at all.
  96655. */
  96656. getTransformNodeByID(id: string): Nullable<TransformNode>;
  96657. /**
  96658. * Gets a transform node with its auto-generated unique id
  96659. * @param uniqueId efines the unique id to search for
  96660. * @return the found transform node or null if not found at all.
  96661. */
  96662. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  96663. /**
  96664. * Gets a list of transform nodes using their id
  96665. * @param id defines the id to search for
  96666. * @returns a list of transform nodes
  96667. */
  96668. getTransformNodesByID(id: string): Array<TransformNode>;
  96669. /**
  96670. * Gets a mesh with its auto-generated unique id
  96671. * @param uniqueId defines the unique id to search for
  96672. * @return the found mesh or null if not found at all.
  96673. */
  96674. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  96675. /**
  96676. * Gets a the last added mesh using a given id
  96677. * @param id defines the id to search for
  96678. * @return the found mesh or null if not found at all.
  96679. */
  96680. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  96681. /**
  96682. * Gets a the last added node (Mesh, Camera, Light) using a given id
  96683. * @param id defines the id to search for
  96684. * @return the found node or null if not found at all
  96685. */
  96686. getLastEntryByID(id: string): Nullable<Node>;
  96687. /**
  96688. * Gets a node (Mesh, Camera, Light) using a given id
  96689. * @param id defines the id to search for
  96690. * @return the found node or null if not found at all
  96691. */
  96692. getNodeByID(id: string): Nullable<Node>;
  96693. /**
  96694. * Gets a node (Mesh, Camera, Light) using a given name
  96695. * @param name defines the name to search for
  96696. * @return the found node or null if not found at all.
  96697. */
  96698. getNodeByName(name: string): Nullable<Node>;
  96699. /**
  96700. * Gets a mesh using a given name
  96701. * @param name defines the name to search for
  96702. * @return the found mesh or null if not found at all.
  96703. */
  96704. getMeshByName(name: string): Nullable<AbstractMesh>;
  96705. /**
  96706. * Gets a transform node using a given name
  96707. * @param name defines the name to search for
  96708. * @return the found transform node or null if not found at all.
  96709. */
  96710. getTransformNodeByName(name: string): Nullable<TransformNode>;
  96711. /**
  96712. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  96713. * @param id defines the id to search for
  96714. * @return the found skeleton or null if not found at all.
  96715. */
  96716. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  96717. /**
  96718. * Gets a skeleton using a given auto generated unique id
  96719. * @param uniqueId defines the unique id to search for
  96720. * @return the found skeleton or null if not found at all.
  96721. */
  96722. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  96723. /**
  96724. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  96725. * @param id defines the id to search for
  96726. * @return the found skeleton or null if not found at all.
  96727. */
  96728. getSkeletonById(id: string): Nullable<Skeleton>;
  96729. /**
  96730. * Gets a skeleton using a given name
  96731. * @param name defines the name to search for
  96732. * @return the found skeleton or null if not found at all.
  96733. */
  96734. getSkeletonByName(name: string): Nullable<Skeleton>;
  96735. /**
  96736. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  96737. * @param id defines the id to search for
  96738. * @return the found morph target manager or null if not found at all.
  96739. */
  96740. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  96741. /**
  96742. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  96743. * @param id defines the id to search for
  96744. * @return the found morph target or null if not found at all.
  96745. */
  96746. getMorphTargetById(id: string): Nullable<MorphTarget>;
  96747. /**
  96748. * Gets a boolean indicating if the given mesh is active
  96749. * @param mesh defines the mesh to look for
  96750. * @returns true if the mesh is in the active list
  96751. */
  96752. isActiveMesh(mesh: AbstractMesh): boolean;
  96753. /**
  96754. * Return a unique id as a string which can serve as an identifier for the scene
  96755. */
  96756. readonly uid: string;
  96757. /**
  96758. * Add an externaly attached data from its key.
  96759. * This method call will fail and return false, if such key already exists.
  96760. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  96761. * @param key the unique key that identifies the data
  96762. * @param data the data object to associate to the key for this Engine instance
  96763. * @return true if no such key were already present and the data was added successfully, false otherwise
  96764. */
  96765. addExternalData<T>(key: string, data: T): boolean;
  96766. /**
  96767. * Get an externaly attached data from its key
  96768. * @param key the unique key that identifies the data
  96769. * @return the associated data, if present (can be null), or undefined if not present
  96770. */
  96771. getExternalData<T>(key: string): Nullable<T>;
  96772. /**
  96773. * Get an externaly attached data from its key, create it using a factory if it's not already present
  96774. * @param key the unique key that identifies the data
  96775. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  96776. * @return the associated data, can be null if the factory returned null.
  96777. */
  96778. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  96779. /**
  96780. * Remove an externaly attached data from the Engine instance
  96781. * @param key the unique key that identifies the data
  96782. * @return true if the data was successfully removed, false if it doesn't exist
  96783. */
  96784. removeExternalData(key: string): boolean;
  96785. private _evaluateSubMesh;
  96786. /**
  96787. * Clear the processed materials smart array preventing retention point in material dispose.
  96788. */
  96789. freeProcessedMaterials(): void;
  96790. private _preventFreeActiveMeshesAndRenderingGroups;
  96791. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  96792. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  96793. * when disposing several meshes in a row or a hierarchy of meshes.
  96794. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  96795. */
  96796. blockfreeActiveMeshesAndRenderingGroups: boolean;
  96797. /**
  96798. * Clear the active meshes smart array preventing retention point in mesh dispose.
  96799. */
  96800. freeActiveMeshes(): void;
  96801. /**
  96802. * Clear the info related to rendering groups preventing retention points during dispose.
  96803. */
  96804. freeRenderingGroups(): void;
  96805. /** @hidden */
  96806. _isInIntermediateRendering(): boolean;
  96807. /**
  96808. * Lambda returning the list of potentially active meshes.
  96809. */
  96810. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  96811. /**
  96812. * Lambda returning the list of potentially active sub meshes.
  96813. */
  96814. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  96815. /**
  96816. * Lambda returning the list of potentially intersecting sub meshes.
  96817. */
  96818. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  96819. /**
  96820. * Lambda returning the list of potentially colliding sub meshes.
  96821. */
  96822. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  96823. private _activeMeshesFrozen;
  96824. /**
  96825. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  96826. * @returns the current scene
  96827. */
  96828. freezeActiveMeshes(): Scene;
  96829. /**
  96830. * Use this function to restart evaluating active meshes on every frame
  96831. * @returns the current scene
  96832. */
  96833. unfreezeActiveMeshes(): Scene;
  96834. private _evaluateActiveMeshes;
  96835. private _activeMesh;
  96836. /**
  96837. * Update the transform matrix to update from the current active camera
  96838. * @param force defines a boolean used to force the update even if cache is up to date
  96839. */
  96840. updateTransformMatrix(force?: boolean): void;
  96841. private _bindFrameBuffer;
  96842. /** @hidden */
  96843. _allowPostProcessClearColor: boolean;
  96844. /** @hidden */
  96845. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  96846. private _processSubCameras;
  96847. private _checkIntersections;
  96848. /** @hidden */
  96849. _advancePhysicsEngineStep(step: number): void;
  96850. /**
  96851. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  96852. */
  96853. getDeterministicFrameTime: () => number;
  96854. /** @hidden */
  96855. _animate(): void;
  96856. /** Execute all animations (for a frame) */
  96857. animate(): void;
  96858. /**
  96859. * Render the scene
  96860. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  96861. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  96862. */
  96863. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  96864. /**
  96865. * Freeze all materials
  96866. * A frozen material will not be updatable but should be faster to render
  96867. */
  96868. freezeMaterials(): void;
  96869. /**
  96870. * Unfreeze all materials
  96871. * A frozen material will not be updatable but should be faster to render
  96872. */
  96873. unfreezeMaterials(): void;
  96874. /**
  96875. * Releases all held ressources
  96876. */
  96877. dispose(): void;
  96878. /**
  96879. * Gets if the scene is already disposed
  96880. */
  96881. readonly isDisposed: boolean;
  96882. /**
  96883. * Call this function to reduce memory footprint of the scene.
  96884. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  96885. */
  96886. clearCachedVertexData(): void;
  96887. /**
  96888. * This function will remove the local cached buffer data from texture.
  96889. * It will save memory but will prevent the texture from being rebuilt
  96890. */
  96891. cleanCachedTextureBuffer(): void;
  96892. /**
  96893. * Get the world extend vectors with an optional filter
  96894. *
  96895. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  96896. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  96897. */
  96898. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  96899. min: Vector3;
  96900. max: Vector3;
  96901. };
  96902. /**
  96903. * Creates a ray that can be used to pick in the scene
  96904. * @param x defines the x coordinate of the origin (on-screen)
  96905. * @param y defines the y coordinate of the origin (on-screen)
  96906. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  96907. * @param camera defines the camera to use for the picking
  96908. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  96909. * @returns a Ray
  96910. */
  96911. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  96912. /**
  96913. * Creates a ray that can be used to pick in the scene
  96914. * @param x defines the x coordinate of the origin (on-screen)
  96915. * @param y defines the y coordinate of the origin (on-screen)
  96916. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  96917. * @param result defines the ray where to store the picking ray
  96918. * @param camera defines the camera to use for the picking
  96919. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  96920. * @returns the current scene
  96921. */
  96922. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  96923. /**
  96924. * Creates a ray that can be used to pick in the scene
  96925. * @param x defines the x coordinate of the origin (on-screen)
  96926. * @param y defines the y coordinate of the origin (on-screen)
  96927. * @param camera defines the camera to use for the picking
  96928. * @returns a Ray
  96929. */
  96930. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  96931. /**
  96932. * Creates a ray that can be used to pick in the scene
  96933. * @param x defines the x coordinate of the origin (on-screen)
  96934. * @param y defines the y coordinate of the origin (on-screen)
  96935. * @param result defines the ray where to store the picking ray
  96936. * @param camera defines the camera to use for the picking
  96937. * @returns the current scene
  96938. */
  96939. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  96940. /** Launch a ray to try to pick a mesh in the scene
  96941. * @param x position on screen
  96942. * @param y position on screen
  96943. * @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
  96944. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  96945. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96946. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96947. * @returns a PickingInfo
  96948. */
  96949. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  96950. /** Use the given ray to pick a mesh in the scene
  96951. * @param ray The ray to use to pick meshes
  96952. * @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
  96953. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  96954. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96955. * @returns a PickingInfo
  96956. */
  96957. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  96958. /**
  96959. * Launch a ray to try to pick a mesh in the scene
  96960. * @param x X position on screen
  96961. * @param y Y position on screen
  96962. * @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
  96963. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96964. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96965. * @returns an array of PickingInfo
  96966. */
  96967. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  96968. /**
  96969. * Launch a ray to try to pick a mesh in the scene
  96970. * @param ray Ray to use
  96971. * @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
  96972. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96973. * @returns an array of PickingInfo
  96974. */
  96975. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  96976. /**
  96977. * Force the value of meshUnderPointer
  96978. * @param mesh defines the mesh to use
  96979. */
  96980. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  96981. /**
  96982. * Gets the mesh under the pointer
  96983. * @returns a Mesh or null if no mesh is under the pointer
  96984. */
  96985. getPointerOverMesh(): Nullable<AbstractMesh>;
  96986. /** @hidden */
  96987. _rebuildGeometries(): void;
  96988. /** @hidden */
  96989. _rebuildTextures(): void;
  96990. private _getByTags;
  96991. /**
  96992. * Get a list of meshes by tags
  96993. * @param tagsQuery defines the tags query to use
  96994. * @param forEach defines a predicate used to filter results
  96995. * @returns an array of Mesh
  96996. */
  96997. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  96998. /**
  96999. * Get a list of cameras by tags
  97000. * @param tagsQuery defines the tags query to use
  97001. * @param forEach defines a predicate used to filter results
  97002. * @returns an array of Camera
  97003. */
  97004. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  97005. /**
  97006. * Get a list of lights by tags
  97007. * @param tagsQuery defines the tags query to use
  97008. * @param forEach defines a predicate used to filter results
  97009. * @returns an array of Light
  97010. */
  97011. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  97012. /**
  97013. * Get a list of materials by tags
  97014. * @param tagsQuery defines the tags query to use
  97015. * @param forEach defines a predicate used to filter results
  97016. * @returns an array of Material
  97017. */
  97018. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  97019. /**
  97020. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  97021. * This allowed control for front to back rendering or reversly depending of the special needs.
  97022. *
  97023. * @param renderingGroupId The rendering group id corresponding to its index
  97024. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  97025. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  97026. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  97027. */
  97028. 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;
  97029. /**
  97030. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  97031. *
  97032. * @param renderingGroupId The rendering group id corresponding to its index
  97033. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  97034. * @param depth Automatically clears depth between groups if true and autoClear is true.
  97035. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  97036. */
  97037. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  97038. /**
  97039. * Gets the current auto clear configuration for one rendering group of the rendering
  97040. * manager.
  97041. * @param index the rendering group index to get the information for
  97042. * @returns The auto clear setup for the requested rendering group
  97043. */
  97044. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  97045. private _blockMaterialDirtyMechanism;
  97046. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  97047. blockMaterialDirtyMechanism: boolean;
  97048. /**
  97049. * Will flag all materials as dirty to trigger new shader compilation
  97050. * @param flag defines the flag used to specify which material part must be marked as dirty
  97051. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  97052. */
  97053. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  97054. /** @hidden */
  97055. _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;
  97056. /** @hidden */
  97057. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  97058. }
  97059. }
  97060. declare module BABYLON {
  97061. /**
  97062. * Set of assets to keep when moving a scene into an asset container.
  97063. */
  97064. export class KeepAssets extends AbstractScene {
  97065. }
  97066. /**
  97067. * Container with a set of assets that can be added or removed from a scene.
  97068. */
  97069. export class AssetContainer extends AbstractScene {
  97070. /**
  97071. * The scene the AssetContainer belongs to.
  97072. */
  97073. scene: Scene;
  97074. /**
  97075. * Instantiates an AssetContainer.
  97076. * @param scene The scene the AssetContainer belongs to.
  97077. */
  97078. constructor(scene: Scene);
  97079. /**
  97080. * Adds all the assets from the container to the scene.
  97081. */
  97082. addAllToScene(): void;
  97083. /**
  97084. * Removes all the assets in the container from the scene
  97085. */
  97086. removeAllFromScene(): void;
  97087. /**
  97088. * Disposes all the assets in the container
  97089. */
  97090. dispose(): void;
  97091. private _moveAssets;
  97092. /**
  97093. * Removes all the assets contained in the scene and adds them to the container.
  97094. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  97095. */
  97096. moveAllFromScene(keepAssets?: KeepAssets): void;
  97097. /**
  97098. * 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.
  97099. * @returns the root mesh
  97100. */
  97101. createRootMesh(): Mesh;
  97102. }
  97103. }
  97104. declare module BABYLON {
  97105. /**
  97106. * Defines how the parser contract is defined.
  97107. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  97108. */
  97109. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  97110. /**
  97111. * Defines how the individual parser contract is defined.
  97112. * These parser can parse an individual asset
  97113. */
  97114. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  97115. /**
  97116. * Base class of the scene acting as a container for the different elements composing a scene.
  97117. * This class is dynamically extended by the different components of the scene increasing
  97118. * flexibility and reducing coupling
  97119. */
  97120. export abstract class AbstractScene {
  97121. /**
  97122. * Stores the list of available parsers in the application.
  97123. */
  97124. private static _BabylonFileParsers;
  97125. /**
  97126. * Stores the list of available individual parsers in the application.
  97127. */
  97128. private static _IndividualBabylonFileParsers;
  97129. /**
  97130. * Adds a parser in the list of available ones
  97131. * @param name Defines the name of the parser
  97132. * @param parser Defines the parser to add
  97133. */
  97134. static AddParser(name: string, parser: BabylonFileParser): void;
  97135. /**
  97136. * Gets a general parser from the list of avaialble ones
  97137. * @param name Defines the name of the parser
  97138. * @returns the requested parser or null
  97139. */
  97140. static GetParser(name: string): Nullable<BabylonFileParser>;
  97141. /**
  97142. * Adds n individual parser in the list of available ones
  97143. * @param name Defines the name of the parser
  97144. * @param parser Defines the parser to add
  97145. */
  97146. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  97147. /**
  97148. * Gets an individual parser from the list of avaialble ones
  97149. * @param name Defines the name of the parser
  97150. * @returns the requested parser or null
  97151. */
  97152. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  97153. /**
  97154. * Parser json data and populate both a scene and its associated container object
  97155. * @param jsonData Defines the data to parse
  97156. * @param scene Defines the scene to parse the data for
  97157. * @param container Defines the container attached to the parsing sequence
  97158. * @param rootUrl Defines the root url of the data
  97159. */
  97160. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  97161. /**
  97162. * Gets the list of root nodes (ie. nodes with no parent)
  97163. */
  97164. rootNodes: Node[];
  97165. /** All of the cameras added to this scene
  97166. * @see http://doc.babylonjs.com/babylon101/cameras
  97167. */
  97168. cameras: Camera[];
  97169. /**
  97170. * All of the lights added to this scene
  97171. * @see http://doc.babylonjs.com/babylon101/lights
  97172. */
  97173. lights: Light[];
  97174. /**
  97175. * All of the (abstract) meshes added to this scene
  97176. */
  97177. meshes: AbstractMesh[];
  97178. /**
  97179. * The list of skeletons added to the scene
  97180. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  97181. */
  97182. skeletons: Skeleton[];
  97183. /**
  97184. * All of the particle systems added to this scene
  97185. * @see http://doc.babylonjs.com/babylon101/particles
  97186. */
  97187. particleSystems: IParticleSystem[];
  97188. /**
  97189. * Gets a list of Animations associated with the scene
  97190. */
  97191. animations: Animation[];
  97192. /**
  97193. * All of the animation groups added to this scene
  97194. * @see http://doc.babylonjs.com/how_to/group
  97195. */
  97196. animationGroups: AnimationGroup[];
  97197. /**
  97198. * All of the multi-materials added to this scene
  97199. * @see http://doc.babylonjs.com/how_to/multi_materials
  97200. */
  97201. multiMaterials: MultiMaterial[];
  97202. /**
  97203. * All of the materials added to this scene
  97204. * In the context of a Scene, it is not supposed to be modified manually.
  97205. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  97206. * Note also that the order of the Material wihin the array is not significant and might change.
  97207. * @see http://doc.babylonjs.com/babylon101/materials
  97208. */
  97209. materials: Material[];
  97210. /**
  97211. * The list of morph target managers added to the scene
  97212. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  97213. */
  97214. morphTargetManagers: MorphTargetManager[];
  97215. /**
  97216. * The list of geometries used in the scene.
  97217. */
  97218. geometries: Geometry[];
  97219. /**
  97220. * All of the tranform nodes added to this scene
  97221. * In the context of a Scene, it is not supposed to be modified manually.
  97222. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  97223. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  97224. * @see http://doc.babylonjs.com/how_to/transformnode
  97225. */
  97226. transformNodes: TransformNode[];
  97227. /**
  97228. * ActionManagers available on the scene.
  97229. */
  97230. actionManagers: AbstractActionManager[];
  97231. /**
  97232. * Textures to keep.
  97233. */
  97234. textures: BaseTexture[];
  97235. /**
  97236. * Environment texture for the scene
  97237. */
  97238. environmentTexture: Nullable<BaseTexture>;
  97239. }
  97240. }
  97241. declare module BABYLON {
  97242. /**
  97243. * Interface used to define options for Sound class
  97244. */
  97245. export interface ISoundOptions {
  97246. /**
  97247. * Does the sound autoplay once loaded.
  97248. */
  97249. autoplay?: boolean;
  97250. /**
  97251. * Does the sound loop after it finishes playing once.
  97252. */
  97253. loop?: boolean;
  97254. /**
  97255. * Sound's volume
  97256. */
  97257. volume?: number;
  97258. /**
  97259. * Is it a spatial sound?
  97260. */
  97261. spatialSound?: boolean;
  97262. /**
  97263. * Maximum distance to hear that sound
  97264. */
  97265. maxDistance?: number;
  97266. /**
  97267. * Uses user defined attenuation function
  97268. */
  97269. useCustomAttenuation?: boolean;
  97270. /**
  97271. * Define the roll off factor of spatial sounds.
  97272. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97273. */
  97274. rolloffFactor?: number;
  97275. /**
  97276. * Define the reference distance the sound should be heard perfectly.
  97277. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97278. */
  97279. refDistance?: number;
  97280. /**
  97281. * Define the distance attenuation model the sound will follow.
  97282. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97283. */
  97284. distanceModel?: string;
  97285. /**
  97286. * Defines the playback speed (1 by default)
  97287. */
  97288. playbackRate?: number;
  97289. /**
  97290. * Defines if the sound is from a streaming source
  97291. */
  97292. streaming?: boolean;
  97293. /**
  97294. * Defines an optional length (in seconds) inside the sound file
  97295. */
  97296. length?: number;
  97297. /**
  97298. * Defines an optional offset (in seconds) inside the sound file
  97299. */
  97300. offset?: number;
  97301. /**
  97302. * If true, URLs will not be required to state the audio file codec to use.
  97303. */
  97304. skipCodecCheck?: boolean;
  97305. }
  97306. /**
  97307. * Defines a sound that can be played in the application.
  97308. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  97309. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97310. */
  97311. export class Sound {
  97312. /**
  97313. * The name of the sound in the scene.
  97314. */
  97315. name: string;
  97316. /**
  97317. * Does the sound autoplay once loaded.
  97318. */
  97319. autoplay: boolean;
  97320. /**
  97321. * Does the sound loop after it finishes playing once.
  97322. */
  97323. loop: boolean;
  97324. /**
  97325. * Does the sound use a custom attenuation curve to simulate the falloff
  97326. * happening when the source gets further away from the camera.
  97327. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  97328. */
  97329. useCustomAttenuation: boolean;
  97330. /**
  97331. * The sound track id this sound belongs to.
  97332. */
  97333. soundTrackId: number;
  97334. /**
  97335. * Is this sound currently played.
  97336. */
  97337. isPlaying: boolean;
  97338. /**
  97339. * Is this sound currently paused.
  97340. */
  97341. isPaused: boolean;
  97342. /**
  97343. * Does this sound enables spatial sound.
  97344. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97345. */
  97346. spatialSound: boolean;
  97347. /**
  97348. * Define the reference distance the sound should be heard perfectly.
  97349. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97350. */
  97351. refDistance: number;
  97352. /**
  97353. * Define the roll off factor of spatial sounds.
  97354. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97355. */
  97356. rolloffFactor: number;
  97357. /**
  97358. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  97359. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97360. */
  97361. maxDistance: number;
  97362. /**
  97363. * Define the distance attenuation model the sound will follow.
  97364. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97365. */
  97366. distanceModel: string;
  97367. /**
  97368. * @hidden
  97369. * Back Compat
  97370. **/
  97371. onended: () => any;
  97372. /**
  97373. * Observable event when the current playing sound finishes.
  97374. */
  97375. onEndedObservable: Observable<Sound>;
  97376. private _panningModel;
  97377. private _playbackRate;
  97378. private _streaming;
  97379. private _startTime;
  97380. private _startOffset;
  97381. private _position;
  97382. /** @hidden */
  97383. _positionInEmitterSpace: boolean;
  97384. private _localDirection;
  97385. private _volume;
  97386. private _isReadyToPlay;
  97387. private _isDirectional;
  97388. private _readyToPlayCallback;
  97389. private _audioBuffer;
  97390. private _soundSource;
  97391. private _streamingSource;
  97392. private _soundPanner;
  97393. private _soundGain;
  97394. private _inputAudioNode;
  97395. private _outputAudioNode;
  97396. private _coneInnerAngle;
  97397. private _coneOuterAngle;
  97398. private _coneOuterGain;
  97399. private _scene;
  97400. private _connectedTransformNode;
  97401. private _customAttenuationFunction;
  97402. private _registerFunc;
  97403. private _isOutputConnected;
  97404. private _htmlAudioElement;
  97405. private _urlType;
  97406. private _length?;
  97407. private _offset?;
  97408. /** @hidden */
  97409. static _SceneComponentInitialization: (scene: Scene) => void;
  97410. /**
  97411. * Create a sound and attach it to a scene
  97412. * @param name Name of your sound
  97413. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  97414. * @param scene defines the scene the sound belongs to
  97415. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  97416. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  97417. */
  97418. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  97419. /**
  97420. * Release the sound and its associated resources
  97421. */
  97422. dispose(): void;
  97423. /**
  97424. * Gets if the sounds is ready to be played or not.
  97425. * @returns true if ready, otherwise false
  97426. */
  97427. isReady(): boolean;
  97428. private _soundLoaded;
  97429. /**
  97430. * Sets the data of the sound from an audiobuffer
  97431. * @param audioBuffer The audioBuffer containing the data
  97432. */
  97433. setAudioBuffer(audioBuffer: AudioBuffer): void;
  97434. /**
  97435. * Updates the current sounds options such as maxdistance, loop...
  97436. * @param options A JSON object containing values named as the object properties
  97437. */
  97438. updateOptions(options: ISoundOptions): void;
  97439. private _createSpatialParameters;
  97440. private _updateSpatialParameters;
  97441. /**
  97442. * Switch the panning model to HRTF:
  97443. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  97444. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97445. */
  97446. switchPanningModelToHRTF(): void;
  97447. /**
  97448. * Switch the panning model to Equal Power:
  97449. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  97450. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97451. */
  97452. switchPanningModelToEqualPower(): void;
  97453. private _switchPanningModel;
  97454. /**
  97455. * Connect this sound to a sound track audio node like gain...
  97456. * @param soundTrackAudioNode the sound track audio node to connect to
  97457. */
  97458. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  97459. /**
  97460. * Transform this sound into a directional source
  97461. * @param coneInnerAngle Size of the inner cone in degree
  97462. * @param coneOuterAngle Size of the outer cone in degree
  97463. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  97464. */
  97465. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  97466. /**
  97467. * Gets or sets the inner angle for the directional cone.
  97468. */
  97469. /**
  97470. * Gets or sets the inner angle for the directional cone.
  97471. */
  97472. directionalConeInnerAngle: number;
  97473. /**
  97474. * Gets or sets the outer angle for the directional cone.
  97475. */
  97476. /**
  97477. * Gets or sets the outer angle for the directional cone.
  97478. */
  97479. directionalConeOuterAngle: number;
  97480. /**
  97481. * Sets the position of the emitter if spatial sound is enabled
  97482. * @param newPosition Defines the new posisiton
  97483. */
  97484. setPosition(newPosition: Vector3): void;
  97485. /**
  97486. * Sets the local direction of the emitter if spatial sound is enabled
  97487. * @param newLocalDirection Defines the new local direction
  97488. */
  97489. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  97490. private _updateDirection;
  97491. /** @hidden */
  97492. updateDistanceFromListener(): void;
  97493. /**
  97494. * Sets a new custom attenuation function for the sound.
  97495. * @param callback Defines the function used for the attenuation
  97496. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  97497. */
  97498. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  97499. /**
  97500. * Play the sound
  97501. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  97502. * @param offset (optional) Start the sound at a specific time in seconds
  97503. * @param length (optional) Sound duration (in seconds)
  97504. */
  97505. play(time?: number, offset?: number, length?: number): void;
  97506. private _onended;
  97507. /**
  97508. * Stop the sound
  97509. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  97510. */
  97511. stop(time?: number): void;
  97512. /**
  97513. * Put the sound in pause
  97514. */
  97515. pause(): void;
  97516. /**
  97517. * Sets a dedicated volume for this sounds
  97518. * @param newVolume Define the new volume of the sound
  97519. * @param time Define time for gradual change to new volume
  97520. */
  97521. setVolume(newVolume: number, time?: number): void;
  97522. /**
  97523. * Set the sound play back rate
  97524. * @param newPlaybackRate Define the playback rate the sound should be played at
  97525. */
  97526. setPlaybackRate(newPlaybackRate: number): void;
  97527. /**
  97528. * Gets the volume of the sound.
  97529. * @returns the volume of the sound
  97530. */
  97531. getVolume(): number;
  97532. /**
  97533. * Attach the sound to a dedicated mesh
  97534. * @param transformNode The transform node to connect the sound with
  97535. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  97536. */
  97537. attachToMesh(transformNode: TransformNode): void;
  97538. /**
  97539. * Detach the sound from the previously attached mesh
  97540. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  97541. */
  97542. detachFromMesh(): void;
  97543. private _onRegisterAfterWorldMatrixUpdate;
  97544. /**
  97545. * Clone the current sound in the scene.
  97546. * @returns the new sound clone
  97547. */
  97548. clone(): Nullable<Sound>;
  97549. /**
  97550. * Gets the current underlying audio buffer containing the data
  97551. * @returns the audio buffer
  97552. */
  97553. getAudioBuffer(): Nullable<AudioBuffer>;
  97554. /**
  97555. * Serializes the Sound in a JSON representation
  97556. * @returns the JSON representation of the sound
  97557. */
  97558. serialize(): any;
  97559. /**
  97560. * Parse a JSON representation of a sound to innstantiate in a given scene
  97561. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  97562. * @param scene Define the scene the new parsed sound should be created in
  97563. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  97564. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  97565. * @returns the newly parsed sound
  97566. */
  97567. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  97568. }
  97569. }
  97570. declare module BABYLON {
  97571. /**
  97572. * This defines an action helpful to play a defined sound on a triggered action.
  97573. */
  97574. export class PlaySoundAction extends Action {
  97575. private _sound;
  97576. /**
  97577. * Instantiate the action
  97578. * @param triggerOptions defines the trigger options
  97579. * @param sound defines the sound to play
  97580. * @param condition defines the trigger related conditions
  97581. */
  97582. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  97583. /** @hidden */
  97584. _prepare(): void;
  97585. /**
  97586. * Execute the action and play the sound.
  97587. */
  97588. execute(): void;
  97589. /**
  97590. * Serializes the actions and its related information.
  97591. * @param parent defines the object to serialize in
  97592. * @returns the serialized object
  97593. */
  97594. serialize(parent: any): any;
  97595. }
  97596. /**
  97597. * This defines an action helpful to stop a defined sound on a triggered action.
  97598. */
  97599. export class StopSoundAction extends Action {
  97600. private _sound;
  97601. /**
  97602. * Instantiate the action
  97603. * @param triggerOptions defines the trigger options
  97604. * @param sound defines the sound to stop
  97605. * @param condition defines the trigger related conditions
  97606. */
  97607. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  97608. /** @hidden */
  97609. _prepare(): void;
  97610. /**
  97611. * Execute the action and stop the sound.
  97612. */
  97613. execute(): void;
  97614. /**
  97615. * Serializes the actions and its related information.
  97616. * @param parent defines the object to serialize in
  97617. * @returns the serialized object
  97618. */
  97619. serialize(parent: any): any;
  97620. }
  97621. }
  97622. declare module BABYLON {
  97623. /**
  97624. * This defines an action responsible to change the value of a property
  97625. * by interpolating between its current value and the newly set one once triggered.
  97626. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  97627. */
  97628. export class InterpolateValueAction extends Action {
  97629. /**
  97630. * Defines the path of the property where the value should be interpolated
  97631. */
  97632. propertyPath: string;
  97633. /**
  97634. * Defines the target value at the end of the interpolation.
  97635. */
  97636. value: any;
  97637. /**
  97638. * Defines the time it will take for the property to interpolate to the value.
  97639. */
  97640. duration: number;
  97641. /**
  97642. * Defines if the other scene animations should be stopped when the action has been triggered
  97643. */
  97644. stopOtherAnimations?: boolean;
  97645. /**
  97646. * Defines a callback raised once the interpolation animation has been done.
  97647. */
  97648. onInterpolationDone?: () => void;
  97649. /**
  97650. * Observable triggered once the interpolation animation has been done.
  97651. */
  97652. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  97653. private _target;
  97654. private _effectiveTarget;
  97655. private _property;
  97656. /**
  97657. * Instantiate the action
  97658. * @param triggerOptions defines the trigger options
  97659. * @param target defines the object containing the value to interpolate
  97660. * @param propertyPath defines the path to the property in the target object
  97661. * @param value defines the target value at the end of the interpolation
  97662. * @param duration deines the time it will take for the property to interpolate to the value.
  97663. * @param condition defines the trigger related conditions
  97664. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  97665. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  97666. */
  97667. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  97668. /** @hidden */
  97669. _prepare(): void;
  97670. /**
  97671. * Execute the action starts the value interpolation.
  97672. */
  97673. execute(): void;
  97674. /**
  97675. * Serializes the actions and its related information.
  97676. * @param parent defines the object to serialize in
  97677. * @returns the serialized object
  97678. */
  97679. serialize(parent: any): any;
  97680. }
  97681. }
  97682. declare module BABYLON {
  97683. /**
  97684. * Options allowed during the creation of a sound track.
  97685. */
  97686. export interface ISoundTrackOptions {
  97687. /**
  97688. * The volume the sound track should take during creation
  97689. */
  97690. volume?: number;
  97691. /**
  97692. * Define if the sound track is the main sound track of the scene
  97693. */
  97694. mainTrack?: boolean;
  97695. }
  97696. /**
  97697. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  97698. * It will be also used in a future release to apply effects on a specific track.
  97699. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  97700. */
  97701. export class SoundTrack {
  97702. /**
  97703. * The unique identifier of the sound track in the scene.
  97704. */
  97705. id: number;
  97706. /**
  97707. * The list of sounds included in the sound track.
  97708. */
  97709. soundCollection: Array<Sound>;
  97710. private _outputAudioNode;
  97711. private _scene;
  97712. private _isMainTrack;
  97713. private _connectedAnalyser;
  97714. private _options;
  97715. private _isInitialized;
  97716. /**
  97717. * Creates a new sound track.
  97718. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  97719. * @param scene Define the scene the sound track belongs to
  97720. * @param options
  97721. */
  97722. constructor(scene: Scene, options?: ISoundTrackOptions);
  97723. private _initializeSoundTrackAudioGraph;
  97724. /**
  97725. * Release the sound track and its associated resources
  97726. */
  97727. dispose(): void;
  97728. /**
  97729. * Adds a sound to this sound track
  97730. * @param sound define the cound to add
  97731. * @ignoreNaming
  97732. */
  97733. AddSound(sound: Sound): void;
  97734. /**
  97735. * Removes a sound to this sound track
  97736. * @param sound define the cound to remove
  97737. * @ignoreNaming
  97738. */
  97739. RemoveSound(sound: Sound): void;
  97740. /**
  97741. * Set a global volume for the full sound track.
  97742. * @param newVolume Define the new volume of the sound track
  97743. */
  97744. setVolume(newVolume: number): void;
  97745. /**
  97746. * Switch the panning model to HRTF:
  97747. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  97748. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97749. */
  97750. switchPanningModelToHRTF(): void;
  97751. /**
  97752. * Switch the panning model to Equal Power:
  97753. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  97754. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97755. */
  97756. switchPanningModelToEqualPower(): void;
  97757. /**
  97758. * Connect the sound track to an audio analyser allowing some amazing
  97759. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  97760. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  97761. * @param analyser The analyser to connect to the engine
  97762. */
  97763. connectToAnalyser(analyser: Analyser): void;
  97764. }
  97765. }
  97766. declare module BABYLON {
  97767. interface AbstractScene {
  97768. /**
  97769. * The list of sounds used in the scene.
  97770. */
  97771. sounds: Nullable<Array<Sound>>;
  97772. }
  97773. interface Scene {
  97774. /**
  97775. * @hidden
  97776. * Backing field
  97777. */
  97778. _mainSoundTrack: SoundTrack;
  97779. /**
  97780. * The main sound track played by the scene.
  97781. * It cotains your primary collection of sounds.
  97782. */
  97783. mainSoundTrack: SoundTrack;
  97784. /**
  97785. * The list of sound tracks added to the scene
  97786. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97787. */
  97788. soundTracks: Nullable<Array<SoundTrack>>;
  97789. /**
  97790. * Gets a sound using a given name
  97791. * @param name defines the name to search for
  97792. * @return the found sound or null if not found at all.
  97793. */
  97794. getSoundByName(name: string): Nullable<Sound>;
  97795. /**
  97796. * Gets or sets if audio support is enabled
  97797. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97798. */
  97799. audioEnabled: boolean;
  97800. /**
  97801. * Gets or sets if audio will be output to headphones
  97802. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97803. */
  97804. headphone: boolean;
  97805. }
  97806. /**
  97807. * Defines the sound scene component responsible to manage any sounds
  97808. * in a given scene.
  97809. */
  97810. export class AudioSceneComponent implements ISceneSerializableComponent {
  97811. /**
  97812. * The component name helpfull to identify the component in the list of scene components.
  97813. */
  97814. readonly name: string;
  97815. /**
  97816. * The scene the component belongs to.
  97817. */
  97818. scene: Scene;
  97819. private _audioEnabled;
  97820. /**
  97821. * Gets whether audio is enabled or not.
  97822. * Please use related enable/disable method to switch state.
  97823. */
  97824. readonly audioEnabled: boolean;
  97825. private _headphone;
  97826. /**
  97827. * Gets whether audio is outputing to headphone or not.
  97828. * Please use the according Switch methods to change output.
  97829. */
  97830. readonly headphone: boolean;
  97831. /**
  97832. * Creates a new instance of the component for the given scene
  97833. * @param scene Defines the scene to register the component in
  97834. */
  97835. constructor(scene: Scene);
  97836. /**
  97837. * Registers the component in a given scene
  97838. */
  97839. register(): void;
  97840. /**
  97841. * Rebuilds the elements related to this component in case of
  97842. * context lost for instance.
  97843. */
  97844. rebuild(): void;
  97845. /**
  97846. * Serializes the component data to the specified json object
  97847. * @param serializationObject The object to serialize to
  97848. */
  97849. serialize(serializationObject: any): void;
  97850. /**
  97851. * Adds all the elements from the container to the scene
  97852. * @param container the container holding the elements
  97853. */
  97854. addFromContainer(container: AbstractScene): void;
  97855. /**
  97856. * Removes all the elements in the container from the scene
  97857. * @param container contains the elements to remove
  97858. * @param dispose if the removed element should be disposed (default: false)
  97859. */
  97860. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  97861. /**
  97862. * Disposes the component and the associated ressources.
  97863. */
  97864. dispose(): void;
  97865. /**
  97866. * Disables audio in the associated scene.
  97867. */
  97868. disableAudio(): void;
  97869. /**
  97870. * Enables audio in the associated scene.
  97871. */
  97872. enableAudio(): void;
  97873. /**
  97874. * Switch audio to headphone output.
  97875. */
  97876. switchAudioModeForHeadphones(): void;
  97877. /**
  97878. * Switch audio to normal speakers.
  97879. */
  97880. switchAudioModeForNormalSpeakers(): void;
  97881. private _afterRender;
  97882. }
  97883. }
  97884. declare module BABYLON {
  97885. /**
  97886. * Wraps one or more Sound objects and selects one with random weight for playback.
  97887. */
  97888. export class WeightedSound {
  97889. /** When true a Sound will be selected and played when the current playing Sound completes. */
  97890. loop: boolean;
  97891. private _coneInnerAngle;
  97892. private _coneOuterAngle;
  97893. private _volume;
  97894. /** A Sound is currently playing. */
  97895. isPlaying: boolean;
  97896. /** A Sound is currently paused. */
  97897. isPaused: boolean;
  97898. private _sounds;
  97899. private _weights;
  97900. private _currentIndex?;
  97901. /**
  97902. * Creates a new WeightedSound from the list of sounds given.
  97903. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  97904. * @param sounds Array of Sounds that will be selected from.
  97905. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  97906. */
  97907. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  97908. /**
  97909. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  97910. */
  97911. /**
  97912. * The size of cone in degress for a directional sound in which there will be no attenuation.
  97913. */
  97914. directionalConeInnerAngle: number;
  97915. /**
  97916. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  97917. * Listener angles between innerAngle and outerAngle will falloff linearly.
  97918. */
  97919. /**
  97920. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  97921. * Listener angles between innerAngle and outerAngle will falloff linearly.
  97922. */
  97923. directionalConeOuterAngle: number;
  97924. /**
  97925. * Playback volume.
  97926. */
  97927. /**
  97928. * Playback volume.
  97929. */
  97930. volume: number;
  97931. private _onended;
  97932. /**
  97933. * Suspend playback
  97934. */
  97935. pause(): void;
  97936. /**
  97937. * Stop playback
  97938. */
  97939. stop(): void;
  97940. /**
  97941. * Start playback.
  97942. * @param startOffset Position the clip head at a specific time in seconds.
  97943. */
  97944. play(startOffset?: number): void;
  97945. }
  97946. }
  97947. declare module BABYLON {
  97948. /**
  97949. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  97950. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  97951. */
  97952. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  97953. /**
  97954. * Gets the name of the behavior.
  97955. */
  97956. readonly name: string;
  97957. /**
  97958. * The easing function used by animations
  97959. */
  97960. static EasingFunction: BackEase;
  97961. /**
  97962. * The easing mode used by animations
  97963. */
  97964. static EasingMode: number;
  97965. /**
  97966. * The duration of the animation, in milliseconds
  97967. */
  97968. transitionDuration: number;
  97969. /**
  97970. * Length of the distance animated by the transition when lower radius is reached
  97971. */
  97972. lowerRadiusTransitionRange: number;
  97973. /**
  97974. * Length of the distance animated by the transition when upper radius is reached
  97975. */
  97976. upperRadiusTransitionRange: number;
  97977. private _autoTransitionRange;
  97978. /**
  97979. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  97980. */
  97981. /**
  97982. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  97983. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  97984. */
  97985. autoTransitionRange: boolean;
  97986. private _attachedCamera;
  97987. private _onAfterCheckInputsObserver;
  97988. private _onMeshTargetChangedObserver;
  97989. /**
  97990. * Initializes the behavior.
  97991. */
  97992. init(): void;
  97993. /**
  97994. * Attaches the behavior to its arc rotate camera.
  97995. * @param camera Defines the camera to attach the behavior to
  97996. */
  97997. attach(camera: ArcRotateCamera): void;
  97998. /**
  97999. * Detaches the behavior from its current arc rotate camera.
  98000. */
  98001. detach(): void;
  98002. private _radiusIsAnimating;
  98003. private _radiusBounceTransition;
  98004. private _animatables;
  98005. private _cachedWheelPrecision;
  98006. /**
  98007. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  98008. * @param radiusLimit The limit to check against.
  98009. * @return Bool to indicate if at limit.
  98010. */
  98011. private _isRadiusAtLimit;
  98012. /**
  98013. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  98014. * @param radiusDelta The delta by which to animate to. Can be negative.
  98015. */
  98016. private _applyBoundRadiusAnimation;
  98017. /**
  98018. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  98019. */
  98020. protected _clearAnimationLocks(): void;
  98021. /**
  98022. * Stops and removes all animations that have been applied to the camera
  98023. */
  98024. stopAllAnimations(): void;
  98025. }
  98026. }
  98027. declare module BABYLON {
  98028. /**
  98029. * 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.
  98030. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  98031. */
  98032. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  98033. /**
  98034. * Gets the name of the behavior.
  98035. */
  98036. readonly name: string;
  98037. private _mode;
  98038. private _radiusScale;
  98039. private _positionScale;
  98040. private _defaultElevation;
  98041. private _elevationReturnTime;
  98042. private _elevationReturnWaitTime;
  98043. private _zoomStopsAnimation;
  98044. private _framingTime;
  98045. /**
  98046. * The easing function used by animations
  98047. */
  98048. static EasingFunction: ExponentialEase;
  98049. /**
  98050. * The easing mode used by animations
  98051. */
  98052. static EasingMode: number;
  98053. /**
  98054. * Sets the current mode used by the behavior
  98055. */
  98056. /**
  98057. * Gets current mode used by the behavior.
  98058. */
  98059. mode: number;
  98060. /**
  98061. * Sets the scale applied to the radius (1 by default)
  98062. */
  98063. /**
  98064. * Gets the scale applied to the radius
  98065. */
  98066. radiusScale: number;
  98067. /**
  98068. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  98069. */
  98070. /**
  98071. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  98072. */
  98073. positionScale: number;
  98074. /**
  98075. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  98076. * behaviour is triggered, in radians.
  98077. */
  98078. /**
  98079. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  98080. * behaviour is triggered, in radians.
  98081. */
  98082. defaultElevation: number;
  98083. /**
  98084. * Sets the time (in milliseconds) taken to return to the default beta position.
  98085. * Negative value indicates camera should not return to default.
  98086. */
  98087. /**
  98088. * Gets the time (in milliseconds) taken to return to the default beta position.
  98089. * Negative value indicates camera should not return to default.
  98090. */
  98091. elevationReturnTime: number;
  98092. /**
  98093. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  98094. */
  98095. /**
  98096. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  98097. */
  98098. elevationReturnWaitTime: number;
  98099. /**
  98100. * Sets the flag that indicates if user zooming should stop animation.
  98101. */
  98102. /**
  98103. * Gets the flag that indicates if user zooming should stop animation.
  98104. */
  98105. zoomStopsAnimation: boolean;
  98106. /**
  98107. * Sets the transition time when framing the mesh, in milliseconds
  98108. */
  98109. /**
  98110. * Gets the transition time when framing the mesh, in milliseconds
  98111. */
  98112. framingTime: number;
  98113. /**
  98114. * Define if the behavior should automatically change the configured
  98115. * camera limits and sensibilities.
  98116. */
  98117. autoCorrectCameraLimitsAndSensibility: boolean;
  98118. private _onPrePointerObservableObserver;
  98119. private _onAfterCheckInputsObserver;
  98120. private _onMeshTargetChangedObserver;
  98121. private _attachedCamera;
  98122. private _isPointerDown;
  98123. private _lastInteractionTime;
  98124. /**
  98125. * Initializes the behavior.
  98126. */
  98127. init(): void;
  98128. /**
  98129. * Attaches the behavior to its arc rotate camera.
  98130. * @param camera Defines the camera to attach the behavior to
  98131. */
  98132. attach(camera: ArcRotateCamera): void;
  98133. /**
  98134. * Detaches the behavior from its current arc rotate camera.
  98135. */
  98136. detach(): void;
  98137. private _animatables;
  98138. private _betaIsAnimating;
  98139. private _betaTransition;
  98140. private _radiusTransition;
  98141. private _vectorTransition;
  98142. /**
  98143. * Targets the given mesh and updates zoom level accordingly.
  98144. * @param mesh The mesh to target.
  98145. * @param radius Optional. If a cached radius position already exists, overrides default.
  98146. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  98147. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  98148. * @param onAnimationEnd Callback triggered at the end of the framing animation
  98149. */
  98150. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  98151. /**
  98152. * Targets the given mesh with its children and updates zoom level accordingly.
  98153. * @param mesh The mesh to target.
  98154. * @param radius Optional. If a cached radius position already exists, overrides default.
  98155. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  98156. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  98157. * @param onAnimationEnd Callback triggered at the end of the framing animation
  98158. */
  98159. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  98160. /**
  98161. * Targets the given meshes with their children and updates zoom level accordingly.
  98162. * @param meshes The mesh to target.
  98163. * @param radius Optional. If a cached radius position already exists, overrides default.
  98164. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  98165. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  98166. * @param onAnimationEnd Callback triggered at the end of the framing animation
  98167. */
  98168. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  98169. /**
  98170. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  98171. * @param minimumWorld Determines the smaller position of the bounding box extend
  98172. * @param maximumWorld Determines the bigger position of the bounding box extend
  98173. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  98174. * @param onAnimationEnd Callback triggered at the end of the framing animation
  98175. */
  98176. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  98177. /**
  98178. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  98179. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  98180. * frustum width.
  98181. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  98182. * to fully enclose the mesh in the viewing frustum.
  98183. */
  98184. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  98185. /**
  98186. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  98187. * is automatically returned to its default position (expected to be above ground plane).
  98188. */
  98189. private _maintainCameraAboveGround;
  98190. /**
  98191. * Returns the frustum slope based on the canvas ratio and camera FOV
  98192. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  98193. */
  98194. private _getFrustumSlope;
  98195. /**
  98196. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  98197. */
  98198. private _clearAnimationLocks;
  98199. /**
  98200. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  98201. */
  98202. private _applyUserInteraction;
  98203. /**
  98204. * Stops and removes all animations that have been applied to the camera
  98205. */
  98206. stopAllAnimations(): void;
  98207. /**
  98208. * Gets a value indicating if the user is moving the camera
  98209. */
  98210. readonly isUserIsMoving: boolean;
  98211. /**
  98212. * The camera can move all the way towards the mesh.
  98213. */
  98214. static IgnoreBoundsSizeMode: number;
  98215. /**
  98216. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  98217. */
  98218. static FitFrustumSidesMode: number;
  98219. }
  98220. }
  98221. declare module BABYLON {
  98222. /**
  98223. * Base class for Camera Pointer Inputs.
  98224. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  98225. * for example usage.
  98226. */
  98227. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  98228. /**
  98229. * Defines the camera the input is attached to.
  98230. */
  98231. abstract camera: Camera;
  98232. /**
  98233. * Whether keyboard modifier keys are pressed at time of last mouse event.
  98234. */
  98235. protected _altKey: boolean;
  98236. protected _ctrlKey: boolean;
  98237. protected _metaKey: boolean;
  98238. protected _shiftKey: boolean;
  98239. /**
  98240. * Which mouse buttons were pressed at time of last mouse event.
  98241. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  98242. */
  98243. protected _buttonsPressed: number;
  98244. /**
  98245. * Defines the buttons associated with the input to handle camera move.
  98246. */
  98247. buttons: number[];
  98248. /**
  98249. * Attach the input controls to a specific dom element to get the input from.
  98250. * @param element Defines the element the controls should be listened from
  98251. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98252. */
  98253. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98254. /**
  98255. * Detach the current controls from the specified dom element.
  98256. * @param element Defines the element to stop listening the inputs from
  98257. */
  98258. detachControl(element: Nullable<HTMLElement>): void;
  98259. /**
  98260. * Gets the class name of the current input.
  98261. * @returns the class name
  98262. */
  98263. getClassName(): string;
  98264. /**
  98265. * Get the friendly name associated with the input class.
  98266. * @returns the input friendly name
  98267. */
  98268. getSimpleName(): string;
  98269. /**
  98270. * Called on pointer POINTERDOUBLETAP event.
  98271. * Override this method to provide functionality on POINTERDOUBLETAP event.
  98272. */
  98273. protected onDoubleTap(type: string): void;
  98274. /**
  98275. * Called on pointer POINTERMOVE event if only a single touch is active.
  98276. * Override this method to provide functionality.
  98277. */
  98278. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  98279. /**
  98280. * Called on pointer POINTERMOVE event if multiple touches are active.
  98281. * Override this method to provide functionality.
  98282. */
  98283. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  98284. /**
  98285. * Called on JS contextmenu event.
  98286. * Override this method to provide functionality.
  98287. */
  98288. protected onContextMenu(evt: PointerEvent): void;
  98289. /**
  98290. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  98291. * press.
  98292. * Override this method to provide functionality.
  98293. */
  98294. protected onButtonDown(evt: PointerEvent): void;
  98295. /**
  98296. * Called each time a new POINTERUP event occurs. Ie, for each button
  98297. * release.
  98298. * Override this method to provide functionality.
  98299. */
  98300. protected onButtonUp(evt: PointerEvent): void;
  98301. /**
  98302. * Called when window becomes inactive.
  98303. * Override this method to provide functionality.
  98304. */
  98305. protected onLostFocus(): void;
  98306. private _pointerInput;
  98307. private _observer;
  98308. private _onLostFocus;
  98309. private pointA;
  98310. private pointB;
  98311. }
  98312. }
  98313. declare module BABYLON {
  98314. /**
  98315. * Manage the pointers inputs to control an arc rotate camera.
  98316. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98317. */
  98318. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  98319. /**
  98320. * Defines the camera the input is attached to.
  98321. */
  98322. camera: ArcRotateCamera;
  98323. /**
  98324. * Gets the class name of the current input.
  98325. * @returns the class name
  98326. */
  98327. getClassName(): string;
  98328. /**
  98329. * Defines the buttons associated with the input to handle camera move.
  98330. */
  98331. buttons: number[];
  98332. /**
  98333. * Defines the pointer angular sensibility along the X axis or how fast is
  98334. * the camera rotating.
  98335. */
  98336. angularSensibilityX: number;
  98337. /**
  98338. * Defines the pointer angular sensibility along the Y axis or how fast is
  98339. * the camera rotating.
  98340. */
  98341. angularSensibilityY: number;
  98342. /**
  98343. * Defines the pointer pinch precision or how fast is the camera zooming.
  98344. */
  98345. pinchPrecision: number;
  98346. /**
  98347. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  98348. * from 0.
  98349. * It defines the percentage of current camera.radius to use as delta when
  98350. * pinch zoom is used.
  98351. */
  98352. pinchDeltaPercentage: number;
  98353. /**
  98354. * Defines the pointer panning sensibility or how fast is the camera moving.
  98355. */
  98356. panningSensibility: number;
  98357. /**
  98358. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  98359. */
  98360. multiTouchPanning: boolean;
  98361. /**
  98362. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  98363. * zoom (pinch) through multitouch.
  98364. */
  98365. multiTouchPanAndZoom: boolean;
  98366. /**
  98367. * Revers pinch action direction.
  98368. */
  98369. pinchInwards: boolean;
  98370. private _isPanClick;
  98371. private _twoFingerActivityCount;
  98372. private _isPinching;
  98373. /**
  98374. * Called on pointer POINTERMOVE event if only a single touch is active.
  98375. */
  98376. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  98377. /**
  98378. * Called on pointer POINTERDOUBLETAP event.
  98379. */
  98380. protected onDoubleTap(type: string): void;
  98381. /**
  98382. * Called on pointer POINTERMOVE event if multiple touches are active.
  98383. */
  98384. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  98385. /**
  98386. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  98387. * press.
  98388. */
  98389. protected onButtonDown(evt: PointerEvent): void;
  98390. /**
  98391. * Called each time a new POINTERUP event occurs. Ie, for each button
  98392. * release.
  98393. */
  98394. protected onButtonUp(evt: PointerEvent): void;
  98395. /**
  98396. * Called when window becomes inactive.
  98397. */
  98398. protected onLostFocus(): void;
  98399. }
  98400. }
  98401. declare module BABYLON {
  98402. /**
  98403. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  98404. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98405. */
  98406. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  98407. /**
  98408. * Defines the camera the input is attached to.
  98409. */
  98410. camera: ArcRotateCamera;
  98411. /**
  98412. * Defines the list of key codes associated with the up action (increase alpha)
  98413. */
  98414. keysUp: number[];
  98415. /**
  98416. * Defines the list of key codes associated with the down action (decrease alpha)
  98417. */
  98418. keysDown: number[];
  98419. /**
  98420. * Defines the list of key codes associated with the left action (increase beta)
  98421. */
  98422. keysLeft: number[];
  98423. /**
  98424. * Defines the list of key codes associated with the right action (decrease beta)
  98425. */
  98426. keysRight: number[];
  98427. /**
  98428. * Defines the list of key codes associated with the reset action.
  98429. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  98430. */
  98431. keysReset: number[];
  98432. /**
  98433. * Defines the panning sensibility of the inputs.
  98434. * (How fast is the camera paning)
  98435. */
  98436. panningSensibility: number;
  98437. /**
  98438. * Defines the zooming sensibility of the inputs.
  98439. * (How fast is the camera zooming)
  98440. */
  98441. zoomingSensibility: number;
  98442. /**
  98443. * Defines wether maintaining the alt key down switch the movement mode from
  98444. * orientation to zoom.
  98445. */
  98446. useAltToZoom: boolean;
  98447. /**
  98448. * Rotation speed of the camera
  98449. */
  98450. angularSpeed: number;
  98451. private _keys;
  98452. private _ctrlPressed;
  98453. private _altPressed;
  98454. private _onCanvasBlurObserver;
  98455. private _onKeyboardObserver;
  98456. private _engine;
  98457. private _scene;
  98458. /**
  98459. * Attach the input controls to a specific dom element to get the input from.
  98460. * @param element Defines the element the controls should be listened from
  98461. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98462. */
  98463. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98464. /**
  98465. * Detach the current controls from the specified dom element.
  98466. * @param element Defines the element to stop listening the inputs from
  98467. */
  98468. detachControl(element: Nullable<HTMLElement>): void;
  98469. /**
  98470. * Update the current camera state depending on the inputs that have been used this frame.
  98471. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98472. */
  98473. checkInputs(): void;
  98474. /**
  98475. * Gets the class name of the current intput.
  98476. * @returns the class name
  98477. */
  98478. getClassName(): string;
  98479. /**
  98480. * Get the friendly name associated with the input class.
  98481. * @returns the input friendly name
  98482. */
  98483. getSimpleName(): string;
  98484. }
  98485. }
  98486. declare module BABYLON {
  98487. /**
  98488. * Manage the mouse wheel inputs to control an arc rotate camera.
  98489. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98490. */
  98491. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  98492. /**
  98493. * Defines the camera the input is attached to.
  98494. */
  98495. camera: ArcRotateCamera;
  98496. /**
  98497. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  98498. */
  98499. wheelPrecision: number;
  98500. /**
  98501. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  98502. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  98503. */
  98504. wheelDeltaPercentage: number;
  98505. private _wheel;
  98506. private _observer;
  98507. private computeDeltaFromMouseWheelLegacyEvent;
  98508. /**
  98509. * Attach the input controls to a specific dom element to get the input from.
  98510. * @param element Defines the element the controls should be listened from
  98511. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98512. */
  98513. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98514. /**
  98515. * Detach the current controls from the specified dom element.
  98516. * @param element Defines the element to stop listening the inputs from
  98517. */
  98518. detachControl(element: Nullable<HTMLElement>): void;
  98519. /**
  98520. * Gets the class name of the current intput.
  98521. * @returns the class name
  98522. */
  98523. getClassName(): string;
  98524. /**
  98525. * Get the friendly name associated with the input class.
  98526. * @returns the input friendly name
  98527. */
  98528. getSimpleName(): string;
  98529. }
  98530. }
  98531. declare module BABYLON {
  98532. /**
  98533. * Default Inputs manager for the ArcRotateCamera.
  98534. * It groups all the default supported inputs for ease of use.
  98535. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98536. */
  98537. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  98538. /**
  98539. * Instantiates a new ArcRotateCameraInputsManager.
  98540. * @param camera Defines the camera the inputs belong to
  98541. */
  98542. constructor(camera: ArcRotateCamera);
  98543. /**
  98544. * Add mouse wheel input support to the input manager.
  98545. * @returns the current input manager
  98546. */
  98547. addMouseWheel(): ArcRotateCameraInputsManager;
  98548. /**
  98549. * Add pointers input support to the input manager.
  98550. * @returns the current input manager
  98551. */
  98552. addPointers(): ArcRotateCameraInputsManager;
  98553. /**
  98554. * Add keyboard input support to the input manager.
  98555. * @returns the current input manager
  98556. */
  98557. addKeyboard(): ArcRotateCameraInputsManager;
  98558. }
  98559. }
  98560. declare module BABYLON {
  98561. /**
  98562. * This represents an orbital type of camera.
  98563. *
  98564. * 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.
  98565. * 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.
  98566. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  98567. */
  98568. export class ArcRotateCamera extends TargetCamera {
  98569. /**
  98570. * Defines the rotation angle of the camera along the longitudinal axis.
  98571. */
  98572. alpha: number;
  98573. /**
  98574. * Defines the rotation angle of the camera along the latitudinal axis.
  98575. */
  98576. beta: number;
  98577. /**
  98578. * Defines the radius of the camera from it s target point.
  98579. */
  98580. radius: number;
  98581. protected _target: Vector3;
  98582. protected _targetHost: Nullable<AbstractMesh>;
  98583. /**
  98584. * Defines the target point of the camera.
  98585. * The camera looks towards it form the radius distance.
  98586. */
  98587. target: Vector3;
  98588. /**
  98589. * Define the current local position of the camera in the scene
  98590. */
  98591. position: Vector3;
  98592. protected _upVector: Vector3;
  98593. protected _upToYMatrix: Matrix;
  98594. protected _YToUpMatrix: Matrix;
  98595. /**
  98596. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  98597. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  98598. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  98599. */
  98600. upVector: Vector3;
  98601. /**
  98602. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  98603. */
  98604. setMatUp(): void;
  98605. /**
  98606. * Current inertia value on the longitudinal axis.
  98607. * The bigger this number the longer it will take for the camera to stop.
  98608. */
  98609. inertialAlphaOffset: number;
  98610. /**
  98611. * Current inertia value on the latitudinal axis.
  98612. * The bigger this number the longer it will take for the camera to stop.
  98613. */
  98614. inertialBetaOffset: number;
  98615. /**
  98616. * Current inertia value on the radius axis.
  98617. * The bigger this number the longer it will take for the camera to stop.
  98618. */
  98619. inertialRadiusOffset: number;
  98620. /**
  98621. * Minimum allowed angle on the longitudinal axis.
  98622. * This can help limiting how the Camera is able to move in the scene.
  98623. */
  98624. lowerAlphaLimit: Nullable<number>;
  98625. /**
  98626. * Maximum allowed angle on the longitudinal axis.
  98627. * This can help limiting how the Camera is able to move in the scene.
  98628. */
  98629. upperAlphaLimit: Nullable<number>;
  98630. /**
  98631. * Minimum allowed angle on the latitudinal axis.
  98632. * This can help limiting how the Camera is able to move in the scene.
  98633. */
  98634. lowerBetaLimit: number;
  98635. /**
  98636. * Maximum allowed angle on the latitudinal axis.
  98637. * This can help limiting how the Camera is able to move in the scene.
  98638. */
  98639. upperBetaLimit: number;
  98640. /**
  98641. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  98642. * This can help limiting how the Camera is able to move in the scene.
  98643. */
  98644. lowerRadiusLimit: Nullable<number>;
  98645. /**
  98646. * Maximum allowed distance of the camera to the target (The camera can not get further).
  98647. * This can help limiting how the Camera is able to move in the scene.
  98648. */
  98649. upperRadiusLimit: Nullable<number>;
  98650. /**
  98651. * Defines the current inertia value used during panning of the camera along the X axis.
  98652. */
  98653. inertialPanningX: number;
  98654. /**
  98655. * Defines the current inertia value used during panning of the camera along the Y axis.
  98656. */
  98657. inertialPanningY: number;
  98658. /**
  98659. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  98660. * Basically if your fingers moves away from more than this distance you will be considered
  98661. * in pinch mode.
  98662. */
  98663. pinchToPanMaxDistance: number;
  98664. /**
  98665. * Defines the maximum distance the camera can pan.
  98666. * This could help keeping the cammera always in your scene.
  98667. */
  98668. panningDistanceLimit: Nullable<number>;
  98669. /**
  98670. * Defines the target of the camera before paning.
  98671. */
  98672. panningOriginTarget: Vector3;
  98673. /**
  98674. * Defines the value of the inertia used during panning.
  98675. * 0 would mean stop inertia and one would mean no decelleration at all.
  98676. */
  98677. panningInertia: number;
  98678. /**
  98679. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  98680. */
  98681. angularSensibilityX: number;
  98682. /**
  98683. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  98684. */
  98685. angularSensibilityY: number;
  98686. /**
  98687. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  98688. */
  98689. pinchPrecision: number;
  98690. /**
  98691. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  98692. * It will be used instead of pinchDeltaPrecision if different from 0.
  98693. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  98694. */
  98695. pinchDeltaPercentage: number;
  98696. /**
  98697. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  98698. */
  98699. panningSensibility: number;
  98700. /**
  98701. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  98702. */
  98703. keysUp: number[];
  98704. /**
  98705. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  98706. */
  98707. keysDown: number[];
  98708. /**
  98709. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  98710. */
  98711. keysLeft: number[];
  98712. /**
  98713. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  98714. */
  98715. keysRight: number[];
  98716. /**
  98717. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  98718. */
  98719. wheelPrecision: number;
  98720. /**
  98721. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  98722. * It will be used instead of pinchDeltaPrecision if different from 0.
  98723. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  98724. */
  98725. wheelDeltaPercentage: number;
  98726. /**
  98727. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  98728. */
  98729. zoomOnFactor: number;
  98730. /**
  98731. * Defines a screen offset for the camera position.
  98732. */
  98733. targetScreenOffset: Vector2;
  98734. /**
  98735. * Allows the camera to be completely reversed.
  98736. * If false the camera can not arrive upside down.
  98737. */
  98738. allowUpsideDown: boolean;
  98739. /**
  98740. * Define if double tap/click is used to restore the previously saved state of the camera.
  98741. */
  98742. useInputToRestoreState: boolean;
  98743. /** @hidden */
  98744. _viewMatrix: Matrix;
  98745. /** @hidden */
  98746. _useCtrlForPanning: boolean;
  98747. /** @hidden */
  98748. _panningMouseButton: number;
  98749. /**
  98750. * Defines the input associated to the camera.
  98751. */
  98752. inputs: ArcRotateCameraInputsManager;
  98753. /** @hidden */
  98754. _reset: () => void;
  98755. /**
  98756. * Defines the allowed panning axis.
  98757. */
  98758. panningAxis: Vector3;
  98759. protected _localDirection: Vector3;
  98760. protected _transformedDirection: Vector3;
  98761. private _bouncingBehavior;
  98762. /**
  98763. * Gets the bouncing behavior of the camera if it has been enabled.
  98764. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  98765. */
  98766. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  98767. /**
  98768. * Defines if the bouncing behavior of the camera is enabled on the camera.
  98769. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  98770. */
  98771. useBouncingBehavior: boolean;
  98772. private _framingBehavior;
  98773. /**
  98774. * Gets the framing behavior of the camera if it has been enabled.
  98775. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  98776. */
  98777. readonly framingBehavior: Nullable<FramingBehavior>;
  98778. /**
  98779. * Defines if the framing behavior of the camera is enabled on the camera.
  98780. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  98781. */
  98782. useFramingBehavior: boolean;
  98783. private _autoRotationBehavior;
  98784. /**
  98785. * Gets the auto rotation behavior of the camera if it has been enabled.
  98786. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98787. */
  98788. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  98789. /**
  98790. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  98791. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98792. */
  98793. useAutoRotationBehavior: boolean;
  98794. /**
  98795. * Observable triggered when the mesh target has been changed on the camera.
  98796. */
  98797. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  98798. /**
  98799. * Event raised when the camera is colliding with a mesh.
  98800. */
  98801. onCollide: (collidedMesh: AbstractMesh) => void;
  98802. /**
  98803. * Defines whether the camera should check collision with the objects oh the scene.
  98804. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  98805. */
  98806. checkCollisions: boolean;
  98807. /**
  98808. * Defines the collision radius of the camera.
  98809. * This simulates a sphere around the camera.
  98810. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  98811. */
  98812. collisionRadius: Vector3;
  98813. protected _collider: Collider;
  98814. protected _previousPosition: Vector3;
  98815. protected _collisionVelocity: Vector3;
  98816. protected _newPosition: Vector3;
  98817. protected _previousAlpha: number;
  98818. protected _previousBeta: number;
  98819. protected _previousRadius: number;
  98820. protected _collisionTriggered: boolean;
  98821. protected _targetBoundingCenter: Nullable<Vector3>;
  98822. private _computationVector;
  98823. /**
  98824. * Instantiates a new ArcRotateCamera in a given scene
  98825. * @param name Defines the name of the camera
  98826. * @param alpha Defines the camera rotation along the logitudinal axis
  98827. * @param beta Defines the camera rotation along the latitudinal axis
  98828. * @param radius Defines the camera distance from its target
  98829. * @param target Defines the camera target
  98830. * @param scene Defines the scene the camera belongs to
  98831. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98832. */
  98833. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98834. /** @hidden */
  98835. _initCache(): void;
  98836. /** @hidden */
  98837. _updateCache(ignoreParentClass?: boolean): void;
  98838. protected _getTargetPosition(): Vector3;
  98839. private _storedAlpha;
  98840. private _storedBeta;
  98841. private _storedRadius;
  98842. private _storedTarget;
  98843. /**
  98844. * Stores the current state of the camera (alpha, beta, radius and target)
  98845. * @returns the camera itself
  98846. */
  98847. storeState(): Camera;
  98848. /**
  98849. * @hidden
  98850. * Restored camera state. You must call storeState() first
  98851. */
  98852. _restoreStateValues(): boolean;
  98853. /** @hidden */
  98854. _isSynchronizedViewMatrix(): boolean;
  98855. /**
  98856. * Attached controls to the current camera.
  98857. * @param element Defines the element the controls should be listened from
  98858. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98859. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  98860. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  98861. */
  98862. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  98863. /**
  98864. * Detach the current controls from the camera.
  98865. * The camera will stop reacting to inputs.
  98866. * @param element Defines the element to stop listening the inputs from
  98867. */
  98868. detachControl(element: HTMLElement): void;
  98869. /** @hidden */
  98870. _checkInputs(): void;
  98871. protected _checkLimits(): void;
  98872. /**
  98873. * Rebuilds angles (alpha, beta) and radius from the give position and target
  98874. */
  98875. rebuildAnglesAndRadius(): void;
  98876. /**
  98877. * Use a position to define the current camera related information like aplha, beta and radius
  98878. * @param position Defines the position to set the camera at
  98879. */
  98880. setPosition(position: Vector3): void;
  98881. /**
  98882. * Defines the target the camera should look at.
  98883. * This will automatically adapt alpha beta and radius to fit within the new target.
  98884. * @param target Defines the new target as a Vector or a mesh
  98885. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  98886. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  98887. */
  98888. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  98889. /** @hidden */
  98890. _getViewMatrix(): Matrix;
  98891. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  98892. /**
  98893. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  98894. * @param meshes Defines the mesh to zoom on
  98895. * @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)
  98896. */
  98897. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  98898. /**
  98899. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  98900. * The target will be changed but the radius
  98901. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  98902. * @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)
  98903. */
  98904. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  98905. min: Vector3;
  98906. max: Vector3;
  98907. distance: number;
  98908. }, doNotUpdateMaxZ?: boolean): void;
  98909. /**
  98910. * @override
  98911. * Override Camera.createRigCamera
  98912. */
  98913. createRigCamera(name: string, cameraIndex: number): Camera;
  98914. /**
  98915. * @hidden
  98916. * @override
  98917. * Override Camera._updateRigCameras
  98918. */
  98919. _updateRigCameras(): void;
  98920. /**
  98921. * Destroy the camera and release the current resources hold by it.
  98922. */
  98923. dispose(): void;
  98924. /**
  98925. * Gets the current object class name.
  98926. * @return the class name
  98927. */
  98928. getClassName(): string;
  98929. }
  98930. }
  98931. declare module BABYLON {
  98932. /**
  98933. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  98934. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98935. */
  98936. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  98937. /**
  98938. * Gets the name of the behavior.
  98939. */
  98940. readonly name: string;
  98941. private _zoomStopsAnimation;
  98942. private _idleRotationSpeed;
  98943. private _idleRotationWaitTime;
  98944. private _idleRotationSpinupTime;
  98945. /**
  98946. * Sets the flag that indicates if user zooming should stop animation.
  98947. */
  98948. /**
  98949. * Gets the flag that indicates if user zooming should stop animation.
  98950. */
  98951. zoomStopsAnimation: boolean;
  98952. /**
  98953. * Sets the default speed at which the camera rotates around the model.
  98954. */
  98955. /**
  98956. * Gets the default speed at which the camera rotates around the model.
  98957. */
  98958. idleRotationSpeed: number;
  98959. /**
  98960. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  98961. */
  98962. /**
  98963. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  98964. */
  98965. idleRotationWaitTime: number;
  98966. /**
  98967. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  98968. */
  98969. /**
  98970. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  98971. */
  98972. idleRotationSpinupTime: number;
  98973. /**
  98974. * Gets a value indicating if the camera is currently rotating because of this behavior
  98975. */
  98976. readonly rotationInProgress: boolean;
  98977. private _onPrePointerObservableObserver;
  98978. private _onAfterCheckInputsObserver;
  98979. private _attachedCamera;
  98980. private _isPointerDown;
  98981. private _lastFrameTime;
  98982. private _lastInteractionTime;
  98983. private _cameraRotationSpeed;
  98984. /**
  98985. * Initializes the behavior.
  98986. */
  98987. init(): void;
  98988. /**
  98989. * Attaches the behavior to its arc rotate camera.
  98990. * @param camera Defines the camera to attach the behavior to
  98991. */
  98992. attach(camera: ArcRotateCamera): void;
  98993. /**
  98994. * Detaches the behavior from its current arc rotate camera.
  98995. */
  98996. detach(): void;
  98997. /**
  98998. * Returns true if user is scrolling.
  98999. * @return true if user is scrolling.
  99000. */
  99001. private _userIsZooming;
  99002. private _lastFrameRadius;
  99003. private _shouldAnimationStopForInteraction;
  99004. /**
  99005. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  99006. */
  99007. private _applyUserInteraction;
  99008. private _userIsMoving;
  99009. }
  99010. }
  99011. declare module BABYLON {
  99012. /**
  99013. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  99014. */
  99015. export class AttachToBoxBehavior implements Behavior<Mesh> {
  99016. private ui;
  99017. /**
  99018. * The name of the behavior
  99019. */
  99020. name: string;
  99021. /**
  99022. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  99023. */
  99024. distanceAwayFromFace: number;
  99025. /**
  99026. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  99027. */
  99028. distanceAwayFromBottomOfFace: number;
  99029. private _faceVectors;
  99030. private _target;
  99031. private _scene;
  99032. private _onRenderObserver;
  99033. private _tmpMatrix;
  99034. private _tmpVector;
  99035. /**
  99036. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  99037. * @param ui The transform node that should be attched to the mesh
  99038. */
  99039. constructor(ui: TransformNode);
  99040. /**
  99041. * Initializes the behavior
  99042. */
  99043. init(): void;
  99044. private _closestFace;
  99045. private _zeroVector;
  99046. private _lookAtTmpMatrix;
  99047. private _lookAtToRef;
  99048. /**
  99049. * Attaches the AttachToBoxBehavior to the passed in mesh
  99050. * @param target The mesh that the specified node will be attached to
  99051. */
  99052. attach(target: Mesh): void;
  99053. /**
  99054. * Detaches the behavior from the mesh
  99055. */
  99056. detach(): void;
  99057. }
  99058. }
  99059. declare module BABYLON {
  99060. /**
  99061. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  99062. */
  99063. export class FadeInOutBehavior implements Behavior<Mesh> {
  99064. /**
  99065. * Time in milliseconds to delay before fading in (Default: 0)
  99066. */
  99067. delay: number;
  99068. /**
  99069. * Time in milliseconds for the mesh to fade in (Default: 300)
  99070. */
  99071. fadeInTime: number;
  99072. private _millisecondsPerFrame;
  99073. private _hovered;
  99074. private _hoverValue;
  99075. private _ownerNode;
  99076. /**
  99077. * Instatiates the FadeInOutBehavior
  99078. */
  99079. constructor();
  99080. /**
  99081. * The name of the behavior
  99082. */
  99083. readonly name: string;
  99084. /**
  99085. * Initializes the behavior
  99086. */
  99087. init(): void;
  99088. /**
  99089. * Attaches the fade behavior on the passed in mesh
  99090. * @param ownerNode The mesh that will be faded in/out once attached
  99091. */
  99092. attach(ownerNode: Mesh): void;
  99093. /**
  99094. * Detaches the behavior from the mesh
  99095. */
  99096. detach(): void;
  99097. /**
  99098. * Triggers the mesh to begin fading in or out
  99099. * @param value if the object should fade in or out (true to fade in)
  99100. */
  99101. fadeIn(value: boolean): void;
  99102. private _update;
  99103. private _setAllVisibility;
  99104. }
  99105. }
  99106. declare module BABYLON {
  99107. /**
  99108. * Class containing a set of static utilities functions for managing Pivots
  99109. * @hidden
  99110. */
  99111. export class PivotTools {
  99112. private static _PivotCached;
  99113. private static _OldPivotPoint;
  99114. private static _PivotTranslation;
  99115. private static _PivotTmpVector;
  99116. /** @hidden */
  99117. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  99118. /** @hidden */
  99119. static _RestorePivotPoint(mesh: AbstractMesh): void;
  99120. }
  99121. }
  99122. declare module BABYLON {
  99123. /**
  99124. * Class containing static functions to help procedurally build meshes
  99125. */
  99126. export class PlaneBuilder {
  99127. /**
  99128. * Creates a plane mesh
  99129. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  99130. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  99131. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  99132. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99133. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99135. * @param name defines the name of the mesh
  99136. * @param options defines the options used to create the mesh
  99137. * @param scene defines the hosting scene
  99138. * @returns the plane mesh
  99139. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  99140. */
  99141. static CreatePlane(name: string, options: {
  99142. size?: number;
  99143. width?: number;
  99144. height?: number;
  99145. sideOrientation?: number;
  99146. frontUVs?: Vector4;
  99147. backUVs?: Vector4;
  99148. updatable?: boolean;
  99149. sourcePlane?: Plane;
  99150. }, scene?: Nullable<Scene>): Mesh;
  99151. }
  99152. }
  99153. declare module BABYLON {
  99154. /**
  99155. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  99156. */
  99157. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  99158. private static _AnyMouseID;
  99159. /**
  99160. * Abstract mesh the behavior is set on
  99161. */
  99162. attachedNode: AbstractMesh;
  99163. private _dragPlane;
  99164. private _scene;
  99165. private _pointerObserver;
  99166. private _beforeRenderObserver;
  99167. private static _planeScene;
  99168. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  99169. /**
  99170. * 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)
  99171. */
  99172. maxDragAngle: number;
  99173. /**
  99174. * @hidden
  99175. */
  99176. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  99177. /**
  99178. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  99179. */
  99180. currentDraggingPointerID: number;
  99181. /**
  99182. * The last position where the pointer hit the drag plane in world space
  99183. */
  99184. lastDragPosition: Vector3;
  99185. /**
  99186. * If the behavior is currently in a dragging state
  99187. */
  99188. dragging: boolean;
  99189. /**
  99190. * 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)
  99191. */
  99192. dragDeltaRatio: number;
  99193. /**
  99194. * If the drag plane orientation should be updated during the dragging (Default: true)
  99195. */
  99196. updateDragPlane: boolean;
  99197. private _debugMode;
  99198. private _moving;
  99199. /**
  99200. * Fires each time the attached mesh is dragged with the pointer
  99201. * * delta between last drag position and current drag position in world space
  99202. * * dragDistance along the drag axis
  99203. * * dragPlaneNormal normal of the current drag plane used during the drag
  99204. * * dragPlanePoint in world space where the drag intersects the drag plane
  99205. */
  99206. onDragObservable: Observable<{
  99207. delta: Vector3;
  99208. dragPlanePoint: Vector3;
  99209. dragPlaneNormal: Vector3;
  99210. dragDistance: number;
  99211. pointerId: number;
  99212. }>;
  99213. /**
  99214. * Fires each time a drag begins (eg. mouse down on mesh)
  99215. */
  99216. onDragStartObservable: Observable<{
  99217. dragPlanePoint: Vector3;
  99218. pointerId: number;
  99219. }>;
  99220. /**
  99221. * Fires each time a drag ends (eg. mouse release after drag)
  99222. */
  99223. onDragEndObservable: Observable<{
  99224. dragPlanePoint: Vector3;
  99225. pointerId: number;
  99226. }>;
  99227. /**
  99228. * If the attached mesh should be moved when dragged
  99229. */
  99230. moveAttached: boolean;
  99231. /**
  99232. * If the drag behavior will react to drag events (Default: true)
  99233. */
  99234. enabled: boolean;
  99235. /**
  99236. * If pointer events should start and release the drag (Default: true)
  99237. */
  99238. startAndReleaseDragOnPointerEvents: boolean;
  99239. /**
  99240. * If camera controls should be detached during the drag
  99241. */
  99242. detachCameraControls: boolean;
  99243. /**
  99244. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  99245. */
  99246. useObjectOrienationForDragging: boolean;
  99247. private _options;
  99248. /**
  99249. * Creates a pointer drag behavior that can be attached to a mesh
  99250. * @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)
  99251. */
  99252. constructor(options?: {
  99253. dragAxis?: Vector3;
  99254. dragPlaneNormal?: Vector3;
  99255. });
  99256. /**
  99257. * Predicate to determine if it is valid to move the object to a new position when it is moved
  99258. */
  99259. validateDrag: (targetPosition: Vector3) => boolean;
  99260. /**
  99261. * The name of the behavior
  99262. */
  99263. readonly name: string;
  99264. /**
  99265. * Initializes the behavior
  99266. */
  99267. init(): void;
  99268. private _tmpVector;
  99269. private _alternatePickedPoint;
  99270. private _worldDragAxis;
  99271. private _targetPosition;
  99272. private _attachedElement;
  99273. /**
  99274. * Attaches the drag behavior the passed in mesh
  99275. * @param ownerNode The mesh that will be dragged around once attached
  99276. */
  99277. attach(ownerNode: AbstractMesh): void;
  99278. /**
  99279. * Force relase the drag action by code.
  99280. */
  99281. releaseDrag(): void;
  99282. private _startDragRay;
  99283. private _lastPointerRay;
  99284. /**
  99285. * Simulates the start of a pointer drag event on the behavior
  99286. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  99287. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  99288. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  99289. */
  99290. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  99291. private _startDrag;
  99292. private _dragDelta;
  99293. private _moveDrag;
  99294. private _pickWithRayOnDragPlane;
  99295. private _pointA;
  99296. private _pointB;
  99297. private _pointC;
  99298. private _lineA;
  99299. private _lineB;
  99300. private _localAxis;
  99301. private _lookAt;
  99302. private _updateDragPlanePosition;
  99303. /**
  99304. * Detaches the behavior from the mesh
  99305. */
  99306. detach(): void;
  99307. }
  99308. }
  99309. declare module BABYLON {
  99310. /**
  99311. * A behavior that when attached to a mesh will allow the mesh to be scaled
  99312. */
  99313. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  99314. private _dragBehaviorA;
  99315. private _dragBehaviorB;
  99316. private _startDistance;
  99317. private _initialScale;
  99318. private _targetScale;
  99319. private _ownerNode;
  99320. private _sceneRenderObserver;
  99321. /**
  99322. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  99323. */
  99324. constructor();
  99325. /**
  99326. * The name of the behavior
  99327. */
  99328. readonly name: string;
  99329. /**
  99330. * Initializes the behavior
  99331. */
  99332. init(): void;
  99333. private _getCurrentDistance;
  99334. /**
  99335. * Attaches the scale behavior the passed in mesh
  99336. * @param ownerNode The mesh that will be scaled around once attached
  99337. */
  99338. attach(ownerNode: Mesh): void;
  99339. /**
  99340. * Detaches the behavior from the mesh
  99341. */
  99342. detach(): void;
  99343. }
  99344. }
  99345. declare module BABYLON {
  99346. /**
  99347. * 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
  99348. */
  99349. export class SixDofDragBehavior implements Behavior<Mesh> {
  99350. private static _virtualScene;
  99351. private _ownerNode;
  99352. private _sceneRenderObserver;
  99353. private _scene;
  99354. private _targetPosition;
  99355. private _virtualOriginMesh;
  99356. private _virtualDragMesh;
  99357. private _pointerObserver;
  99358. private _moving;
  99359. private _startingOrientation;
  99360. /**
  99361. * 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)
  99362. */
  99363. private zDragFactor;
  99364. /**
  99365. * If the object should rotate to face the drag origin
  99366. */
  99367. rotateDraggedObject: boolean;
  99368. /**
  99369. * If the behavior is currently in a dragging state
  99370. */
  99371. dragging: boolean;
  99372. /**
  99373. * 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)
  99374. */
  99375. dragDeltaRatio: number;
  99376. /**
  99377. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  99378. */
  99379. currentDraggingPointerID: number;
  99380. /**
  99381. * If camera controls should be detached during the drag
  99382. */
  99383. detachCameraControls: boolean;
  99384. /**
  99385. * Fires each time a drag starts
  99386. */
  99387. onDragStartObservable: Observable<{}>;
  99388. /**
  99389. * Fires each time a drag ends (eg. mouse release after drag)
  99390. */
  99391. onDragEndObservable: Observable<{}>;
  99392. /**
  99393. * 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
  99394. */
  99395. constructor();
  99396. /**
  99397. * The name of the behavior
  99398. */
  99399. readonly name: string;
  99400. /**
  99401. * Initializes the behavior
  99402. */
  99403. init(): void;
  99404. /**
  99405. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  99406. */
  99407. private readonly _pointerCamera;
  99408. /**
  99409. * Attaches the scale behavior the passed in mesh
  99410. * @param ownerNode The mesh that will be scaled around once attached
  99411. */
  99412. attach(ownerNode: Mesh): void;
  99413. /**
  99414. * Detaches the behavior from the mesh
  99415. */
  99416. detach(): void;
  99417. }
  99418. }
  99419. declare module BABYLON {
  99420. /**
  99421. * Class used to apply inverse kinematics to bones
  99422. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  99423. */
  99424. export class BoneIKController {
  99425. private static _tmpVecs;
  99426. private static _tmpQuat;
  99427. private static _tmpMats;
  99428. /**
  99429. * Gets or sets the target mesh
  99430. */
  99431. targetMesh: AbstractMesh;
  99432. /** Gets or sets the mesh used as pole */
  99433. poleTargetMesh: AbstractMesh;
  99434. /**
  99435. * Gets or sets the bone used as pole
  99436. */
  99437. poleTargetBone: Nullable<Bone>;
  99438. /**
  99439. * Gets or sets the target position
  99440. */
  99441. targetPosition: Vector3;
  99442. /**
  99443. * Gets or sets the pole target position
  99444. */
  99445. poleTargetPosition: Vector3;
  99446. /**
  99447. * Gets or sets the pole target local offset
  99448. */
  99449. poleTargetLocalOffset: Vector3;
  99450. /**
  99451. * Gets or sets the pole angle
  99452. */
  99453. poleAngle: number;
  99454. /**
  99455. * Gets or sets the mesh associated with the controller
  99456. */
  99457. mesh: AbstractMesh;
  99458. /**
  99459. * 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)
  99460. */
  99461. slerpAmount: number;
  99462. private _bone1Quat;
  99463. private _bone1Mat;
  99464. private _bone2Ang;
  99465. private _bone1;
  99466. private _bone2;
  99467. private _bone1Length;
  99468. private _bone2Length;
  99469. private _maxAngle;
  99470. private _maxReach;
  99471. private _rightHandedSystem;
  99472. private _bendAxis;
  99473. private _slerping;
  99474. private _adjustRoll;
  99475. /**
  99476. * Gets or sets maximum allowed angle
  99477. */
  99478. maxAngle: number;
  99479. /**
  99480. * Creates a new BoneIKController
  99481. * @param mesh defines the mesh to control
  99482. * @param bone defines the bone to control
  99483. * @param options defines options to set up the controller
  99484. */
  99485. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  99486. targetMesh?: AbstractMesh;
  99487. poleTargetMesh?: AbstractMesh;
  99488. poleTargetBone?: Bone;
  99489. poleTargetLocalOffset?: Vector3;
  99490. poleAngle?: number;
  99491. bendAxis?: Vector3;
  99492. maxAngle?: number;
  99493. slerpAmount?: number;
  99494. });
  99495. private _setMaxAngle;
  99496. /**
  99497. * Force the controller to update the bones
  99498. */
  99499. update(): void;
  99500. }
  99501. }
  99502. declare module BABYLON {
  99503. /**
  99504. * Class used to make a bone look toward a point in space
  99505. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  99506. */
  99507. export class BoneLookController {
  99508. private static _tmpVecs;
  99509. private static _tmpQuat;
  99510. private static _tmpMats;
  99511. /**
  99512. * The target Vector3 that the bone will look at
  99513. */
  99514. target: Vector3;
  99515. /**
  99516. * The mesh that the bone is attached to
  99517. */
  99518. mesh: AbstractMesh;
  99519. /**
  99520. * The bone that will be looking to the target
  99521. */
  99522. bone: Bone;
  99523. /**
  99524. * The up axis of the coordinate system that is used when the bone is rotated
  99525. */
  99526. upAxis: Vector3;
  99527. /**
  99528. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  99529. */
  99530. upAxisSpace: Space;
  99531. /**
  99532. * Used to make an adjustment to the yaw of the bone
  99533. */
  99534. adjustYaw: number;
  99535. /**
  99536. * Used to make an adjustment to the pitch of the bone
  99537. */
  99538. adjustPitch: number;
  99539. /**
  99540. * Used to make an adjustment to the roll of the bone
  99541. */
  99542. adjustRoll: number;
  99543. /**
  99544. * 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)
  99545. */
  99546. slerpAmount: number;
  99547. private _minYaw;
  99548. private _maxYaw;
  99549. private _minPitch;
  99550. private _maxPitch;
  99551. private _minYawSin;
  99552. private _minYawCos;
  99553. private _maxYawSin;
  99554. private _maxYawCos;
  99555. private _midYawConstraint;
  99556. private _minPitchTan;
  99557. private _maxPitchTan;
  99558. private _boneQuat;
  99559. private _slerping;
  99560. private _transformYawPitch;
  99561. private _transformYawPitchInv;
  99562. private _firstFrameSkipped;
  99563. private _yawRange;
  99564. private _fowardAxis;
  99565. /**
  99566. * Gets or sets the minimum yaw angle that the bone can look to
  99567. */
  99568. minYaw: number;
  99569. /**
  99570. * Gets or sets the maximum yaw angle that the bone can look to
  99571. */
  99572. maxYaw: number;
  99573. /**
  99574. * Gets or sets the minimum pitch angle that the bone can look to
  99575. */
  99576. minPitch: number;
  99577. /**
  99578. * Gets or sets the maximum pitch angle that the bone can look to
  99579. */
  99580. maxPitch: number;
  99581. /**
  99582. * Create a BoneLookController
  99583. * @param mesh the mesh that the bone belongs to
  99584. * @param bone the bone that will be looking to the target
  99585. * @param target the target Vector3 to look at
  99586. * @param options optional settings:
  99587. * * maxYaw: the maximum angle the bone will yaw to
  99588. * * minYaw: the minimum angle the bone will yaw to
  99589. * * maxPitch: the maximum angle the bone will pitch to
  99590. * * minPitch: the minimum angle the bone will yaw to
  99591. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  99592. * * upAxis: the up axis of the coordinate system
  99593. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  99594. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  99595. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  99596. * * adjustYaw: used to make an adjustment to the yaw of the bone
  99597. * * adjustPitch: used to make an adjustment to the pitch of the bone
  99598. * * adjustRoll: used to make an adjustment to the roll of the bone
  99599. **/
  99600. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  99601. maxYaw?: number;
  99602. minYaw?: number;
  99603. maxPitch?: number;
  99604. minPitch?: number;
  99605. slerpAmount?: number;
  99606. upAxis?: Vector3;
  99607. upAxisSpace?: Space;
  99608. yawAxis?: Vector3;
  99609. pitchAxis?: Vector3;
  99610. adjustYaw?: number;
  99611. adjustPitch?: number;
  99612. adjustRoll?: number;
  99613. });
  99614. /**
  99615. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  99616. */
  99617. update(): void;
  99618. private _getAngleDiff;
  99619. private _getAngleBetween;
  99620. private _isAngleBetween;
  99621. }
  99622. }
  99623. declare module BABYLON {
  99624. /**
  99625. * Manage the gamepad inputs to control an arc rotate camera.
  99626. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99627. */
  99628. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  99629. /**
  99630. * Defines the camera the input is attached to.
  99631. */
  99632. camera: ArcRotateCamera;
  99633. /**
  99634. * Defines the gamepad the input is gathering event from.
  99635. */
  99636. gamepad: Nullable<Gamepad>;
  99637. /**
  99638. * Defines the gamepad rotation sensiblity.
  99639. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  99640. */
  99641. gamepadRotationSensibility: number;
  99642. /**
  99643. * Defines the gamepad move sensiblity.
  99644. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  99645. */
  99646. gamepadMoveSensibility: number;
  99647. private _onGamepadConnectedObserver;
  99648. private _onGamepadDisconnectedObserver;
  99649. /**
  99650. * Attach the input controls to a specific dom element to get the input from.
  99651. * @param element Defines the element the controls should be listened from
  99652. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99653. */
  99654. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99655. /**
  99656. * Detach the current controls from the specified dom element.
  99657. * @param element Defines the element to stop listening the inputs from
  99658. */
  99659. detachControl(element: Nullable<HTMLElement>): void;
  99660. /**
  99661. * Update the current camera state depending on the inputs that have been used this frame.
  99662. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99663. */
  99664. checkInputs(): void;
  99665. /**
  99666. * Gets the class name of the current intput.
  99667. * @returns the class name
  99668. */
  99669. getClassName(): string;
  99670. /**
  99671. * Get the friendly name associated with the input class.
  99672. * @returns the input friendly name
  99673. */
  99674. getSimpleName(): string;
  99675. }
  99676. }
  99677. declare module BABYLON {
  99678. interface ArcRotateCameraInputsManager {
  99679. /**
  99680. * Add orientation input support to the input manager.
  99681. * @returns the current input manager
  99682. */
  99683. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  99684. }
  99685. /**
  99686. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  99687. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99688. */
  99689. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  99690. /**
  99691. * Defines the camera the input is attached to.
  99692. */
  99693. camera: ArcRotateCamera;
  99694. /**
  99695. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  99696. */
  99697. alphaCorrection: number;
  99698. /**
  99699. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  99700. */
  99701. gammaCorrection: number;
  99702. private _alpha;
  99703. private _gamma;
  99704. private _dirty;
  99705. private _deviceOrientationHandler;
  99706. /**
  99707. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  99708. */
  99709. constructor();
  99710. /**
  99711. * Attach the input controls to a specific dom element to get the input from.
  99712. * @param element Defines the element the controls should be listened from
  99713. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99714. */
  99715. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99716. /** @hidden */
  99717. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  99718. /**
  99719. * Update the current camera state depending on the inputs that have been used this frame.
  99720. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99721. */
  99722. checkInputs(): void;
  99723. /**
  99724. * Detach the current controls from the specified dom element.
  99725. * @param element Defines the element to stop listening the inputs from
  99726. */
  99727. detachControl(element: Nullable<HTMLElement>): void;
  99728. /**
  99729. * Gets the class name of the current intput.
  99730. * @returns the class name
  99731. */
  99732. getClassName(): string;
  99733. /**
  99734. * Get the friendly name associated with the input class.
  99735. * @returns the input friendly name
  99736. */
  99737. getSimpleName(): string;
  99738. }
  99739. }
  99740. declare module BABYLON {
  99741. /**
  99742. * Listen to mouse events to control the camera.
  99743. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99744. */
  99745. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  99746. /**
  99747. * Defines the camera the input is attached to.
  99748. */
  99749. camera: FlyCamera;
  99750. /**
  99751. * Defines if touch is enabled. (Default is true.)
  99752. */
  99753. touchEnabled: boolean;
  99754. /**
  99755. * Defines the buttons associated with the input to handle camera rotation.
  99756. */
  99757. buttons: number[];
  99758. /**
  99759. * Assign buttons for Yaw control.
  99760. */
  99761. buttonsYaw: number[];
  99762. /**
  99763. * Assign buttons for Pitch control.
  99764. */
  99765. buttonsPitch: number[];
  99766. /**
  99767. * Assign buttons for Roll control.
  99768. */
  99769. buttonsRoll: number[];
  99770. /**
  99771. * Detect if any button is being pressed while mouse is moved.
  99772. * -1 = Mouse locked.
  99773. * 0 = Left button.
  99774. * 1 = Middle Button.
  99775. * 2 = Right Button.
  99776. */
  99777. activeButton: number;
  99778. /**
  99779. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  99780. * Higher values reduce its sensitivity.
  99781. */
  99782. angularSensibility: number;
  99783. private _mousemoveCallback;
  99784. private _observer;
  99785. private _rollObserver;
  99786. private previousPosition;
  99787. private noPreventDefault;
  99788. private element;
  99789. /**
  99790. * Listen to mouse events to control the camera.
  99791. * @param touchEnabled Define if touch is enabled. (Default is true.)
  99792. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99793. */
  99794. constructor(touchEnabled?: boolean);
  99795. /**
  99796. * Attach the mouse control to the HTML DOM element.
  99797. * @param element Defines the element that listens to the input events.
  99798. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  99799. */
  99800. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99801. /**
  99802. * Detach the current controls from the specified dom element.
  99803. * @param element Defines the element to stop listening the inputs from
  99804. */
  99805. detachControl(element: Nullable<HTMLElement>): void;
  99806. /**
  99807. * Gets the class name of the current input.
  99808. * @returns the class name.
  99809. */
  99810. getClassName(): string;
  99811. /**
  99812. * Get the friendly name associated with the input class.
  99813. * @returns the input's friendly name.
  99814. */
  99815. getSimpleName(): string;
  99816. private _pointerInput;
  99817. private _onMouseMove;
  99818. /**
  99819. * Rotate camera by mouse offset.
  99820. */
  99821. private rotateCamera;
  99822. }
  99823. }
  99824. declare module BABYLON {
  99825. /**
  99826. * Default Inputs manager for the FlyCamera.
  99827. * It groups all the default supported inputs for ease of use.
  99828. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99829. */
  99830. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  99831. /**
  99832. * Instantiates a new FlyCameraInputsManager.
  99833. * @param camera Defines the camera the inputs belong to.
  99834. */
  99835. constructor(camera: FlyCamera);
  99836. /**
  99837. * Add keyboard input support to the input manager.
  99838. * @returns the new FlyCameraKeyboardMoveInput().
  99839. */
  99840. addKeyboard(): FlyCameraInputsManager;
  99841. /**
  99842. * Add mouse input support to the input manager.
  99843. * @param touchEnabled Enable touch screen support.
  99844. * @returns the new FlyCameraMouseInput().
  99845. */
  99846. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  99847. }
  99848. }
  99849. declare module BABYLON {
  99850. /**
  99851. * This is a flying camera, designed for 3D movement and rotation in all directions,
  99852. * such as in a 3D Space Shooter or a Flight Simulator.
  99853. */
  99854. export class FlyCamera extends TargetCamera {
  99855. /**
  99856. * Define the collision ellipsoid of the camera.
  99857. * This is helpful for simulating a camera body, like a player's body.
  99858. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99859. */
  99860. ellipsoid: Vector3;
  99861. /**
  99862. * Define an offset for the position of the ellipsoid around the camera.
  99863. * This can be helpful if the camera is attached away from the player's body center,
  99864. * such as at its head.
  99865. */
  99866. ellipsoidOffset: Vector3;
  99867. /**
  99868. * Enable or disable collisions of the camera with the rest of the scene objects.
  99869. */
  99870. checkCollisions: boolean;
  99871. /**
  99872. * Enable or disable gravity on the camera.
  99873. */
  99874. applyGravity: boolean;
  99875. /**
  99876. * Define the current direction the camera is moving to.
  99877. */
  99878. cameraDirection: Vector3;
  99879. /**
  99880. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  99881. * This overrides and empties cameraRotation.
  99882. */
  99883. rotationQuaternion: Quaternion;
  99884. /**
  99885. * Track Roll to maintain the wanted Rolling when looking around.
  99886. */
  99887. _trackRoll: number;
  99888. /**
  99889. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  99890. */
  99891. rollCorrect: number;
  99892. /**
  99893. * Mimic a banked turn, Rolling the camera when Yawing.
  99894. * It's recommended to use rollCorrect = 10 for faster banking correction.
  99895. */
  99896. bankedTurn: boolean;
  99897. /**
  99898. * Limit in radians for how much Roll banking will add. (Default: 90°)
  99899. */
  99900. bankedTurnLimit: number;
  99901. /**
  99902. * Value of 0 disables the banked Roll.
  99903. * Value of 1 is equal to the Yaw angle in radians.
  99904. */
  99905. bankedTurnMultiplier: number;
  99906. /**
  99907. * The inputs manager loads all the input sources, such as keyboard and mouse.
  99908. */
  99909. inputs: FlyCameraInputsManager;
  99910. /**
  99911. * Gets the input sensibility for mouse input.
  99912. * Higher values reduce sensitivity.
  99913. */
  99914. /**
  99915. * Sets the input sensibility for a mouse input.
  99916. * Higher values reduce sensitivity.
  99917. */
  99918. angularSensibility: number;
  99919. /**
  99920. * Get the keys for camera movement forward.
  99921. */
  99922. /**
  99923. * Set the keys for camera movement forward.
  99924. */
  99925. keysForward: number[];
  99926. /**
  99927. * Get the keys for camera movement backward.
  99928. */
  99929. keysBackward: number[];
  99930. /**
  99931. * Get the keys for camera movement up.
  99932. */
  99933. /**
  99934. * Set the keys for camera movement up.
  99935. */
  99936. keysUp: number[];
  99937. /**
  99938. * Get the keys for camera movement down.
  99939. */
  99940. /**
  99941. * Set the keys for camera movement down.
  99942. */
  99943. keysDown: number[];
  99944. /**
  99945. * Get the keys for camera movement left.
  99946. */
  99947. /**
  99948. * Set the keys for camera movement left.
  99949. */
  99950. keysLeft: number[];
  99951. /**
  99952. * Set the keys for camera movement right.
  99953. */
  99954. /**
  99955. * Set the keys for camera movement right.
  99956. */
  99957. keysRight: number[];
  99958. /**
  99959. * Event raised when the camera collides with a mesh in the scene.
  99960. */
  99961. onCollide: (collidedMesh: AbstractMesh) => void;
  99962. private _collider;
  99963. private _needMoveForGravity;
  99964. private _oldPosition;
  99965. private _diffPosition;
  99966. private _newPosition;
  99967. /** @hidden */
  99968. _localDirection: Vector3;
  99969. /** @hidden */
  99970. _transformedDirection: Vector3;
  99971. /**
  99972. * Instantiates a FlyCamera.
  99973. * This is a flying camera, designed for 3D movement and rotation in all directions,
  99974. * such as in a 3D Space Shooter or a Flight Simulator.
  99975. * @param name Define the name of the camera in the scene.
  99976. * @param position Define the starting position of the camera in the scene.
  99977. * @param scene Define the scene the camera belongs to.
  99978. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  99979. */
  99980. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99981. /**
  99982. * Attach a control to the HTML DOM element.
  99983. * @param element Defines the element that listens to the input events.
  99984. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  99985. */
  99986. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99987. /**
  99988. * Detach a control from the HTML DOM element.
  99989. * The camera will stop reacting to that input.
  99990. * @param element Defines the element that listens to the input events.
  99991. */
  99992. detachControl(element: HTMLElement): void;
  99993. private _collisionMask;
  99994. /**
  99995. * Get the mask that the camera ignores in collision events.
  99996. */
  99997. /**
  99998. * Set the mask that the camera ignores in collision events.
  99999. */
  100000. collisionMask: number;
  100001. /** @hidden */
  100002. _collideWithWorld(displacement: Vector3): void;
  100003. /** @hidden */
  100004. private _onCollisionPositionChange;
  100005. /** @hidden */
  100006. _checkInputs(): void;
  100007. /** @hidden */
  100008. _decideIfNeedsToMove(): boolean;
  100009. /** @hidden */
  100010. _updatePosition(): void;
  100011. /**
  100012. * Restore the Roll to its target value at the rate specified.
  100013. * @param rate - Higher means slower restoring.
  100014. * @hidden
  100015. */
  100016. restoreRoll(rate: number): void;
  100017. /**
  100018. * Destroy the camera and release the current resources held by it.
  100019. */
  100020. dispose(): void;
  100021. /**
  100022. * Get the current object class name.
  100023. * @returns the class name.
  100024. */
  100025. getClassName(): string;
  100026. }
  100027. }
  100028. declare module BABYLON {
  100029. /**
  100030. * Listen to keyboard events to control the camera.
  100031. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100032. */
  100033. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  100034. /**
  100035. * Defines the camera the input is attached to.
  100036. */
  100037. camera: FlyCamera;
  100038. /**
  100039. * The list of keyboard keys used to control the forward move of the camera.
  100040. */
  100041. keysForward: number[];
  100042. /**
  100043. * The list of keyboard keys used to control the backward move of the camera.
  100044. */
  100045. keysBackward: number[];
  100046. /**
  100047. * The list of keyboard keys used to control the forward move of the camera.
  100048. */
  100049. keysUp: number[];
  100050. /**
  100051. * The list of keyboard keys used to control the backward move of the camera.
  100052. */
  100053. keysDown: number[];
  100054. /**
  100055. * The list of keyboard keys used to control the right strafe move of the camera.
  100056. */
  100057. keysRight: number[];
  100058. /**
  100059. * The list of keyboard keys used to control the left strafe move of the camera.
  100060. */
  100061. keysLeft: number[];
  100062. private _keys;
  100063. private _onCanvasBlurObserver;
  100064. private _onKeyboardObserver;
  100065. private _engine;
  100066. private _scene;
  100067. /**
  100068. * Attach the input controls to a specific dom element to get the input from.
  100069. * @param element Defines the element the controls should be listened from
  100070. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100071. */
  100072. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100073. /**
  100074. * Detach the current controls from the specified dom element.
  100075. * @param element Defines the element to stop listening the inputs from
  100076. */
  100077. detachControl(element: Nullable<HTMLElement>): void;
  100078. /**
  100079. * Gets the class name of the current intput.
  100080. * @returns the class name
  100081. */
  100082. getClassName(): string;
  100083. /** @hidden */
  100084. _onLostFocus(e: FocusEvent): void;
  100085. /**
  100086. * Get the friendly name associated with the input class.
  100087. * @returns the input friendly name
  100088. */
  100089. getSimpleName(): string;
  100090. /**
  100091. * Update the current camera state depending on the inputs that have been used this frame.
  100092. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100093. */
  100094. checkInputs(): void;
  100095. }
  100096. }
  100097. declare module BABYLON {
  100098. /**
  100099. * Manage the mouse wheel inputs to control a follow camera.
  100100. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100101. */
  100102. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  100103. /**
  100104. * Defines the camera the input is attached to.
  100105. */
  100106. camera: FollowCamera;
  100107. /**
  100108. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  100109. */
  100110. axisControlRadius: boolean;
  100111. /**
  100112. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  100113. */
  100114. axisControlHeight: boolean;
  100115. /**
  100116. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  100117. */
  100118. axisControlRotation: boolean;
  100119. /**
  100120. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  100121. * relation to mouseWheel events.
  100122. */
  100123. wheelPrecision: number;
  100124. /**
  100125. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  100126. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  100127. */
  100128. wheelDeltaPercentage: number;
  100129. private _wheel;
  100130. private _observer;
  100131. /**
  100132. * Attach the input controls to a specific dom element to get the input from.
  100133. * @param element Defines the element the controls should be listened from
  100134. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100135. */
  100136. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100137. /**
  100138. * Detach the current controls from the specified dom element.
  100139. * @param element Defines the element to stop listening the inputs from
  100140. */
  100141. detachControl(element: Nullable<HTMLElement>): void;
  100142. /**
  100143. * Gets the class name of the current intput.
  100144. * @returns the class name
  100145. */
  100146. getClassName(): string;
  100147. /**
  100148. * Get the friendly name associated with the input class.
  100149. * @returns the input friendly name
  100150. */
  100151. getSimpleName(): string;
  100152. }
  100153. }
  100154. declare module BABYLON {
  100155. /**
  100156. * Manage the pointers inputs to control an follow camera.
  100157. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100158. */
  100159. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  100160. /**
  100161. * Defines the camera the input is attached to.
  100162. */
  100163. camera: FollowCamera;
  100164. /**
  100165. * Gets the class name of the current input.
  100166. * @returns the class name
  100167. */
  100168. getClassName(): string;
  100169. /**
  100170. * Defines the pointer angular sensibility along the X axis or how fast is
  100171. * the camera rotating.
  100172. * A negative number will reverse the axis direction.
  100173. */
  100174. angularSensibilityX: number;
  100175. /**
  100176. * Defines the pointer angular sensibility along the Y axis or how fast is
  100177. * the camera rotating.
  100178. * A negative number will reverse the axis direction.
  100179. */
  100180. angularSensibilityY: number;
  100181. /**
  100182. * Defines the pointer pinch precision or how fast is the camera zooming.
  100183. * A negative number will reverse the axis direction.
  100184. */
  100185. pinchPrecision: number;
  100186. /**
  100187. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  100188. * from 0.
  100189. * It defines the percentage of current camera.radius to use as delta when
  100190. * pinch zoom is used.
  100191. */
  100192. pinchDeltaPercentage: number;
  100193. /**
  100194. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  100195. */
  100196. axisXControlRadius: boolean;
  100197. /**
  100198. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  100199. */
  100200. axisXControlHeight: boolean;
  100201. /**
  100202. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  100203. */
  100204. axisXControlRotation: boolean;
  100205. /**
  100206. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  100207. */
  100208. axisYControlRadius: boolean;
  100209. /**
  100210. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  100211. */
  100212. axisYControlHeight: boolean;
  100213. /**
  100214. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  100215. */
  100216. axisYControlRotation: boolean;
  100217. /**
  100218. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  100219. */
  100220. axisPinchControlRadius: boolean;
  100221. /**
  100222. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  100223. */
  100224. axisPinchControlHeight: boolean;
  100225. /**
  100226. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  100227. */
  100228. axisPinchControlRotation: boolean;
  100229. /**
  100230. * Log error messages if basic misconfiguration has occurred.
  100231. */
  100232. warningEnable: boolean;
  100233. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  100234. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  100235. private _warningCounter;
  100236. private _warning;
  100237. }
  100238. }
  100239. declare module BABYLON {
  100240. /**
  100241. * Default Inputs manager for the FollowCamera.
  100242. * It groups all the default supported inputs for ease of use.
  100243. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100244. */
  100245. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  100246. /**
  100247. * Instantiates a new FollowCameraInputsManager.
  100248. * @param camera Defines the camera the inputs belong to
  100249. */
  100250. constructor(camera: FollowCamera);
  100251. /**
  100252. * Add keyboard input support to the input manager.
  100253. * @returns the current input manager
  100254. */
  100255. addKeyboard(): FollowCameraInputsManager;
  100256. /**
  100257. * Add mouse wheel input support to the input manager.
  100258. * @returns the current input manager
  100259. */
  100260. addMouseWheel(): FollowCameraInputsManager;
  100261. /**
  100262. * Add pointers input support to the input manager.
  100263. * @returns the current input manager
  100264. */
  100265. addPointers(): FollowCameraInputsManager;
  100266. /**
  100267. * Add orientation input support to the input manager.
  100268. * @returns the current input manager
  100269. */
  100270. addVRDeviceOrientation(): FollowCameraInputsManager;
  100271. }
  100272. }
  100273. declare module BABYLON {
  100274. /**
  100275. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  100276. * an arc rotate version arcFollowCamera are available.
  100277. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  100278. */
  100279. export class FollowCamera extends TargetCamera {
  100280. /**
  100281. * Distance the follow camera should follow an object at
  100282. */
  100283. radius: number;
  100284. /**
  100285. * Minimum allowed distance of the camera to the axis of rotation
  100286. * (The camera can not get closer).
  100287. * This can help limiting how the Camera is able to move in the scene.
  100288. */
  100289. lowerRadiusLimit: Nullable<number>;
  100290. /**
  100291. * Maximum allowed distance of the camera to the axis of rotation
  100292. * (The camera can not get further).
  100293. * This can help limiting how the Camera is able to move in the scene.
  100294. */
  100295. upperRadiusLimit: Nullable<number>;
  100296. /**
  100297. * Define a rotation offset between the camera and the object it follows
  100298. */
  100299. rotationOffset: number;
  100300. /**
  100301. * Minimum allowed angle to camera position relative to target object.
  100302. * This can help limiting how the Camera is able to move in the scene.
  100303. */
  100304. lowerRotationOffsetLimit: Nullable<number>;
  100305. /**
  100306. * Maximum allowed angle to camera position relative to target object.
  100307. * This can help limiting how the Camera is able to move in the scene.
  100308. */
  100309. upperRotationOffsetLimit: Nullable<number>;
  100310. /**
  100311. * Define a height offset between the camera and the object it follows.
  100312. * It can help following an object from the top (like a car chaing a plane)
  100313. */
  100314. heightOffset: number;
  100315. /**
  100316. * Minimum allowed height of camera position relative to target object.
  100317. * This can help limiting how the Camera is able to move in the scene.
  100318. */
  100319. lowerHeightOffsetLimit: Nullable<number>;
  100320. /**
  100321. * Maximum allowed height of camera position relative to target object.
  100322. * This can help limiting how the Camera is able to move in the scene.
  100323. */
  100324. upperHeightOffsetLimit: Nullable<number>;
  100325. /**
  100326. * Define how fast the camera can accelerate to follow it s target.
  100327. */
  100328. cameraAcceleration: number;
  100329. /**
  100330. * Define the speed limit of the camera following an object.
  100331. */
  100332. maxCameraSpeed: number;
  100333. /**
  100334. * Define the target of the camera.
  100335. */
  100336. lockedTarget: Nullable<AbstractMesh>;
  100337. /**
  100338. * Defines the input associated with the camera.
  100339. */
  100340. inputs: FollowCameraInputsManager;
  100341. /**
  100342. * Instantiates the follow camera.
  100343. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  100344. * @param name Define the name of the camera in the scene
  100345. * @param position Define the position of the camera
  100346. * @param scene Define the scene the camera belong to
  100347. * @param lockedTarget Define the target of the camera
  100348. */
  100349. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  100350. private _follow;
  100351. /**
  100352. * Attached controls to the current camera.
  100353. * @param element Defines the element the controls should be listened from
  100354. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100355. */
  100356. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100357. /**
  100358. * Detach the current controls from the camera.
  100359. * The camera will stop reacting to inputs.
  100360. * @param element Defines the element to stop listening the inputs from
  100361. */
  100362. detachControl(element: HTMLElement): void;
  100363. /** @hidden */
  100364. _checkInputs(): void;
  100365. private _checkLimits;
  100366. /**
  100367. * Gets the camera class name.
  100368. * @returns the class name
  100369. */
  100370. getClassName(): string;
  100371. }
  100372. /**
  100373. * Arc Rotate version of the follow camera.
  100374. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  100375. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  100376. */
  100377. export class ArcFollowCamera extends TargetCamera {
  100378. /** The longitudinal angle of the camera */
  100379. alpha: number;
  100380. /** The latitudinal angle of the camera */
  100381. beta: number;
  100382. /** The radius of the camera from its target */
  100383. radius: number;
  100384. /** Define the camera target (the messh it should follow) */
  100385. target: Nullable<AbstractMesh>;
  100386. private _cartesianCoordinates;
  100387. /**
  100388. * Instantiates a new ArcFollowCamera
  100389. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  100390. * @param name Define the name of the camera
  100391. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  100392. * @param beta Define the rotation angle of the camera around the elevation axis
  100393. * @param radius Define the radius of the camera from its target point
  100394. * @param target Define the target of the camera
  100395. * @param scene Define the scene the camera belongs to
  100396. */
  100397. constructor(name: string,
  100398. /** The longitudinal angle of the camera */
  100399. alpha: number,
  100400. /** The latitudinal angle of the camera */
  100401. beta: number,
  100402. /** The radius of the camera from its target */
  100403. radius: number,
  100404. /** Define the camera target (the messh it should follow) */
  100405. target: Nullable<AbstractMesh>, scene: Scene);
  100406. private _follow;
  100407. /** @hidden */
  100408. _checkInputs(): void;
  100409. /**
  100410. * Returns the class name of the object.
  100411. * It is mostly used internally for serialization purposes.
  100412. */
  100413. getClassName(): string;
  100414. }
  100415. }
  100416. declare module BABYLON {
  100417. /**
  100418. * Manage the keyboard inputs to control the movement of a follow camera.
  100419. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100420. */
  100421. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  100422. /**
  100423. * Defines the camera the input is attached to.
  100424. */
  100425. camera: FollowCamera;
  100426. /**
  100427. * Defines the list of key codes associated with the up action (increase heightOffset)
  100428. */
  100429. keysHeightOffsetIncr: number[];
  100430. /**
  100431. * Defines the list of key codes associated with the down action (decrease heightOffset)
  100432. */
  100433. keysHeightOffsetDecr: number[];
  100434. /**
  100435. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  100436. */
  100437. keysHeightOffsetModifierAlt: boolean;
  100438. /**
  100439. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  100440. */
  100441. keysHeightOffsetModifierCtrl: boolean;
  100442. /**
  100443. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  100444. */
  100445. keysHeightOffsetModifierShift: boolean;
  100446. /**
  100447. * Defines the list of key codes associated with the left action (increase rotationOffset)
  100448. */
  100449. keysRotationOffsetIncr: number[];
  100450. /**
  100451. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  100452. */
  100453. keysRotationOffsetDecr: number[];
  100454. /**
  100455. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  100456. */
  100457. keysRotationOffsetModifierAlt: boolean;
  100458. /**
  100459. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  100460. */
  100461. keysRotationOffsetModifierCtrl: boolean;
  100462. /**
  100463. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  100464. */
  100465. keysRotationOffsetModifierShift: boolean;
  100466. /**
  100467. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  100468. */
  100469. keysRadiusIncr: number[];
  100470. /**
  100471. * Defines the list of key codes associated with the zoom-out action (increase radius)
  100472. */
  100473. keysRadiusDecr: number[];
  100474. /**
  100475. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  100476. */
  100477. keysRadiusModifierAlt: boolean;
  100478. /**
  100479. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  100480. */
  100481. keysRadiusModifierCtrl: boolean;
  100482. /**
  100483. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  100484. */
  100485. keysRadiusModifierShift: boolean;
  100486. /**
  100487. * Defines the rate of change of heightOffset.
  100488. */
  100489. heightSensibility: number;
  100490. /**
  100491. * Defines the rate of change of rotationOffset.
  100492. */
  100493. rotationSensibility: number;
  100494. /**
  100495. * Defines the rate of change of radius.
  100496. */
  100497. radiusSensibility: number;
  100498. private _keys;
  100499. private _ctrlPressed;
  100500. private _altPressed;
  100501. private _shiftPressed;
  100502. private _onCanvasBlurObserver;
  100503. private _onKeyboardObserver;
  100504. private _engine;
  100505. private _scene;
  100506. /**
  100507. * Attach the input controls to a specific dom element to get the input from.
  100508. * @param element Defines the element the controls should be listened from
  100509. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100510. */
  100511. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100512. /**
  100513. * Detach the current controls from the specified dom element.
  100514. * @param element Defines the element to stop listening the inputs from
  100515. */
  100516. detachControl(element: Nullable<HTMLElement>): void;
  100517. /**
  100518. * Update the current camera state depending on the inputs that have been used this frame.
  100519. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100520. */
  100521. checkInputs(): void;
  100522. /**
  100523. * Gets the class name of the current input.
  100524. * @returns the class name
  100525. */
  100526. getClassName(): string;
  100527. /**
  100528. * Get the friendly name associated with the input class.
  100529. * @returns the input friendly name
  100530. */
  100531. getSimpleName(): string;
  100532. /**
  100533. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  100534. * allow modification of the heightOffset value.
  100535. */
  100536. private _modifierHeightOffset;
  100537. /**
  100538. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  100539. * allow modification of the rotationOffset value.
  100540. */
  100541. private _modifierRotationOffset;
  100542. /**
  100543. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  100544. * allow modification of the radius value.
  100545. */
  100546. private _modifierRadius;
  100547. }
  100548. }
  100549. declare module BABYLON {
  100550. interface FreeCameraInputsManager {
  100551. /**
  100552. * @hidden
  100553. */
  100554. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  100555. /**
  100556. * Add orientation input support to the input manager.
  100557. * @returns the current input manager
  100558. */
  100559. addDeviceOrientation(): FreeCameraInputsManager;
  100560. }
  100561. /**
  100562. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  100563. * Screen rotation is taken into account.
  100564. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100565. */
  100566. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  100567. private _camera;
  100568. private _screenOrientationAngle;
  100569. private _constantTranform;
  100570. private _screenQuaternion;
  100571. private _alpha;
  100572. private _beta;
  100573. private _gamma;
  100574. /**
  100575. * Can be used to detect if a device orientation sensor is availible on a device
  100576. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  100577. * @returns a promise that will resolve on orientation change
  100578. */
  100579. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  100580. /**
  100581. * @hidden
  100582. */
  100583. _onDeviceOrientationChangedObservable: Observable<void>;
  100584. /**
  100585. * Instantiates a new input
  100586. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100587. */
  100588. constructor();
  100589. /**
  100590. * Define the camera controlled by the input.
  100591. */
  100592. camera: FreeCamera;
  100593. /**
  100594. * Attach the input controls to a specific dom element to get the input from.
  100595. * @param element Defines the element the controls should be listened from
  100596. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100597. */
  100598. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100599. private _orientationChanged;
  100600. private _deviceOrientation;
  100601. /**
  100602. * Detach the current controls from the specified dom element.
  100603. * @param element Defines the element to stop listening the inputs from
  100604. */
  100605. detachControl(element: Nullable<HTMLElement>): void;
  100606. /**
  100607. * Update the current camera state depending on the inputs that have been used this frame.
  100608. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100609. */
  100610. checkInputs(): void;
  100611. /**
  100612. * Gets the class name of the current intput.
  100613. * @returns the class name
  100614. */
  100615. getClassName(): string;
  100616. /**
  100617. * Get the friendly name associated with the input class.
  100618. * @returns the input friendly name
  100619. */
  100620. getSimpleName(): string;
  100621. }
  100622. }
  100623. declare module BABYLON {
  100624. /**
  100625. * Manage the gamepad inputs to control a free camera.
  100626. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100627. */
  100628. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  100629. /**
  100630. * Define the camera the input is attached to.
  100631. */
  100632. camera: FreeCamera;
  100633. /**
  100634. * Define the Gamepad controlling the input
  100635. */
  100636. gamepad: Nullable<Gamepad>;
  100637. /**
  100638. * Defines the gamepad rotation sensiblity.
  100639. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  100640. */
  100641. gamepadAngularSensibility: number;
  100642. /**
  100643. * Defines the gamepad move sensiblity.
  100644. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  100645. */
  100646. gamepadMoveSensibility: number;
  100647. private _onGamepadConnectedObserver;
  100648. private _onGamepadDisconnectedObserver;
  100649. private _cameraTransform;
  100650. private _deltaTransform;
  100651. private _vector3;
  100652. private _vector2;
  100653. /**
  100654. * Attach the input controls to a specific dom element to get the input from.
  100655. * @param element Defines the element the controls should be listened from
  100656. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100657. */
  100658. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100659. /**
  100660. * Detach the current controls from the specified dom element.
  100661. * @param element Defines the element to stop listening the inputs from
  100662. */
  100663. detachControl(element: Nullable<HTMLElement>): void;
  100664. /**
  100665. * Update the current camera state depending on the inputs that have been used this frame.
  100666. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100667. */
  100668. checkInputs(): void;
  100669. /**
  100670. * Gets the class name of the current intput.
  100671. * @returns the class name
  100672. */
  100673. getClassName(): string;
  100674. /**
  100675. * Get the friendly name associated with the input class.
  100676. * @returns the input friendly name
  100677. */
  100678. getSimpleName(): string;
  100679. }
  100680. }
  100681. declare module BABYLON {
  100682. /**
  100683. * Defines the potential axis of a Joystick
  100684. */
  100685. export enum JoystickAxis {
  100686. /** X axis */
  100687. X = 0,
  100688. /** Y axis */
  100689. Y = 1,
  100690. /** Z axis */
  100691. Z = 2
  100692. }
  100693. /**
  100694. * Class used to define virtual joystick (used in touch mode)
  100695. */
  100696. export class VirtualJoystick {
  100697. /**
  100698. * Gets or sets a boolean indicating that left and right values must be inverted
  100699. */
  100700. reverseLeftRight: boolean;
  100701. /**
  100702. * Gets or sets a boolean indicating that up and down values must be inverted
  100703. */
  100704. reverseUpDown: boolean;
  100705. /**
  100706. * Gets the offset value for the position (ie. the change of the position value)
  100707. */
  100708. deltaPosition: Vector3;
  100709. /**
  100710. * Gets a boolean indicating if the virtual joystick was pressed
  100711. */
  100712. pressed: boolean;
  100713. /**
  100714. * Canvas the virtual joystick will render onto, default z-index of this is 5
  100715. */
  100716. static Canvas: Nullable<HTMLCanvasElement>;
  100717. private static _globalJoystickIndex;
  100718. private static vjCanvasContext;
  100719. private static vjCanvasWidth;
  100720. private static vjCanvasHeight;
  100721. private static halfWidth;
  100722. private _action;
  100723. private _axisTargetedByLeftAndRight;
  100724. private _axisTargetedByUpAndDown;
  100725. private _joystickSensibility;
  100726. private _inversedSensibility;
  100727. private _joystickPointerID;
  100728. private _joystickColor;
  100729. private _joystickPointerPos;
  100730. private _joystickPreviousPointerPos;
  100731. private _joystickPointerStartPos;
  100732. private _deltaJoystickVector;
  100733. private _leftJoystick;
  100734. private _touches;
  100735. private _onPointerDownHandlerRef;
  100736. private _onPointerMoveHandlerRef;
  100737. private _onPointerUpHandlerRef;
  100738. private _onResize;
  100739. /**
  100740. * Creates a new virtual joystick
  100741. * @param leftJoystick defines that the joystick is for left hand (false by default)
  100742. */
  100743. constructor(leftJoystick?: boolean);
  100744. /**
  100745. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  100746. * @param newJoystickSensibility defines the new sensibility
  100747. */
  100748. setJoystickSensibility(newJoystickSensibility: number): void;
  100749. private _onPointerDown;
  100750. private _onPointerMove;
  100751. private _onPointerUp;
  100752. /**
  100753. * Change the color of the virtual joystick
  100754. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  100755. */
  100756. setJoystickColor(newColor: string): void;
  100757. /**
  100758. * Defines a callback to call when the joystick is touched
  100759. * @param action defines the callback
  100760. */
  100761. setActionOnTouch(action: () => any): void;
  100762. /**
  100763. * Defines which axis you'd like to control for left & right
  100764. * @param axis defines the axis to use
  100765. */
  100766. setAxisForLeftRight(axis: JoystickAxis): void;
  100767. /**
  100768. * Defines which axis you'd like to control for up & down
  100769. * @param axis defines the axis to use
  100770. */
  100771. setAxisForUpDown(axis: JoystickAxis): void;
  100772. private _drawVirtualJoystick;
  100773. /**
  100774. * Release internal HTML canvas
  100775. */
  100776. releaseCanvas(): void;
  100777. }
  100778. }
  100779. declare module BABYLON {
  100780. interface FreeCameraInputsManager {
  100781. /**
  100782. * Add virtual joystick input support to the input manager.
  100783. * @returns the current input manager
  100784. */
  100785. addVirtualJoystick(): FreeCameraInputsManager;
  100786. }
  100787. /**
  100788. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  100789. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100790. */
  100791. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  100792. /**
  100793. * Defines the camera the input is attached to.
  100794. */
  100795. camera: FreeCamera;
  100796. private _leftjoystick;
  100797. private _rightjoystick;
  100798. /**
  100799. * Gets the left stick of the virtual joystick.
  100800. * @returns The virtual Joystick
  100801. */
  100802. getLeftJoystick(): VirtualJoystick;
  100803. /**
  100804. * Gets the right stick of the virtual joystick.
  100805. * @returns The virtual Joystick
  100806. */
  100807. getRightJoystick(): VirtualJoystick;
  100808. /**
  100809. * Update the current camera state depending on the inputs that have been used this frame.
  100810. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100811. */
  100812. checkInputs(): void;
  100813. /**
  100814. * Attach the input controls to a specific dom element to get the input from.
  100815. * @param element Defines the element the controls should be listened from
  100816. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100817. */
  100818. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100819. /**
  100820. * Detach the current controls from the specified dom element.
  100821. * @param element Defines the element to stop listening the inputs from
  100822. */
  100823. detachControl(element: Nullable<HTMLElement>): void;
  100824. /**
  100825. * Gets the class name of the current intput.
  100826. * @returns the class name
  100827. */
  100828. getClassName(): string;
  100829. /**
  100830. * Get the friendly name associated with the input class.
  100831. * @returns the input friendly name
  100832. */
  100833. getSimpleName(): string;
  100834. }
  100835. }
  100836. declare module BABYLON {
  100837. /**
  100838. * This represents a FPS type of camera controlled by touch.
  100839. * This is like a universal camera minus the Gamepad controls.
  100840. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100841. */
  100842. export class TouchCamera extends FreeCamera {
  100843. /**
  100844. * Defines the touch sensibility for rotation.
  100845. * The higher the faster.
  100846. */
  100847. touchAngularSensibility: number;
  100848. /**
  100849. * Defines the touch sensibility for move.
  100850. * The higher the faster.
  100851. */
  100852. touchMoveSensibility: number;
  100853. /**
  100854. * Instantiates a new touch camera.
  100855. * This represents a FPS type of camera controlled by touch.
  100856. * This is like a universal camera minus the Gamepad controls.
  100857. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100858. * @param name Define the name of the camera in the scene
  100859. * @param position Define the start position of the camera in the scene
  100860. * @param scene Define the scene the camera belongs to
  100861. */
  100862. constructor(name: string, position: Vector3, scene: Scene);
  100863. /**
  100864. * Gets the current object class name.
  100865. * @return the class name
  100866. */
  100867. getClassName(): string;
  100868. /** @hidden */
  100869. _setupInputs(): void;
  100870. }
  100871. }
  100872. declare module BABYLON {
  100873. /**
  100874. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  100875. * being tilted forward or back and left or right.
  100876. */
  100877. export class DeviceOrientationCamera extends FreeCamera {
  100878. private _initialQuaternion;
  100879. private _quaternionCache;
  100880. private _tmpDragQuaternion;
  100881. /**
  100882. * Creates a new device orientation camera
  100883. * @param name The name of the camera
  100884. * @param position The start position camera
  100885. * @param scene The scene the camera belongs to
  100886. */
  100887. constructor(name: string, position: Vector3, scene: Scene);
  100888. /**
  100889. * @hidden
  100890. * Disabled pointer input on first orientation sensor update (Default: true)
  100891. */
  100892. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  100893. private _dragFactor;
  100894. /**
  100895. * Enabled turning on the y axis when the orientation sensor is active
  100896. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  100897. */
  100898. enableHorizontalDragging(dragFactor?: number): void;
  100899. /**
  100900. * Gets the current instance class name ("DeviceOrientationCamera").
  100901. * This helps avoiding instanceof at run time.
  100902. * @returns the class name
  100903. */
  100904. getClassName(): string;
  100905. /**
  100906. * @hidden
  100907. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  100908. */
  100909. _checkInputs(): void;
  100910. /**
  100911. * Reset the camera to its default orientation on the specified axis only.
  100912. * @param axis The axis to reset
  100913. */
  100914. resetToCurrentRotation(axis?: Axis): void;
  100915. }
  100916. }
  100917. declare module BABYLON {
  100918. /**
  100919. * Defines supported buttons for XBox360 compatible gamepads
  100920. */
  100921. export enum Xbox360Button {
  100922. /** A */
  100923. A = 0,
  100924. /** B */
  100925. B = 1,
  100926. /** X */
  100927. X = 2,
  100928. /** Y */
  100929. Y = 3,
  100930. /** Start */
  100931. Start = 4,
  100932. /** Back */
  100933. Back = 5,
  100934. /** Left button */
  100935. LB = 6,
  100936. /** Right button */
  100937. RB = 7,
  100938. /** Left stick */
  100939. LeftStick = 8,
  100940. /** Right stick */
  100941. RightStick = 9
  100942. }
  100943. /** Defines values for XBox360 DPad */
  100944. export enum Xbox360Dpad {
  100945. /** Up */
  100946. Up = 0,
  100947. /** Down */
  100948. Down = 1,
  100949. /** Left */
  100950. Left = 2,
  100951. /** Right */
  100952. Right = 3
  100953. }
  100954. /**
  100955. * Defines a XBox360 gamepad
  100956. */
  100957. export class Xbox360Pad extends Gamepad {
  100958. private _leftTrigger;
  100959. private _rightTrigger;
  100960. private _onlefttriggerchanged;
  100961. private _onrighttriggerchanged;
  100962. private _onbuttondown;
  100963. private _onbuttonup;
  100964. private _ondpaddown;
  100965. private _ondpadup;
  100966. /** Observable raised when a button is pressed */
  100967. onButtonDownObservable: Observable<Xbox360Button>;
  100968. /** Observable raised when a button is released */
  100969. onButtonUpObservable: Observable<Xbox360Button>;
  100970. /** Observable raised when a pad is pressed */
  100971. onPadDownObservable: Observable<Xbox360Dpad>;
  100972. /** Observable raised when a pad is released */
  100973. onPadUpObservable: Observable<Xbox360Dpad>;
  100974. private _buttonA;
  100975. private _buttonB;
  100976. private _buttonX;
  100977. private _buttonY;
  100978. private _buttonBack;
  100979. private _buttonStart;
  100980. private _buttonLB;
  100981. private _buttonRB;
  100982. private _buttonLeftStick;
  100983. private _buttonRightStick;
  100984. private _dPadUp;
  100985. private _dPadDown;
  100986. private _dPadLeft;
  100987. private _dPadRight;
  100988. private _isXboxOnePad;
  100989. /**
  100990. * Creates a new XBox360 gamepad object
  100991. * @param id defines the id of this gamepad
  100992. * @param index defines its index
  100993. * @param gamepad defines the internal HTML gamepad object
  100994. * @param xboxOne defines if it is a XBox One gamepad
  100995. */
  100996. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  100997. /**
  100998. * Defines the callback to call when left trigger is pressed
  100999. * @param callback defines the callback to use
  101000. */
  101001. onlefttriggerchanged(callback: (value: number) => void): void;
  101002. /**
  101003. * Defines the callback to call when right trigger is pressed
  101004. * @param callback defines the callback to use
  101005. */
  101006. onrighttriggerchanged(callback: (value: number) => void): void;
  101007. /**
  101008. * Gets the left trigger value
  101009. */
  101010. /**
  101011. * Sets the left trigger value
  101012. */
  101013. leftTrigger: number;
  101014. /**
  101015. * Gets the right trigger value
  101016. */
  101017. /**
  101018. * Sets the right trigger value
  101019. */
  101020. rightTrigger: number;
  101021. /**
  101022. * Defines the callback to call when a button is pressed
  101023. * @param callback defines the callback to use
  101024. */
  101025. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  101026. /**
  101027. * Defines the callback to call when a button is released
  101028. * @param callback defines the callback to use
  101029. */
  101030. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  101031. /**
  101032. * Defines the callback to call when a pad is pressed
  101033. * @param callback defines the callback to use
  101034. */
  101035. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  101036. /**
  101037. * Defines the callback to call when a pad is released
  101038. * @param callback defines the callback to use
  101039. */
  101040. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  101041. private _setButtonValue;
  101042. private _setDPadValue;
  101043. /**
  101044. * Gets the value of the `A` button
  101045. */
  101046. /**
  101047. * Sets the value of the `A` button
  101048. */
  101049. buttonA: number;
  101050. /**
  101051. * Gets the value of the `B` button
  101052. */
  101053. /**
  101054. * Sets the value of the `B` button
  101055. */
  101056. buttonB: number;
  101057. /**
  101058. * Gets the value of the `X` button
  101059. */
  101060. /**
  101061. * Sets the value of the `X` button
  101062. */
  101063. buttonX: number;
  101064. /**
  101065. * Gets the value of the `Y` button
  101066. */
  101067. /**
  101068. * Sets the value of the `Y` button
  101069. */
  101070. buttonY: number;
  101071. /**
  101072. * Gets the value of the `Start` button
  101073. */
  101074. /**
  101075. * Sets the value of the `Start` button
  101076. */
  101077. buttonStart: number;
  101078. /**
  101079. * Gets the value of the `Back` button
  101080. */
  101081. /**
  101082. * Sets the value of the `Back` button
  101083. */
  101084. buttonBack: number;
  101085. /**
  101086. * Gets the value of the `Left` button
  101087. */
  101088. /**
  101089. * Sets the value of the `Left` button
  101090. */
  101091. buttonLB: number;
  101092. /**
  101093. * Gets the value of the `Right` button
  101094. */
  101095. /**
  101096. * Sets the value of the `Right` button
  101097. */
  101098. buttonRB: number;
  101099. /**
  101100. * Gets the value of the Left joystick
  101101. */
  101102. /**
  101103. * Sets the value of the Left joystick
  101104. */
  101105. buttonLeftStick: number;
  101106. /**
  101107. * Gets the value of the Right joystick
  101108. */
  101109. /**
  101110. * Sets the value of the Right joystick
  101111. */
  101112. buttonRightStick: number;
  101113. /**
  101114. * Gets the value of D-pad up
  101115. */
  101116. /**
  101117. * Sets the value of D-pad up
  101118. */
  101119. dPadUp: number;
  101120. /**
  101121. * Gets the value of D-pad down
  101122. */
  101123. /**
  101124. * Sets the value of D-pad down
  101125. */
  101126. dPadDown: number;
  101127. /**
  101128. * Gets the value of D-pad left
  101129. */
  101130. /**
  101131. * Sets the value of D-pad left
  101132. */
  101133. dPadLeft: number;
  101134. /**
  101135. * Gets the value of D-pad right
  101136. */
  101137. /**
  101138. * Sets the value of D-pad right
  101139. */
  101140. dPadRight: number;
  101141. /**
  101142. * Force the gamepad to synchronize with device values
  101143. */
  101144. update(): void;
  101145. /**
  101146. * Disposes the gamepad
  101147. */
  101148. dispose(): void;
  101149. }
  101150. }
  101151. declare module BABYLON {
  101152. /**
  101153. * Manager for handling gamepads
  101154. */
  101155. export class GamepadManager {
  101156. private _scene?;
  101157. private _babylonGamepads;
  101158. private _oneGamepadConnected;
  101159. /** @hidden */
  101160. _isMonitoring: boolean;
  101161. private _gamepadEventSupported;
  101162. private _gamepadSupport;
  101163. /**
  101164. * observable to be triggered when the gamepad controller has been connected
  101165. */
  101166. onGamepadConnectedObservable: Observable<Gamepad>;
  101167. /**
  101168. * observable to be triggered when the gamepad controller has been disconnected
  101169. */
  101170. onGamepadDisconnectedObservable: Observable<Gamepad>;
  101171. private _onGamepadConnectedEvent;
  101172. private _onGamepadDisconnectedEvent;
  101173. /**
  101174. * Initializes the gamepad manager
  101175. * @param _scene BabylonJS scene
  101176. */
  101177. constructor(_scene?: Scene | undefined);
  101178. /**
  101179. * The gamepads in the game pad manager
  101180. */
  101181. readonly gamepads: Gamepad[];
  101182. /**
  101183. * Get the gamepad controllers based on type
  101184. * @param type The type of gamepad controller
  101185. * @returns Nullable gamepad
  101186. */
  101187. getGamepadByType(type?: number): Nullable<Gamepad>;
  101188. /**
  101189. * Disposes the gamepad manager
  101190. */
  101191. dispose(): void;
  101192. private _addNewGamepad;
  101193. private _startMonitoringGamepads;
  101194. private _stopMonitoringGamepads;
  101195. /** @hidden */
  101196. _checkGamepadsStatus(): void;
  101197. private _updateGamepadObjects;
  101198. }
  101199. }
  101200. declare module BABYLON {
  101201. interface Scene {
  101202. /** @hidden */
  101203. _gamepadManager: Nullable<GamepadManager>;
  101204. /**
  101205. * Gets the gamepad manager associated with the scene
  101206. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  101207. */
  101208. gamepadManager: GamepadManager;
  101209. }
  101210. /**
  101211. * Interface representing a free camera inputs manager
  101212. */
  101213. interface FreeCameraInputsManager {
  101214. /**
  101215. * Adds gamepad input support to the FreeCameraInputsManager.
  101216. * @returns the FreeCameraInputsManager
  101217. */
  101218. addGamepad(): FreeCameraInputsManager;
  101219. }
  101220. /**
  101221. * Interface representing an arc rotate camera inputs manager
  101222. */
  101223. interface ArcRotateCameraInputsManager {
  101224. /**
  101225. * Adds gamepad input support to the ArcRotateCamera InputManager.
  101226. * @returns the camera inputs manager
  101227. */
  101228. addGamepad(): ArcRotateCameraInputsManager;
  101229. }
  101230. /**
  101231. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  101232. */
  101233. export class GamepadSystemSceneComponent implements ISceneComponent {
  101234. /**
  101235. * The component name helpfull to identify the component in the list of scene components.
  101236. */
  101237. readonly name: string;
  101238. /**
  101239. * The scene the component belongs to.
  101240. */
  101241. scene: Scene;
  101242. /**
  101243. * Creates a new instance of the component for the given scene
  101244. * @param scene Defines the scene to register the component in
  101245. */
  101246. constructor(scene: Scene);
  101247. /**
  101248. * Registers the component in a given scene
  101249. */
  101250. register(): void;
  101251. /**
  101252. * Rebuilds the elements related to this component in case of
  101253. * context lost for instance.
  101254. */
  101255. rebuild(): void;
  101256. /**
  101257. * Disposes the component and the associated ressources
  101258. */
  101259. dispose(): void;
  101260. private _beforeCameraUpdate;
  101261. }
  101262. }
  101263. declare module BABYLON {
  101264. /**
  101265. * 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,
  101266. * which still works and will still be found in many Playgrounds.
  101267. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101268. */
  101269. export class UniversalCamera extends TouchCamera {
  101270. /**
  101271. * Defines the gamepad rotation sensiblity.
  101272. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  101273. */
  101274. gamepadAngularSensibility: number;
  101275. /**
  101276. * Defines the gamepad move sensiblity.
  101277. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  101278. */
  101279. gamepadMoveSensibility: number;
  101280. /**
  101281. * 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,
  101282. * which still works and will still be found in many Playgrounds.
  101283. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101284. * @param name Define the name of the camera in the scene
  101285. * @param position Define the start position of the camera in the scene
  101286. * @param scene Define the scene the camera belongs to
  101287. */
  101288. constructor(name: string, position: Vector3, scene: Scene);
  101289. /**
  101290. * Gets the current object class name.
  101291. * @return the class name
  101292. */
  101293. getClassName(): string;
  101294. }
  101295. }
  101296. declare module BABYLON {
  101297. /**
  101298. * This represents a FPS type of camera. This is only here for back compat purpose.
  101299. * Please use the UniversalCamera instead as both are identical.
  101300. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101301. */
  101302. export class GamepadCamera extends UniversalCamera {
  101303. /**
  101304. * Instantiates a new Gamepad Camera
  101305. * This represents a FPS type of camera. This is only here for back compat purpose.
  101306. * Please use the UniversalCamera instead as both are identical.
  101307. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101308. * @param name Define the name of the camera in the scene
  101309. * @param position Define the start position of the camera in the scene
  101310. * @param scene Define the scene the camera belongs to
  101311. */
  101312. constructor(name: string, position: Vector3, scene: Scene);
  101313. /**
  101314. * Gets the current object class name.
  101315. * @return the class name
  101316. */
  101317. getClassName(): string;
  101318. }
  101319. }
  101320. declare module BABYLON {
  101321. /** @hidden */
  101322. export var passPixelShader: {
  101323. name: string;
  101324. shader: string;
  101325. };
  101326. }
  101327. declare module BABYLON {
  101328. /** @hidden */
  101329. export var passCubePixelShader: {
  101330. name: string;
  101331. shader: string;
  101332. };
  101333. }
  101334. declare module BABYLON {
  101335. /**
  101336. * PassPostProcess which produces an output the same as it's input
  101337. */
  101338. export class PassPostProcess extends PostProcess {
  101339. /**
  101340. * Creates the PassPostProcess
  101341. * @param name The name of the effect.
  101342. * @param options The required width/height ratio to downsize to before computing the render pass.
  101343. * @param camera The camera to apply the render pass to.
  101344. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101345. * @param engine The engine which the post process will be applied. (default: current engine)
  101346. * @param reusable If the post process can be reused on the same frame. (default: false)
  101347. * @param textureType The type of texture to be used when performing the post processing.
  101348. * @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)
  101349. */
  101350. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  101351. }
  101352. /**
  101353. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  101354. */
  101355. export class PassCubePostProcess extends PostProcess {
  101356. private _face;
  101357. /**
  101358. * Gets or sets the cube face to display.
  101359. * * 0 is +X
  101360. * * 1 is -X
  101361. * * 2 is +Y
  101362. * * 3 is -Y
  101363. * * 4 is +Z
  101364. * * 5 is -Z
  101365. */
  101366. face: number;
  101367. /**
  101368. * Creates the PassCubePostProcess
  101369. * @param name The name of the effect.
  101370. * @param options The required width/height ratio to downsize to before computing the render pass.
  101371. * @param camera The camera to apply the render pass to.
  101372. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101373. * @param engine The engine which the post process will be applied. (default: current engine)
  101374. * @param reusable If the post process can be reused on the same frame. (default: false)
  101375. * @param textureType The type of texture to be used when performing the post processing.
  101376. * @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)
  101377. */
  101378. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  101379. }
  101380. }
  101381. declare module BABYLON {
  101382. /** @hidden */
  101383. export var anaglyphPixelShader: {
  101384. name: string;
  101385. shader: string;
  101386. };
  101387. }
  101388. declare module BABYLON {
  101389. /**
  101390. * Postprocess used to generate anaglyphic rendering
  101391. */
  101392. export class AnaglyphPostProcess extends PostProcess {
  101393. private _passedProcess;
  101394. /**
  101395. * Creates a new AnaglyphPostProcess
  101396. * @param name defines postprocess name
  101397. * @param options defines creation options or target ratio scale
  101398. * @param rigCameras defines cameras using this postprocess
  101399. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  101400. * @param engine defines hosting engine
  101401. * @param reusable defines if the postprocess will be reused multiple times per frame
  101402. */
  101403. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  101404. }
  101405. }
  101406. declare module BABYLON {
  101407. /**
  101408. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  101409. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101410. */
  101411. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  101412. /**
  101413. * Creates a new AnaglyphArcRotateCamera
  101414. * @param name defines camera name
  101415. * @param alpha defines alpha angle (in radians)
  101416. * @param beta defines beta angle (in radians)
  101417. * @param radius defines radius
  101418. * @param target defines camera target
  101419. * @param interaxialDistance defines distance between each color axis
  101420. * @param scene defines the hosting scene
  101421. */
  101422. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  101423. /**
  101424. * Gets camera class name
  101425. * @returns AnaglyphArcRotateCamera
  101426. */
  101427. getClassName(): string;
  101428. }
  101429. }
  101430. declare module BABYLON {
  101431. /**
  101432. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  101433. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101434. */
  101435. export class AnaglyphFreeCamera extends FreeCamera {
  101436. /**
  101437. * Creates a new AnaglyphFreeCamera
  101438. * @param name defines camera name
  101439. * @param position defines initial position
  101440. * @param interaxialDistance defines distance between each color axis
  101441. * @param scene defines the hosting scene
  101442. */
  101443. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  101444. /**
  101445. * Gets camera class name
  101446. * @returns AnaglyphFreeCamera
  101447. */
  101448. getClassName(): string;
  101449. }
  101450. }
  101451. declare module BABYLON {
  101452. /**
  101453. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  101454. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101455. */
  101456. export class AnaglyphGamepadCamera extends GamepadCamera {
  101457. /**
  101458. * Creates a new AnaglyphGamepadCamera
  101459. * @param name defines camera name
  101460. * @param position defines initial position
  101461. * @param interaxialDistance defines distance between each color axis
  101462. * @param scene defines the hosting scene
  101463. */
  101464. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  101465. /**
  101466. * Gets camera class name
  101467. * @returns AnaglyphGamepadCamera
  101468. */
  101469. getClassName(): string;
  101470. }
  101471. }
  101472. declare module BABYLON {
  101473. /**
  101474. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  101475. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101476. */
  101477. export class AnaglyphUniversalCamera extends UniversalCamera {
  101478. /**
  101479. * Creates a new AnaglyphUniversalCamera
  101480. * @param name defines camera name
  101481. * @param position defines initial position
  101482. * @param interaxialDistance defines distance between each color axis
  101483. * @param scene defines the hosting scene
  101484. */
  101485. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  101486. /**
  101487. * Gets camera class name
  101488. * @returns AnaglyphUniversalCamera
  101489. */
  101490. getClassName(): string;
  101491. }
  101492. }
  101493. declare module BABYLON {
  101494. /** @hidden */
  101495. export var stereoscopicInterlacePixelShader: {
  101496. name: string;
  101497. shader: string;
  101498. };
  101499. }
  101500. declare module BABYLON {
  101501. /**
  101502. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  101503. */
  101504. export class StereoscopicInterlacePostProcess extends PostProcess {
  101505. private _stepSize;
  101506. private _passedProcess;
  101507. /**
  101508. * Initializes a StereoscopicInterlacePostProcess
  101509. * @param name The name of the effect.
  101510. * @param rigCameras The rig cameras to be appled to the post process
  101511. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  101512. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101513. * @param engine The engine which the post process will be applied. (default: current engine)
  101514. * @param reusable If the post process can be reused on the same frame. (default: false)
  101515. */
  101516. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  101517. }
  101518. }
  101519. declare module BABYLON {
  101520. /**
  101521. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  101522. * @see http://doc.babylonjs.com/features/cameras
  101523. */
  101524. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  101525. /**
  101526. * Creates a new StereoscopicArcRotateCamera
  101527. * @param name defines camera name
  101528. * @param alpha defines alpha angle (in radians)
  101529. * @param beta defines beta angle (in radians)
  101530. * @param radius defines radius
  101531. * @param target defines camera target
  101532. * @param interaxialDistance defines distance between each color axis
  101533. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101534. * @param scene defines the hosting scene
  101535. */
  101536. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101537. /**
  101538. * Gets camera class name
  101539. * @returns StereoscopicArcRotateCamera
  101540. */
  101541. getClassName(): string;
  101542. }
  101543. }
  101544. declare module BABYLON {
  101545. /**
  101546. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  101547. * @see http://doc.babylonjs.com/features/cameras
  101548. */
  101549. export class StereoscopicFreeCamera extends FreeCamera {
  101550. /**
  101551. * Creates a new StereoscopicFreeCamera
  101552. * @param name defines camera name
  101553. * @param position defines initial position
  101554. * @param interaxialDistance defines distance between each color axis
  101555. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101556. * @param scene defines the hosting scene
  101557. */
  101558. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101559. /**
  101560. * Gets camera class name
  101561. * @returns StereoscopicFreeCamera
  101562. */
  101563. getClassName(): string;
  101564. }
  101565. }
  101566. declare module BABYLON {
  101567. /**
  101568. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  101569. * @see http://doc.babylonjs.com/features/cameras
  101570. */
  101571. export class StereoscopicGamepadCamera extends GamepadCamera {
  101572. /**
  101573. * Creates a new StereoscopicGamepadCamera
  101574. * @param name defines camera name
  101575. * @param position defines initial position
  101576. * @param interaxialDistance defines distance between each color axis
  101577. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101578. * @param scene defines the hosting scene
  101579. */
  101580. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101581. /**
  101582. * Gets camera class name
  101583. * @returns StereoscopicGamepadCamera
  101584. */
  101585. getClassName(): string;
  101586. }
  101587. }
  101588. declare module BABYLON {
  101589. /**
  101590. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  101591. * @see http://doc.babylonjs.com/features/cameras
  101592. */
  101593. export class StereoscopicUniversalCamera extends UniversalCamera {
  101594. /**
  101595. * Creates a new StereoscopicUniversalCamera
  101596. * @param name defines camera name
  101597. * @param position defines initial position
  101598. * @param interaxialDistance defines distance between each color axis
  101599. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101600. * @param scene defines the hosting scene
  101601. */
  101602. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101603. /**
  101604. * Gets camera class name
  101605. * @returns StereoscopicUniversalCamera
  101606. */
  101607. getClassName(): string;
  101608. }
  101609. }
  101610. declare module BABYLON {
  101611. /**
  101612. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  101613. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  101614. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  101615. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  101616. */
  101617. export class VirtualJoysticksCamera extends FreeCamera {
  101618. /**
  101619. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  101620. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  101621. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  101622. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  101623. * @param name Define the name of the camera in the scene
  101624. * @param position Define the start position of the camera in the scene
  101625. * @param scene Define the scene the camera belongs to
  101626. */
  101627. constructor(name: string, position: Vector3, scene: Scene);
  101628. /**
  101629. * Gets the current object class name.
  101630. * @return the class name
  101631. */
  101632. getClassName(): string;
  101633. }
  101634. }
  101635. declare module BABYLON {
  101636. /**
  101637. * This represents all the required metrics to create a VR camera.
  101638. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  101639. */
  101640. export class VRCameraMetrics {
  101641. /**
  101642. * Define the horizontal resolution off the screen.
  101643. */
  101644. hResolution: number;
  101645. /**
  101646. * Define the vertical resolution off the screen.
  101647. */
  101648. vResolution: number;
  101649. /**
  101650. * Define the horizontal screen size.
  101651. */
  101652. hScreenSize: number;
  101653. /**
  101654. * Define the vertical screen size.
  101655. */
  101656. vScreenSize: number;
  101657. /**
  101658. * Define the vertical screen center position.
  101659. */
  101660. vScreenCenter: number;
  101661. /**
  101662. * Define the distance of the eyes to the screen.
  101663. */
  101664. eyeToScreenDistance: number;
  101665. /**
  101666. * Define the distance between both lenses
  101667. */
  101668. lensSeparationDistance: number;
  101669. /**
  101670. * Define the distance between both viewer's eyes.
  101671. */
  101672. interpupillaryDistance: number;
  101673. /**
  101674. * Define the distortion factor of the VR postprocess.
  101675. * Please, touch with care.
  101676. */
  101677. distortionK: number[];
  101678. /**
  101679. * Define the chromatic aberration correction factors for the VR post process.
  101680. */
  101681. chromaAbCorrection: number[];
  101682. /**
  101683. * Define the scale factor of the post process.
  101684. * The smaller the better but the slower.
  101685. */
  101686. postProcessScaleFactor: number;
  101687. /**
  101688. * Define an offset for the lens center.
  101689. */
  101690. lensCenterOffset: number;
  101691. /**
  101692. * Define if the current vr camera should compensate the distortion of the lense or not.
  101693. */
  101694. compensateDistortion: boolean;
  101695. /**
  101696. * Defines if multiview should be enabled when rendering (Default: false)
  101697. */
  101698. multiviewEnabled: boolean;
  101699. /**
  101700. * Gets the rendering aspect ratio based on the provided resolutions.
  101701. */
  101702. readonly aspectRatio: number;
  101703. /**
  101704. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  101705. */
  101706. readonly aspectRatioFov: number;
  101707. /**
  101708. * @hidden
  101709. */
  101710. readonly leftHMatrix: Matrix;
  101711. /**
  101712. * @hidden
  101713. */
  101714. readonly rightHMatrix: Matrix;
  101715. /**
  101716. * @hidden
  101717. */
  101718. readonly leftPreViewMatrix: Matrix;
  101719. /**
  101720. * @hidden
  101721. */
  101722. readonly rightPreViewMatrix: Matrix;
  101723. /**
  101724. * Get the default VRMetrics based on the most generic setup.
  101725. * @returns the default vr metrics
  101726. */
  101727. static GetDefault(): VRCameraMetrics;
  101728. }
  101729. }
  101730. declare module BABYLON {
  101731. /** @hidden */
  101732. export var vrDistortionCorrectionPixelShader: {
  101733. name: string;
  101734. shader: string;
  101735. };
  101736. }
  101737. declare module BABYLON {
  101738. /**
  101739. * VRDistortionCorrectionPostProcess used for mobile VR
  101740. */
  101741. export class VRDistortionCorrectionPostProcess extends PostProcess {
  101742. private _isRightEye;
  101743. private _distortionFactors;
  101744. private _postProcessScaleFactor;
  101745. private _lensCenterOffset;
  101746. private _scaleIn;
  101747. private _scaleFactor;
  101748. private _lensCenter;
  101749. /**
  101750. * Initializes the VRDistortionCorrectionPostProcess
  101751. * @param name The name of the effect.
  101752. * @param camera The camera to apply the render pass to.
  101753. * @param isRightEye If this is for the right eye distortion
  101754. * @param vrMetrics All the required metrics for the VR camera
  101755. */
  101756. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  101757. }
  101758. }
  101759. declare module BABYLON {
  101760. /**
  101761. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  101762. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101763. */
  101764. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  101765. /**
  101766. * Creates a new VRDeviceOrientationArcRotateCamera
  101767. * @param name defines camera name
  101768. * @param alpha defines the camera rotation along the logitudinal axis
  101769. * @param beta defines the camera rotation along the latitudinal axis
  101770. * @param radius defines the camera distance from its target
  101771. * @param target defines the camera target
  101772. * @param scene defines the scene the camera belongs to
  101773. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101774. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101775. */
  101776. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101777. /**
  101778. * Gets camera class name
  101779. * @returns VRDeviceOrientationArcRotateCamera
  101780. */
  101781. getClassName(): string;
  101782. }
  101783. }
  101784. declare module BABYLON {
  101785. /**
  101786. * Camera used to simulate VR rendering (based on FreeCamera)
  101787. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101788. */
  101789. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  101790. /**
  101791. * Creates a new VRDeviceOrientationFreeCamera
  101792. * @param name defines camera name
  101793. * @param position defines the start position of the camera
  101794. * @param scene defines the scene the camera belongs to
  101795. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101796. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101797. */
  101798. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101799. /**
  101800. * Gets camera class name
  101801. * @returns VRDeviceOrientationFreeCamera
  101802. */
  101803. getClassName(): string;
  101804. }
  101805. }
  101806. declare module BABYLON {
  101807. /**
  101808. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  101809. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101810. */
  101811. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  101812. /**
  101813. * Creates a new VRDeviceOrientationGamepadCamera
  101814. * @param name defines camera name
  101815. * @param position defines the start position of the camera
  101816. * @param scene defines the scene the camera belongs to
  101817. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101818. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101819. */
  101820. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101821. /**
  101822. * Gets camera class name
  101823. * @returns VRDeviceOrientationGamepadCamera
  101824. */
  101825. getClassName(): string;
  101826. }
  101827. }
  101828. declare module BABYLON {
  101829. /**
  101830. * Base class of materials working in push mode in babylon JS
  101831. * @hidden
  101832. */
  101833. export class PushMaterial extends Material {
  101834. protected _activeEffect: Effect;
  101835. protected _normalMatrix: Matrix;
  101836. /**
  101837. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  101838. * This means that the material can keep using a previous shader while a new one is being compiled.
  101839. * This is mostly used when shader parallel compilation is supported (true by default)
  101840. */
  101841. allowShaderHotSwapping: boolean;
  101842. constructor(name: string, scene: Scene);
  101843. getEffect(): Effect;
  101844. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  101845. /**
  101846. * Binds the given world matrix to the active effect
  101847. *
  101848. * @param world the matrix to bind
  101849. */
  101850. bindOnlyWorldMatrix(world: Matrix): void;
  101851. /**
  101852. * Binds the given normal matrix to the active effect
  101853. *
  101854. * @param normalMatrix the matrix to bind
  101855. */
  101856. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  101857. bind(world: Matrix, mesh?: Mesh): void;
  101858. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  101859. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  101860. }
  101861. }
  101862. declare module BABYLON {
  101863. /**
  101864. * This groups all the flags used to control the materials channel.
  101865. */
  101866. export class MaterialFlags {
  101867. private static _DiffuseTextureEnabled;
  101868. /**
  101869. * Are diffuse textures enabled in the application.
  101870. */
  101871. static DiffuseTextureEnabled: boolean;
  101872. private static _AmbientTextureEnabled;
  101873. /**
  101874. * Are ambient textures enabled in the application.
  101875. */
  101876. static AmbientTextureEnabled: boolean;
  101877. private static _OpacityTextureEnabled;
  101878. /**
  101879. * Are opacity textures enabled in the application.
  101880. */
  101881. static OpacityTextureEnabled: boolean;
  101882. private static _ReflectionTextureEnabled;
  101883. /**
  101884. * Are reflection textures enabled in the application.
  101885. */
  101886. static ReflectionTextureEnabled: boolean;
  101887. private static _EmissiveTextureEnabled;
  101888. /**
  101889. * Are emissive textures enabled in the application.
  101890. */
  101891. static EmissiveTextureEnabled: boolean;
  101892. private static _SpecularTextureEnabled;
  101893. /**
  101894. * Are specular textures enabled in the application.
  101895. */
  101896. static SpecularTextureEnabled: boolean;
  101897. private static _BumpTextureEnabled;
  101898. /**
  101899. * Are bump textures enabled in the application.
  101900. */
  101901. static BumpTextureEnabled: boolean;
  101902. private static _LightmapTextureEnabled;
  101903. /**
  101904. * Are lightmap textures enabled in the application.
  101905. */
  101906. static LightmapTextureEnabled: boolean;
  101907. private static _RefractionTextureEnabled;
  101908. /**
  101909. * Are refraction textures enabled in the application.
  101910. */
  101911. static RefractionTextureEnabled: boolean;
  101912. private static _ColorGradingTextureEnabled;
  101913. /**
  101914. * Are color grading textures enabled in the application.
  101915. */
  101916. static ColorGradingTextureEnabled: boolean;
  101917. private static _FresnelEnabled;
  101918. /**
  101919. * Are fresnels enabled in the application.
  101920. */
  101921. static FresnelEnabled: boolean;
  101922. private static _ClearCoatTextureEnabled;
  101923. /**
  101924. * Are clear coat textures enabled in the application.
  101925. */
  101926. static ClearCoatTextureEnabled: boolean;
  101927. private static _ClearCoatBumpTextureEnabled;
  101928. /**
  101929. * Are clear coat bump textures enabled in the application.
  101930. */
  101931. static ClearCoatBumpTextureEnabled: boolean;
  101932. private static _ClearCoatTintTextureEnabled;
  101933. /**
  101934. * Are clear coat tint textures enabled in the application.
  101935. */
  101936. static ClearCoatTintTextureEnabled: boolean;
  101937. private static _SheenTextureEnabled;
  101938. /**
  101939. * Are sheen textures enabled in the application.
  101940. */
  101941. static SheenTextureEnabled: boolean;
  101942. private static _AnisotropicTextureEnabled;
  101943. /**
  101944. * Are anisotropic textures enabled in the application.
  101945. */
  101946. static AnisotropicTextureEnabled: boolean;
  101947. private static _ThicknessTextureEnabled;
  101948. /**
  101949. * Are thickness textures enabled in the application.
  101950. */
  101951. static ThicknessTextureEnabled: boolean;
  101952. }
  101953. }
  101954. declare module BABYLON {
  101955. /** @hidden */
  101956. export var defaultFragmentDeclaration: {
  101957. name: string;
  101958. shader: string;
  101959. };
  101960. }
  101961. declare module BABYLON {
  101962. /** @hidden */
  101963. export var defaultUboDeclaration: {
  101964. name: string;
  101965. shader: string;
  101966. };
  101967. }
  101968. declare module BABYLON {
  101969. /** @hidden */
  101970. export var lightFragmentDeclaration: {
  101971. name: string;
  101972. shader: string;
  101973. };
  101974. }
  101975. declare module BABYLON {
  101976. /** @hidden */
  101977. export var lightUboDeclaration: {
  101978. name: string;
  101979. shader: string;
  101980. };
  101981. }
  101982. declare module BABYLON {
  101983. /** @hidden */
  101984. export var lightsFragmentFunctions: {
  101985. name: string;
  101986. shader: string;
  101987. };
  101988. }
  101989. declare module BABYLON {
  101990. /** @hidden */
  101991. export var shadowsFragmentFunctions: {
  101992. name: string;
  101993. shader: string;
  101994. };
  101995. }
  101996. declare module BABYLON {
  101997. /** @hidden */
  101998. export var fresnelFunction: {
  101999. name: string;
  102000. shader: string;
  102001. };
  102002. }
  102003. declare module BABYLON {
  102004. /** @hidden */
  102005. export var reflectionFunction: {
  102006. name: string;
  102007. shader: string;
  102008. };
  102009. }
  102010. declare module BABYLON {
  102011. /** @hidden */
  102012. export var bumpFragmentFunctions: {
  102013. name: string;
  102014. shader: string;
  102015. };
  102016. }
  102017. declare module BABYLON {
  102018. /** @hidden */
  102019. export var logDepthDeclaration: {
  102020. name: string;
  102021. shader: string;
  102022. };
  102023. }
  102024. declare module BABYLON {
  102025. /** @hidden */
  102026. export var bumpFragment: {
  102027. name: string;
  102028. shader: string;
  102029. };
  102030. }
  102031. declare module BABYLON {
  102032. /** @hidden */
  102033. export var depthPrePass: {
  102034. name: string;
  102035. shader: string;
  102036. };
  102037. }
  102038. declare module BABYLON {
  102039. /** @hidden */
  102040. export var lightFragment: {
  102041. name: string;
  102042. shader: string;
  102043. };
  102044. }
  102045. declare module BABYLON {
  102046. /** @hidden */
  102047. export var logDepthFragment: {
  102048. name: string;
  102049. shader: string;
  102050. };
  102051. }
  102052. declare module BABYLON {
  102053. /** @hidden */
  102054. export var defaultPixelShader: {
  102055. name: string;
  102056. shader: string;
  102057. };
  102058. }
  102059. declare module BABYLON {
  102060. /** @hidden */
  102061. export var defaultVertexDeclaration: {
  102062. name: string;
  102063. shader: string;
  102064. };
  102065. }
  102066. declare module BABYLON {
  102067. /** @hidden */
  102068. export var bumpVertexDeclaration: {
  102069. name: string;
  102070. shader: string;
  102071. };
  102072. }
  102073. declare module BABYLON {
  102074. /** @hidden */
  102075. export var bumpVertex: {
  102076. name: string;
  102077. shader: string;
  102078. };
  102079. }
  102080. declare module BABYLON {
  102081. /** @hidden */
  102082. export var fogVertex: {
  102083. name: string;
  102084. shader: string;
  102085. };
  102086. }
  102087. declare module BABYLON {
  102088. /** @hidden */
  102089. export var shadowsVertex: {
  102090. name: string;
  102091. shader: string;
  102092. };
  102093. }
  102094. declare module BABYLON {
  102095. /** @hidden */
  102096. export var pointCloudVertex: {
  102097. name: string;
  102098. shader: string;
  102099. };
  102100. }
  102101. declare module BABYLON {
  102102. /** @hidden */
  102103. export var logDepthVertex: {
  102104. name: string;
  102105. shader: string;
  102106. };
  102107. }
  102108. declare module BABYLON {
  102109. /** @hidden */
  102110. export var defaultVertexShader: {
  102111. name: string;
  102112. shader: string;
  102113. };
  102114. }
  102115. declare module BABYLON {
  102116. /** @hidden */
  102117. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  102118. MAINUV1: boolean;
  102119. MAINUV2: boolean;
  102120. DIFFUSE: boolean;
  102121. DIFFUSEDIRECTUV: number;
  102122. AMBIENT: boolean;
  102123. AMBIENTDIRECTUV: number;
  102124. OPACITY: boolean;
  102125. OPACITYDIRECTUV: number;
  102126. OPACITYRGB: boolean;
  102127. REFLECTION: boolean;
  102128. EMISSIVE: boolean;
  102129. EMISSIVEDIRECTUV: number;
  102130. SPECULAR: boolean;
  102131. SPECULARDIRECTUV: number;
  102132. BUMP: boolean;
  102133. BUMPDIRECTUV: number;
  102134. PARALLAX: boolean;
  102135. PARALLAXOCCLUSION: boolean;
  102136. SPECULAROVERALPHA: boolean;
  102137. CLIPPLANE: boolean;
  102138. CLIPPLANE2: boolean;
  102139. CLIPPLANE3: boolean;
  102140. CLIPPLANE4: boolean;
  102141. ALPHATEST: boolean;
  102142. DEPTHPREPASS: boolean;
  102143. ALPHAFROMDIFFUSE: boolean;
  102144. POINTSIZE: boolean;
  102145. FOG: boolean;
  102146. SPECULARTERM: boolean;
  102147. DIFFUSEFRESNEL: boolean;
  102148. OPACITYFRESNEL: boolean;
  102149. REFLECTIONFRESNEL: boolean;
  102150. REFRACTIONFRESNEL: boolean;
  102151. EMISSIVEFRESNEL: boolean;
  102152. FRESNEL: boolean;
  102153. NORMAL: boolean;
  102154. UV1: boolean;
  102155. UV2: boolean;
  102156. VERTEXCOLOR: boolean;
  102157. VERTEXALPHA: boolean;
  102158. NUM_BONE_INFLUENCERS: number;
  102159. BonesPerMesh: number;
  102160. BONETEXTURE: boolean;
  102161. INSTANCES: boolean;
  102162. GLOSSINESS: boolean;
  102163. ROUGHNESS: boolean;
  102164. EMISSIVEASILLUMINATION: boolean;
  102165. LINKEMISSIVEWITHDIFFUSE: boolean;
  102166. REFLECTIONFRESNELFROMSPECULAR: boolean;
  102167. LIGHTMAP: boolean;
  102168. LIGHTMAPDIRECTUV: number;
  102169. OBJECTSPACE_NORMALMAP: boolean;
  102170. USELIGHTMAPASSHADOWMAP: boolean;
  102171. REFLECTIONMAP_3D: boolean;
  102172. REFLECTIONMAP_SPHERICAL: boolean;
  102173. REFLECTIONMAP_PLANAR: boolean;
  102174. REFLECTIONMAP_CUBIC: boolean;
  102175. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  102176. REFLECTIONMAP_PROJECTION: boolean;
  102177. REFLECTIONMAP_SKYBOX: boolean;
  102178. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  102179. REFLECTIONMAP_EXPLICIT: boolean;
  102180. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  102181. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  102182. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  102183. INVERTCUBICMAP: boolean;
  102184. LOGARITHMICDEPTH: boolean;
  102185. REFRACTION: boolean;
  102186. REFRACTIONMAP_3D: boolean;
  102187. REFLECTIONOVERALPHA: boolean;
  102188. TWOSIDEDLIGHTING: boolean;
  102189. SHADOWFLOAT: boolean;
  102190. MORPHTARGETS: boolean;
  102191. MORPHTARGETS_NORMAL: boolean;
  102192. MORPHTARGETS_TANGENT: boolean;
  102193. MORPHTARGETS_UV: boolean;
  102194. NUM_MORPH_INFLUENCERS: number;
  102195. NONUNIFORMSCALING: boolean;
  102196. PREMULTIPLYALPHA: boolean;
  102197. IMAGEPROCESSING: boolean;
  102198. VIGNETTE: boolean;
  102199. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102200. VIGNETTEBLENDMODEOPAQUE: boolean;
  102201. TONEMAPPING: boolean;
  102202. TONEMAPPING_ACES: boolean;
  102203. CONTRAST: boolean;
  102204. COLORCURVES: boolean;
  102205. COLORGRADING: boolean;
  102206. COLORGRADING3D: boolean;
  102207. SAMPLER3DGREENDEPTH: boolean;
  102208. SAMPLER3DBGRMAP: boolean;
  102209. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102210. MULTIVIEW: boolean;
  102211. /**
  102212. * If the reflection texture on this material is in linear color space
  102213. * @hidden
  102214. */
  102215. IS_REFLECTION_LINEAR: boolean;
  102216. /**
  102217. * If the refraction texture on this material is in linear color space
  102218. * @hidden
  102219. */
  102220. IS_REFRACTION_LINEAR: boolean;
  102221. EXPOSURE: boolean;
  102222. constructor();
  102223. setReflectionMode(modeToEnable: string): void;
  102224. }
  102225. /**
  102226. * This is the default material used in Babylon. It is the best trade off between quality
  102227. * and performances.
  102228. * @see http://doc.babylonjs.com/babylon101/materials
  102229. */
  102230. export class StandardMaterial extends PushMaterial {
  102231. private _diffuseTexture;
  102232. /**
  102233. * The basic texture of the material as viewed under a light.
  102234. */
  102235. diffuseTexture: Nullable<BaseTexture>;
  102236. private _ambientTexture;
  102237. /**
  102238. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  102239. */
  102240. ambientTexture: Nullable<BaseTexture>;
  102241. private _opacityTexture;
  102242. /**
  102243. * Define the transparency of the material from a texture.
  102244. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  102245. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  102246. */
  102247. opacityTexture: Nullable<BaseTexture>;
  102248. private _reflectionTexture;
  102249. /**
  102250. * Define the texture used to display the reflection.
  102251. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102252. */
  102253. reflectionTexture: Nullable<BaseTexture>;
  102254. private _emissiveTexture;
  102255. /**
  102256. * Define texture of the material as if self lit.
  102257. * This will be mixed in the final result even in the absence of light.
  102258. */
  102259. emissiveTexture: Nullable<BaseTexture>;
  102260. private _specularTexture;
  102261. /**
  102262. * Define how the color and intensity of the highlight given by the light in the material.
  102263. */
  102264. specularTexture: Nullable<BaseTexture>;
  102265. private _bumpTexture;
  102266. /**
  102267. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  102268. * 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.
  102269. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  102270. */
  102271. bumpTexture: Nullable<BaseTexture>;
  102272. private _lightmapTexture;
  102273. /**
  102274. * Complex lighting can be computationally expensive to compute at runtime.
  102275. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  102276. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  102277. */
  102278. lightmapTexture: Nullable<BaseTexture>;
  102279. private _refractionTexture;
  102280. /**
  102281. * Define the texture used to display the refraction.
  102282. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102283. */
  102284. refractionTexture: Nullable<BaseTexture>;
  102285. /**
  102286. * The color of the material lit by the environmental background lighting.
  102287. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  102288. */
  102289. ambientColor: Color3;
  102290. /**
  102291. * The basic color of the material as viewed under a light.
  102292. */
  102293. diffuseColor: Color3;
  102294. /**
  102295. * Define how the color and intensity of the highlight given by the light in the material.
  102296. */
  102297. specularColor: Color3;
  102298. /**
  102299. * Define the color of the material as if self lit.
  102300. * This will be mixed in the final result even in the absence of light.
  102301. */
  102302. emissiveColor: Color3;
  102303. /**
  102304. * Defines how sharp are the highlights in the material.
  102305. * The bigger the value the sharper giving a more glossy feeling to the result.
  102306. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  102307. */
  102308. specularPower: number;
  102309. private _useAlphaFromDiffuseTexture;
  102310. /**
  102311. * Does the transparency come from the diffuse texture alpha channel.
  102312. */
  102313. useAlphaFromDiffuseTexture: boolean;
  102314. private _useEmissiveAsIllumination;
  102315. /**
  102316. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  102317. */
  102318. useEmissiveAsIllumination: boolean;
  102319. private _linkEmissiveWithDiffuse;
  102320. /**
  102321. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  102322. * the emissive level when the final color is close to one.
  102323. */
  102324. linkEmissiveWithDiffuse: boolean;
  102325. private _useSpecularOverAlpha;
  102326. /**
  102327. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  102328. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  102329. */
  102330. useSpecularOverAlpha: boolean;
  102331. private _useReflectionOverAlpha;
  102332. /**
  102333. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  102334. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  102335. */
  102336. useReflectionOverAlpha: boolean;
  102337. private _disableLighting;
  102338. /**
  102339. * Does lights from the scene impacts this material.
  102340. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  102341. */
  102342. disableLighting: boolean;
  102343. private _useObjectSpaceNormalMap;
  102344. /**
  102345. * Allows using an object space normal map (instead of tangent space).
  102346. */
  102347. useObjectSpaceNormalMap: boolean;
  102348. private _useParallax;
  102349. /**
  102350. * Is parallax enabled or not.
  102351. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  102352. */
  102353. useParallax: boolean;
  102354. private _useParallaxOcclusion;
  102355. /**
  102356. * Is parallax occlusion enabled or not.
  102357. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  102358. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  102359. */
  102360. useParallaxOcclusion: boolean;
  102361. /**
  102362. * 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.
  102363. */
  102364. parallaxScaleBias: number;
  102365. private _roughness;
  102366. /**
  102367. * Helps to define how blurry the reflections should appears in the material.
  102368. */
  102369. roughness: number;
  102370. /**
  102371. * In case of refraction, define the value of the index of refraction.
  102372. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102373. */
  102374. indexOfRefraction: number;
  102375. /**
  102376. * Invert the refraction texture alongside the y axis.
  102377. * It can be useful with procedural textures or probe for instance.
  102378. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102379. */
  102380. invertRefractionY: boolean;
  102381. /**
  102382. * Defines the alpha limits in alpha test mode.
  102383. */
  102384. alphaCutOff: number;
  102385. private _useLightmapAsShadowmap;
  102386. /**
  102387. * In case of light mapping, define whether the map contains light or shadow informations.
  102388. */
  102389. useLightmapAsShadowmap: boolean;
  102390. private _diffuseFresnelParameters;
  102391. /**
  102392. * Define the diffuse fresnel parameters of the material.
  102393. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102394. */
  102395. diffuseFresnelParameters: FresnelParameters;
  102396. private _opacityFresnelParameters;
  102397. /**
  102398. * Define the opacity fresnel parameters of the material.
  102399. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102400. */
  102401. opacityFresnelParameters: FresnelParameters;
  102402. private _reflectionFresnelParameters;
  102403. /**
  102404. * Define the reflection fresnel parameters of the material.
  102405. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102406. */
  102407. reflectionFresnelParameters: FresnelParameters;
  102408. private _refractionFresnelParameters;
  102409. /**
  102410. * Define the refraction fresnel parameters of the material.
  102411. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102412. */
  102413. refractionFresnelParameters: FresnelParameters;
  102414. private _emissiveFresnelParameters;
  102415. /**
  102416. * Define the emissive fresnel parameters of the material.
  102417. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102418. */
  102419. emissiveFresnelParameters: FresnelParameters;
  102420. private _useReflectionFresnelFromSpecular;
  102421. /**
  102422. * If true automatically deducts the fresnels values from the material specularity.
  102423. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102424. */
  102425. useReflectionFresnelFromSpecular: boolean;
  102426. private _useGlossinessFromSpecularMapAlpha;
  102427. /**
  102428. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  102429. */
  102430. useGlossinessFromSpecularMapAlpha: boolean;
  102431. private _maxSimultaneousLights;
  102432. /**
  102433. * Defines the maximum number of lights that can be used in the material
  102434. */
  102435. maxSimultaneousLights: number;
  102436. private _invertNormalMapX;
  102437. /**
  102438. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  102439. */
  102440. invertNormalMapX: boolean;
  102441. private _invertNormalMapY;
  102442. /**
  102443. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  102444. */
  102445. invertNormalMapY: boolean;
  102446. private _twoSidedLighting;
  102447. /**
  102448. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102449. */
  102450. twoSidedLighting: boolean;
  102451. /**
  102452. * Default configuration related to image processing available in the standard Material.
  102453. */
  102454. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102455. /**
  102456. * Gets the image processing configuration used either in this material.
  102457. */
  102458. /**
  102459. * Sets the Default image processing configuration used either in the this material.
  102460. *
  102461. * If sets to null, the scene one is in use.
  102462. */
  102463. imageProcessingConfiguration: ImageProcessingConfiguration;
  102464. /**
  102465. * Keep track of the image processing observer to allow dispose and replace.
  102466. */
  102467. private _imageProcessingObserver;
  102468. /**
  102469. * Attaches a new image processing configuration to the Standard Material.
  102470. * @param configuration
  102471. */
  102472. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102473. /**
  102474. * Gets wether the color curves effect is enabled.
  102475. */
  102476. /**
  102477. * Sets wether the color curves effect is enabled.
  102478. */
  102479. cameraColorCurvesEnabled: boolean;
  102480. /**
  102481. * Gets wether the color grading effect is enabled.
  102482. */
  102483. /**
  102484. * Gets wether the color grading effect is enabled.
  102485. */
  102486. cameraColorGradingEnabled: boolean;
  102487. /**
  102488. * Gets wether tonemapping is enabled or not.
  102489. */
  102490. /**
  102491. * Sets wether tonemapping is enabled or not
  102492. */
  102493. cameraToneMappingEnabled: boolean;
  102494. /**
  102495. * The camera exposure used on this material.
  102496. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102497. * This corresponds to a photographic exposure.
  102498. */
  102499. /**
  102500. * The camera exposure used on this material.
  102501. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102502. * This corresponds to a photographic exposure.
  102503. */
  102504. cameraExposure: number;
  102505. /**
  102506. * Gets The camera contrast used on this material.
  102507. */
  102508. /**
  102509. * Sets The camera contrast used on this material.
  102510. */
  102511. cameraContrast: number;
  102512. /**
  102513. * Gets the Color Grading 2D Lookup Texture.
  102514. */
  102515. /**
  102516. * Sets the Color Grading 2D Lookup Texture.
  102517. */
  102518. cameraColorGradingTexture: Nullable<BaseTexture>;
  102519. /**
  102520. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102521. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102522. * 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;
  102523. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102524. */
  102525. /**
  102526. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102527. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102528. * 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;
  102529. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102530. */
  102531. cameraColorCurves: Nullable<ColorCurves>;
  102532. /**
  102533. * Custom callback helping to override the default shader used in the material.
  102534. */
  102535. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  102536. protected _renderTargets: SmartArray<RenderTargetTexture>;
  102537. protected _worldViewProjectionMatrix: Matrix;
  102538. protected _globalAmbientColor: Color3;
  102539. protected _useLogarithmicDepth: boolean;
  102540. /**
  102541. * Instantiates a new standard material.
  102542. * This is the default material used in Babylon. It is the best trade off between quality
  102543. * and performances.
  102544. * @see http://doc.babylonjs.com/babylon101/materials
  102545. * @param name Define the name of the material in the scene
  102546. * @param scene Define the scene the material belong to
  102547. */
  102548. constructor(name: string, scene: Scene);
  102549. /**
  102550. * Gets a boolean indicating that current material needs to register RTT
  102551. */
  102552. readonly hasRenderTargetTextures: boolean;
  102553. /**
  102554. * Gets the current class name of the material e.g. "StandardMaterial"
  102555. * Mainly use in serialization.
  102556. * @returns the class name
  102557. */
  102558. getClassName(): string;
  102559. /**
  102560. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  102561. * You can try switching to logarithmic depth.
  102562. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  102563. */
  102564. useLogarithmicDepth: boolean;
  102565. /**
  102566. * Specifies if the material will require alpha blending
  102567. * @returns a boolean specifying if alpha blending is needed
  102568. */
  102569. needAlphaBlending(): boolean;
  102570. /**
  102571. * Specifies if this material should be rendered in alpha test mode
  102572. * @returns a boolean specifying if an alpha test is needed.
  102573. */
  102574. needAlphaTesting(): boolean;
  102575. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  102576. /**
  102577. * Get the texture used for alpha test purpose.
  102578. * @returns the diffuse texture in case of the standard material.
  102579. */
  102580. getAlphaTestTexture(): Nullable<BaseTexture>;
  102581. /**
  102582. * Get if the submesh is ready to be used and all its information available.
  102583. * Child classes can use it to update shaders
  102584. * @param mesh defines the mesh to check
  102585. * @param subMesh defines which submesh to check
  102586. * @param useInstances specifies that instances should be used
  102587. * @returns a boolean indicating that the submesh is ready or not
  102588. */
  102589. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102590. /**
  102591. * Builds the material UBO layouts.
  102592. * Used internally during the effect preparation.
  102593. */
  102594. buildUniformLayout(): void;
  102595. /**
  102596. * Unbinds the material from the mesh
  102597. */
  102598. unbind(): void;
  102599. /**
  102600. * Binds the submesh to this material by preparing the effect and shader to draw
  102601. * @param world defines the world transformation matrix
  102602. * @param mesh defines the mesh containing the submesh
  102603. * @param subMesh defines the submesh to bind the material to
  102604. */
  102605. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102606. /**
  102607. * Get the list of animatables in the material.
  102608. * @returns the list of animatables object used in the material
  102609. */
  102610. getAnimatables(): IAnimatable[];
  102611. /**
  102612. * Gets the active textures from the material
  102613. * @returns an array of textures
  102614. */
  102615. getActiveTextures(): BaseTexture[];
  102616. /**
  102617. * Specifies if the material uses a texture
  102618. * @param texture defines the texture to check against the material
  102619. * @returns a boolean specifying if the material uses the texture
  102620. */
  102621. hasTexture(texture: BaseTexture): boolean;
  102622. /**
  102623. * Disposes the material
  102624. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102625. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102626. */
  102627. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  102628. /**
  102629. * Makes a duplicate of the material, and gives it a new name
  102630. * @param name defines the new name for the duplicated material
  102631. * @returns the cloned material
  102632. */
  102633. clone(name: string): StandardMaterial;
  102634. /**
  102635. * Serializes this material in a JSON representation
  102636. * @returns the serialized material object
  102637. */
  102638. serialize(): any;
  102639. /**
  102640. * Creates a standard material from parsed material data
  102641. * @param source defines the JSON representation of the material
  102642. * @param scene defines the hosting scene
  102643. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102644. * @returns a new standard material
  102645. */
  102646. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  102647. /**
  102648. * Are diffuse textures enabled in the application.
  102649. */
  102650. static DiffuseTextureEnabled: boolean;
  102651. /**
  102652. * Are ambient textures enabled in the application.
  102653. */
  102654. static AmbientTextureEnabled: boolean;
  102655. /**
  102656. * Are opacity textures enabled in the application.
  102657. */
  102658. static OpacityTextureEnabled: boolean;
  102659. /**
  102660. * Are reflection textures enabled in the application.
  102661. */
  102662. static ReflectionTextureEnabled: boolean;
  102663. /**
  102664. * Are emissive textures enabled in the application.
  102665. */
  102666. static EmissiveTextureEnabled: boolean;
  102667. /**
  102668. * Are specular textures enabled in the application.
  102669. */
  102670. static SpecularTextureEnabled: boolean;
  102671. /**
  102672. * Are bump textures enabled in the application.
  102673. */
  102674. static BumpTextureEnabled: boolean;
  102675. /**
  102676. * Are lightmap textures enabled in the application.
  102677. */
  102678. static LightmapTextureEnabled: boolean;
  102679. /**
  102680. * Are refraction textures enabled in the application.
  102681. */
  102682. static RefractionTextureEnabled: boolean;
  102683. /**
  102684. * Are color grading textures enabled in the application.
  102685. */
  102686. static ColorGradingTextureEnabled: boolean;
  102687. /**
  102688. * Are fresnels enabled in the application.
  102689. */
  102690. static FresnelEnabled: boolean;
  102691. }
  102692. }
  102693. declare module BABYLON {
  102694. /**
  102695. * A class extending Texture allowing drawing on a texture
  102696. * @see http://doc.babylonjs.com/how_to/dynamictexture
  102697. */
  102698. export class DynamicTexture extends Texture {
  102699. private _generateMipMaps;
  102700. private _canvas;
  102701. private _context;
  102702. private _engine;
  102703. /**
  102704. * Creates a DynamicTexture
  102705. * @param name defines the name of the texture
  102706. * @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
  102707. * @param scene defines the scene where you want the texture
  102708. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  102709. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  102710. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  102711. */
  102712. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  102713. /**
  102714. * Get the current class name of the texture useful for serialization or dynamic coding.
  102715. * @returns "DynamicTexture"
  102716. */
  102717. getClassName(): string;
  102718. /**
  102719. * Gets the current state of canRescale
  102720. */
  102721. readonly canRescale: boolean;
  102722. private _recreate;
  102723. /**
  102724. * Scales the texture
  102725. * @param ratio the scale factor to apply to both width and height
  102726. */
  102727. scale(ratio: number): void;
  102728. /**
  102729. * Resizes the texture
  102730. * @param width the new width
  102731. * @param height the new height
  102732. */
  102733. scaleTo(width: number, height: number): void;
  102734. /**
  102735. * Gets the context of the canvas used by the texture
  102736. * @returns the canvas context of the dynamic texture
  102737. */
  102738. getContext(): CanvasRenderingContext2D;
  102739. /**
  102740. * Clears the texture
  102741. */
  102742. clear(): void;
  102743. /**
  102744. * Updates the texture
  102745. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  102746. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  102747. */
  102748. update(invertY?: boolean, premulAlpha?: boolean): void;
  102749. /**
  102750. * Draws text onto the texture
  102751. * @param text defines the text to be drawn
  102752. * @param x defines the placement of the text from the left
  102753. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  102754. * @param font defines the font to be used with font-style, font-size, font-name
  102755. * @param color defines the color used for the text
  102756. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  102757. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  102758. * @param update defines whether texture is immediately update (default is true)
  102759. */
  102760. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  102761. /**
  102762. * Clones the texture
  102763. * @returns the clone of the texture.
  102764. */
  102765. clone(): DynamicTexture;
  102766. /**
  102767. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  102768. * @returns a serialized dynamic texture object
  102769. */
  102770. serialize(): any;
  102771. /** @hidden */
  102772. _rebuild(): void;
  102773. }
  102774. }
  102775. declare module BABYLON {
  102776. /** @hidden */
  102777. export var imageProcessingPixelShader: {
  102778. name: string;
  102779. shader: string;
  102780. };
  102781. }
  102782. declare module BABYLON {
  102783. /**
  102784. * ImageProcessingPostProcess
  102785. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  102786. */
  102787. export class ImageProcessingPostProcess extends PostProcess {
  102788. /**
  102789. * Default configuration related to image processing available in the PBR Material.
  102790. */
  102791. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102792. /**
  102793. * Gets the image processing configuration used either in this material.
  102794. */
  102795. /**
  102796. * Sets the Default image processing configuration used either in the this material.
  102797. *
  102798. * If sets to null, the scene one is in use.
  102799. */
  102800. imageProcessingConfiguration: ImageProcessingConfiguration;
  102801. /**
  102802. * Keep track of the image processing observer to allow dispose and replace.
  102803. */
  102804. private _imageProcessingObserver;
  102805. /**
  102806. * Attaches a new image processing configuration to the PBR Material.
  102807. * @param configuration
  102808. */
  102809. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  102810. /**
  102811. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102812. */
  102813. /**
  102814. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102815. */
  102816. colorCurves: Nullable<ColorCurves>;
  102817. /**
  102818. * Gets wether the color curves effect is enabled.
  102819. */
  102820. /**
  102821. * Sets wether the color curves effect is enabled.
  102822. */
  102823. colorCurvesEnabled: boolean;
  102824. /**
  102825. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102826. */
  102827. /**
  102828. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102829. */
  102830. colorGradingTexture: Nullable<BaseTexture>;
  102831. /**
  102832. * Gets wether the color grading effect is enabled.
  102833. */
  102834. /**
  102835. * Gets wether the color grading effect is enabled.
  102836. */
  102837. colorGradingEnabled: boolean;
  102838. /**
  102839. * Gets exposure used in the effect.
  102840. */
  102841. /**
  102842. * Sets exposure used in the effect.
  102843. */
  102844. exposure: number;
  102845. /**
  102846. * Gets wether tonemapping is enabled or not.
  102847. */
  102848. /**
  102849. * Sets wether tonemapping is enabled or not
  102850. */
  102851. toneMappingEnabled: boolean;
  102852. /**
  102853. * Gets the type of tone mapping effect.
  102854. */
  102855. /**
  102856. * Sets the type of tone mapping effect.
  102857. */
  102858. toneMappingType: number;
  102859. /**
  102860. * Gets contrast used in the effect.
  102861. */
  102862. /**
  102863. * Sets contrast used in the effect.
  102864. */
  102865. contrast: number;
  102866. /**
  102867. * Gets Vignette stretch size.
  102868. */
  102869. /**
  102870. * Sets Vignette stretch size.
  102871. */
  102872. vignetteStretch: number;
  102873. /**
  102874. * Gets Vignette centre X Offset.
  102875. */
  102876. /**
  102877. * Sets Vignette centre X Offset.
  102878. */
  102879. vignetteCentreX: number;
  102880. /**
  102881. * Gets Vignette centre Y Offset.
  102882. */
  102883. /**
  102884. * Sets Vignette centre Y Offset.
  102885. */
  102886. vignetteCentreY: number;
  102887. /**
  102888. * Gets Vignette weight or intensity of the vignette effect.
  102889. */
  102890. /**
  102891. * Sets Vignette weight or intensity of the vignette effect.
  102892. */
  102893. vignetteWeight: number;
  102894. /**
  102895. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102896. * if vignetteEnabled is set to true.
  102897. */
  102898. /**
  102899. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102900. * if vignetteEnabled is set to true.
  102901. */
  102902. vignetteColor: Color4;
  102903. /**
  102904. * Gets Camera field of view used by the Vignette effect.
  102905. */
  102906. /**
  102907. * Sets Camera field of view used by the Vignette effect.
  102908. */
  102909. vignetteCameraFov: number;
  102910. /**
  102911. * Gets the vignette blend mode allowing different kind of effect.
  102912. */
  102913. /**
  102914. * Sets the vignette blend mode allowing different kind of effect.
  102915. */
  102916. vignetteBlendMode: number;
  102917. /**
  102918. * Gets wether the vignette effect is enabled.
  102919. */
  102920. /**
  102921. * Sets wether the vignette effect is enabled.
  102922. */
  102923. vignetteEnabled: boolean;
  102924. private _fromLinearSpace;
  102925. /**
  102926. * Gets wether the input of the processing is in Gamma or Linear Space.
  102927. */
  102928. /**
  102929. * Sets wether the input of the processing is in Gamma or Linear Space.
  102930. */
  102931. fromLinearSpace: boolean;
  102932. /**
  102933. * Defines cache preventing GC.
  102934. */
  102935. private _defines;
  102936. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  102937. /**
  102938. * "ImageProcessingPostProcess"
  102939. * @returns "ImageProcessingPostProcess"
  102940. */
  102941. getClassName(): string;
  102942. protected _updateParameters(): void;
  102943. dispose(camera?: Camera): void;
  102944. }
  102945. }
  102946. declare module BABYLON {
  102947. /**
  102948. * Class containing static functions to help procedurally build meshes
  102949. */
  102950. export class GroundBuilder {
  102951. /**
  102952. * Creates a ground mesh
  102953. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  102954. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  102955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102956. * @param name defines the name of the mesh
  102957. * @param options defines the options used to create the mesh
  102958. * @param scene defines the hosting scene
  102959. * @returns the ground mesh
  102960. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  102961. */
  102962. static CreateGround(name: string, options: {
  102963. width?: number;
  102964. height?: number;
  102965. subdivisions?: number;
  102966. subdivisionsX?: number;
  102967. subdivisionsY?: number;
  102968. updatable?: boolean;
  102969. }, scene: any): Mesh;
  102970. /**
  102971. * Creates a tiled ground mesh
  102972. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  102973. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  102974. * * 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
  102975. * * 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
  102976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102977. * @param name defines the name of the mesh
  102978. * @param options defines the options used to create the mesh
  102979. * @param scene defines the hosting scene
  102980. * @returns the tiled ground mesh
  102981. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  102982. */
  102983. static CreateTiledGround(name: string, options: {
  102984. xmin: number;
  102985. zmin: number;
  102986. xmax: number;
  102987. zmax: number;
  102988. subdivisions?: {
  102989. w: number;
  102990. h: number;
  102991. };
  102992. precision?: {
  102993. w: number;
  102994. h: number;
  102995. };
  102996. updatable?: boolean;
  102997. }, scene?: Nullable<Scene>): Mesh;
  102998. /**
  102999. * Creates a ground mesh from a height map
  103000. * * The parameter `url` sets the URL of the height map image resource.
  103001. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  103002. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  103003. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  103004. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  103005. * * 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.
  103006. * * 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).
  103007. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  103008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103009. * @param name defines the name of the mesh
  103010. * @param url defines the url to the height map
  103011. * @param options defines the options used to create the mesh
  103012. * @param scene defines the hosting scene
  103013. * @returns the ground mesh
  103014. * @see https://doc.babylonjs.com/babylon101/height_map
  103015. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  103016. */
  103017. static CreateGroundFromHeightMap(name: string, url: string, options: {
  103018. width?: number;
  103019. height?: number;
  103020. subdivisions?: number;
  103021. minHeight?: number;
  103022. maxHeight?: number;
  103023. colorFilter?: Color3;
  103024. alphaFilter?: number;
  103025. updatable?: boolean;
  103026. onReady?: (mesh: GroundMesh) => void;
  103027. }, scene?: Nullable<Scene>): GroundMesh;
  103028. }
  103029. }
  103030. declare module BABYLON {
  103031. /**
  103032. * Class containing static functions to help procedurally build meshes
  103033. */
  103034. export class TorusBuilder {
  103035. /**
  103036. * Creates a torus mesh
  103037. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  103038. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  103039. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  103040. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103041. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103043. * @param name defines the name of the mesh
  103044. * @param options defines the options used to create the mesh
  103045. * @param scene defines the hosting scene
  103046. * @returns the torus mesh
  103047. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  103048. */
  103049. static CreateTorus(name: string, options: {
  103050. diameter?: number;
  103051. thickness?: number;
  103052. tessellation?: number;
  103053. updatable?: boolean;
  103054. sideOrientation?: number;
  103055. frontUVs?: Vector4;
  103056. backUVs?: Vector4;
  103057. }, scene: any): Mesh;
  103058. }
  103059. }
  103060. declare module BABYLON {
  103061. /**
  103062. * Class containing static functions to help procedurally build meshes
  103063. */
  103064. export class CylinderBuilder {
  103065. /**
  103066. * Creates a cylinder or a cone mesh
  103067. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  103068. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  103069. * * 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.
  103070. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  103071. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  103072. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  103073. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  103074. * * 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).
  103075. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  103076. * * 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).
  103077. * * 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
  103078. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  103079. * * 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
  103080. * * 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.
  103081. * * If `enclose` is false, a ring surface is one element.
  103082. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  103083. * * 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
  103084. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103085. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103087. * @param name defines the name of the mesh
  103088. * @param options defines the options used to create the mesh
  103089. * @param scene defines the hosting scene
  103090. * @returns the cylinder mesh
  103091. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  103092. */
  103093. static CreateCylinder(name: string, options: {
  103094. height?: number;
  103095. diameterTop?: number;
  103096. diameterBottom?: number;
  103097. diameter?: number;
  103098. tessellation?: number;
  103099. subdivisions?: number;
  103100. arc?: number;
  103101. faceColors?: Color4[];
  103102. faceUV?: Vector4[];
  103103. updatable?: boolean;
  103104. hasRings?: boolean;
  103105. enclose?: boolean;
  103106. cap?: number;
  103107. sideOrientation?: number;
  103108. frontUVs?: Vector4;
  103109. backUVs?: Vector4;
  103110. }, scene: any): Mesh;
  103111. }
  103112. }
  103113. declare module BABYLON {
  103114. /**
  103115. * Options to modify the vr teleportation behavior.
  103116. */
  103117. export interface VRTeleportationOptions {
  103118. /**
  103119. * The name of the mesh which should be used as the teleportation floor. (default: null)
  103120. */
  103121. floorMeshName?: string;
  103122. /**
  103123. * A list of meshes to be used as the teleportation floor. (default: empty)
  103124. */
  103125. floorMeshes?: Mesh[];
  103126. }
  103127. /**
  103128. * Options to modify the vr experience helper's behavior.
  103129. */
  103130. export interface VRExperienceHelperOptions extends WebVROptions {
  103131. /**
  103132. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  103133. */
  103134. createDeviceOrientationCamera?: boolean;
  103135. /**
  103136. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  103137. */
  103138. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  103139. /**
  103140. * Uses the main button on the controller to toggle the laser casted. (default: true)
  103141. */
  103142. laserToggle?: boolean;
  103143. /**
  103144. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  103145. */
  103146. floorMeshes?: Mesh[];
  103147. /**
  103148. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  103149. */
  103150. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  103151. }
  103152. /**
  103153. * Event containing information after VR has been entered
  103154. */
  103155. export class OnAfterEnteringVRObservableEvent {
  103156. /**
  103157. * If entering vr was successful
  103158. */
  103159. success: boolean;
  103160. }
  103161. /**
  103162. * Helps to quickly add VR support to an existing scene.
  103163. * See http://doc.babylonjs.com/how_to/webvr_helper
  103164. */
  103165. export class VRExperienceHelper {
  103166. /** Options to modify the vr experience helper's behavior. */
  103167. webVROptions: VRExperienceHelperOptions;
  103168. private _scene;
  103169. private _position;
  103170. private _btnVR;
  103171. private _btnVRDisplayed;
  103172. private _webVRsupported;
  103173. private _webVRready;
  103174. private _webVRrequesting;
  103175. private _webVRpresenting;
  103176. private _hasEnteredVR;
  103177. private _fullscreenVRpresenting;
  103178. private _canvas;
  103179. private _webVRCamera;
  103180. private _vrDeviceOrientationCamera;
  103181. private _deviceOrientationCamera;
  103182. private _existingCamera;
  103183. private _onKeyDown;
  103184. private _onVrDisplayPresentChange;
  103185. private _onVRDisplayChanged;
  103186. private _onVRRequestPresentStart;
  103187. private _onVRRequestPresentComplete;
  103188. /**
  103189. * Observable raised right before entering VR.
  103190. */
  103191. onEnteringVRObservable: Observable<VRExperienceHelper>;
  103192. /**
  103193. * Observable raised when entering VR has completed.
  103194. */
  103195. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  103196. /**
  103197. * Observable raised when exiting VR.
  103198. */
  103199. onExitingVRObservable: Observable<VRExperienceHelper>;
  103200. /**
  103201. * Observable raised when controller mesh is loaded.
  103202. */
  103203. onControllerMeshLoadedObservable: Observable<WebVRController>;
  103204. /** Return this.onEnteringVRObservable
  103205. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  103206. */
  103207. readonly onEnteringVR: Observable<VRExperienceHelper>;
  103208. /** Return this.onExitingVRObservable
  103209. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  103210. */
  103211. readonly onExitingVR: Observable<VRExperienceHelper>;
  103212. /** Return this.onControllerMeshLoadedObservable
  103213. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  103214. */
  103215. readonly onControllerMeshLoaded: Observable<WebVRController>;
  103216. private _rayLength;
  103217. private _useCustomVRButton;
  103218. private _teleportationRequested;
  103219. private _teleportActive;
  103220. private _floorMeshName;
  103221. private _floorMeshesCollection;
  103222. private _rotationAllowed;
  103223. private _teleportBackwardsVector;
  103224. private _teleportationTarget;
  103225. private _isDefaultTeleportationTarget;
  103226. private _postProcessMove;
  103227. private _teleportationFillColor;
  103228. private _teleportationBorderColor;
  103229. private _rotationAngle;
  103230. private _haloCenter;
  103231. private _cameraGazer;
  103232. private _padSensibilityUp;
  103233. private _padSensibilityDown;
  103234. private _leftController;
  103235. private _rightController;
  103236. /**
  103237. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  103238. */
  103239. onNewMeshSelected: Observable<AbstractMesh>;
  103240. /**
  103241. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  103242. */
  103243. onNewMeshPicked: Observable<PickingInfo>;
  103244. private _circleEase;
  103245. /**
  103246. * Observable raised before camera teleportation
  103247. */
  103248. onBeforeCameraTeleport: Observable<Vector3>;
  103249. /**
  103250. * Observable raised after camera teleportation
  103251. */
  103252. onAfterCameraTeleport: Observable<Vector3>;
  103253. /**
  103254. * Observable raised when current selected mesh gets unselected
  103255. */
  103256. onSelectedMeshUnselected: Observable<AbstractMesh>;
  103257. private _raySelectionPredicate;
  103258. /**
  103259. * To be optionaly changed by user to define custom ray selection
  103260. */
  103261. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  103262. /**
  103263. * To be optionaly changed by user to define custom selection logic (after ray selection)
  103264. */
  103265. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  103266. /**
  103267. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  103268. */
  103269. teleportationEnabled: boolean;
  103270. private _defaultHeight;
  103271. private _teleportationInitialized;
  103272. private _interactionsEnabled;
  103273. private _interactionsRequested;
  103274. private _displayGaze;
  103275. private _displayLaserPointer;
  103276. /**
  103277. * The mesh used to display where the user is going to teleport.
  103278. */
  103279. /**
  103280. * Sets the mesh to be used to display where the user is going to teleport.
  103281. */
  103282. teleportationTarget: Mesh;
  103283. /**
  103284. * 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
  103285. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  103286. * See http://doc.babylonjs.com/resources/baking_transformations
  103287. */
  103288. gazeTrackerMesh: Mesh;
  103289. /**
  103290. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  103291. */
  103292. updateGazeTrackerScale: boolean;
  103293. /**
  103294. * If the gaze trackers color should be updated when selecting meshes
  103295. */
  103296. updateGazeTrackerColor: boolean;
  103297. /**
  103298. * The gaze tracking mesh corresponding to the left controller
  103299. */
  103300. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  103301. /**
  103302. * The gaze tracking mesh corresponding to the right controller
  103303. */
  103304. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  103305. /**
  103306. * If the ray of the gaze should be displayed.
  103307. */
  103308. /**
  103309. * Sets if the ray of the gaze should be displayed.
  103310. */
  103311. displayGaze: boolean;
  103312. /**
  103313. * If the ray of the LaserPointer should be displayed.
  103314. */
  103315. /**
  103316. * Sets if the ray of the LaserPointer should be displayed.
  103317. */
  103318. displayLaserPointer: boolean;
  103319. /**
  103320. * The deviceOrientationCamera used as the camera when not in VR.
  103321. */
  103322. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  103323. /**
  103324. * Based on the current WebVR support, returns the current VR camera used.
  103325. */
  103326. readonly currentVRCamera: Nullable<Camera>;
  103327. /**
  103328. * The webVRCamera which is used when in VR.
  103329. */
  103330. readonly webVRCamera: WebVRFreeCamera;
  103331. /**
  103332. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  103333. */
  103334. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  103335. private readonly _teleportationRequestInitiated;
  103336. /**
  103337. * Defines wether or not Pointer lock should be requested when switching to
  103338. * full screen.
  103339. */
  103340. requestPointerLockOnFullScreen: boolean;
  103341. /**
  103342. * Instantiates a VRExperienceHelper.
  103343. * Helps to quickly add VR support to an existing scene.
  103344. * @param scene The scene the VRExperienceHelper belongs to.
  103345. * @param webVROptions Options to modify the vr experience helper's behavior.
  103346. */
  103347. constructor(scene: Scene,
  103348. /** Options to modify the vr experience helper's behavior. */
  103349. webVROptions?: VRExperienceHelperOptions);
  103350. private _onDefaultMeshLoaded;
  103351. private _onResize;
  103352. private _onFullscreenChange;
  103353. /**
  103354. * Gets a value indicating if we are currently in VR mode.
  103355. */
  103356. readonly isInVRMode: boolean;
  103357. private onVrDisplayPresentChange;
  103358. private onVRDisplayChanged;
  103359. private moveButtonToBottomRight;
  103360. private displayVRButton;
  103361. private updateButtonVisibility;
  103362. private _cachedAngularSensibility;
  103363. /**
  103364. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  103365. * Otherwise, will use the fullscreen API.
  103366. */
  103367. enterVR(): void;
  103368. /**
  103369. * Attempt to exit VR, or fullscreen.
  103370. */
  103371. exitVR(): void;
  103372. /**
  103373. * The position of the vr experience helper.
  103374. */
  103375. /**
  103376. * Sets the position of the vr experience helper.
  103377. */
  103378. position: Vector3;
  103379. /**
  103380. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  103381. */
  103382. enableInteractions(): void;
  103383. private readonly _noControllerIsActive;
  103384. private beforeRender;
  103385. private _isTeleportationFloor;
  103386. /**
  103387. * Adds a floor mesh to be used for teleportation.
  103388. * @param floorMesh the mesh to be used for teleportation.
  103389. */
  103390. addFloorMesh(floorMesh: Mesh): void;
  103391. /**
  103392. * Removes a floor mesh from being used for teleportation.
  103393. * @param floorMesh the mesh to be removed.
  103394. */
  103395. removeFloorMesh(floorMesh: Mesh): void;
  103396. /**
  103397. * Enables interactions and teleportation using the VR controllers and gaze.
  103398. * @param vrTeleportationOptions options to modify teleportation behavior.
  103399. */
  103400. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  103401. private _onNewGamepadConnected;
  103402. private _tryEnableInteractionOnController;
  103403. private _onNewGamepadDisconnected;
  103404. private _enableInteractionOnController;
  103405. private _checkTeleportWithRay;
  103406. private _checkRotate;
  103407. private _checkTeleportBackwards;
  103408. private _enableTeleportationOnController;
  103409. private _createTeleportationCircles;
  103410. private _displayTeleportationTarget;
  103411. private _hideTeleportationTarget;
  103412. private _rotateCamera;
  103413. private _moveTeleportationSelectorTo;
  103414. private _workingVector;
  103415. private _workingQuaternion;
  103416. private _workingMatrix;
  103417. /**
  103418. * Teleports the users feet to the desired location
  103419. * @param location The location where the user's feet should be placed
  103420. */
  103421. teleportCamera(location: Vector3): void;
  103422. private _convertNormalToDirectionOfRay;
  103423. private _castRayAndSelectObject;
  103424. private _notifySelectedMeshUnselected;
  103425. /**
  103426. * Sets the color of the laser ray from the vr controllers.
  103427. * @param color new color for the ray.
  103428. */
  103429. changeLaserColor(color: Color3): void;
  103430. /**
  103431. * Sets the color of the ray from the vr headsets gaze.
  103432. * @param color new color for the ray.
  103433. */
  103434. changeGazeColor(color: Color3): void;
  103435. /**
  103436. * Exits VR and disposes of the vr experience helper
  103437. */
  103438. dispose(): void;
  103439. /**
  103440. * Gets the name of the VRExperienceHelper class
  103441. * @returns "VRExperienceHelper"
  103442. */
  103443. getClassName(): string;
  103444. }
  103445. }
  103446. declare module BABYLON {
  103447. /**
  103448. * Manages an XRSession
  103449. * @see https://doc.babylonjs.com/how_to/webxr
  103450. */
  103451. export class WebXRSessionManager implements IDisposable {
  103452. private scene;
  103453. /**
  103454. * Fires every time a new xrFrame arrives which can be used to update the camera
  103455. */
  103456. onXRFrameObservable: Observable<any>;
  103457. /**
  103458. * Fires when the xr session is ended either by the device or manually done
  103459. */
  103460. onXRSessionEnded: Observable<any>;
  103461. /** @hidden */
  103462. _xrSession: XRSession;
  103463. /** @hidden */
  103464. _frameOfReference: XRFrameOfReference;
  103465. /** @hidden */
  103466. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  103467. /** @hidden */
  103468. _currentXRFrame: Nullable<XRFrame>;
  103469. private _xrNavigator;
  103470. private _xrDevice;
  103471. private _tmpMatrix;
  103472. /**
  103473. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  103474. * @param scene The scene which the session should be created for
  103475. */
  103476. constructor(scene: Scene);
  103477. /**
  103478. * Initializes the manager
  103479. * After initialization enterXR can be called to start an XR session
  103480. * @returns Promise which resolves after it is initialized
  103481. */
  103482. initializeAsync(): Promise<void>;
  103483. /**
  103484. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  103485. * @param sessionCreationOptions xr options to create the session with
  103486. * @param frameOfReferenceType option to configure how the xr pose is expressed
  103487. * @returns Promise which resolves after it enters XR
  103488. */
  103489. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  103490. /**
  103491. * Stops the xrSession and restores the renderloop
  103492. * @returns Promise which resolves after it exits XR
  103493. */
  103494. exitXRAsync(): Promise<void>;
  103495. /**
  103496. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  103497. * @param ray ray to cast into the environment
  103498. * @returns Promise which resolves with a collision point in the environment if it exists
  103499. */
  103500. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  103501. /**
  103502. * Checks if a session would be supported for the creation options specified
  103503. * @param options creation options to check if they are supported
  103504. * @returns true if supported
  103505. */
  103506. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  103507. /**
  103508. * @hidden
  103509. * Converts the render layer of xrSession to a render target
  103510. * @param session session to create render target for
  103511. * @param scene scene the new render target should be created for
  103512. */
  103513. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  103514. /**
  103515. * Disposes of the session manager
  103516. */
  103517. dispose(): void;
  103518. }
  103519. }
  103520. declare module BABYLON {
  103521. /**
  103522. * WebXR Camera which holds the views for the xrSession
  103523. * @see https://doc.babylonjs.com/how_to/webxr
  103524. */
  103525. export class WebXRCamera extends FreeCamera {
  103526. private static _TmpMatrix;
  103527. /**
  103528. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  103529. * @param name the name of the camera
  103530. * @param scene the scene to add the camera to
  103531. */
  103532. constructor(name: string, scene: Scene);
  103533. private _updateNumberOfRigCameras;
  103534. /** @hidden */
  103535. _updateForDualEyeDebugging(pupilDistance?: number): void;
  103536. /**
  103537. * Updates the cameras position from the current pose information of the XR session
  103538. * @param xrSessionManager the session containing pose information
  103539. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  103540. */
  103541. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  103542. }
  103543. }
  103544. declare module BABYLON {
  103545. /**
  103546. * States of the webXR experience
  103547. */
  103548. export enum WebXRState {
  103549. /**
  103550. * Transitioning to being in XR mode
  103551. */
  103552. ENTERING_XR = 0,
  103553. /**
  103554. * Transitioning to non XR mode
  103555. */
  103556. EXITING_XR = 1,
  103557. /**
  103558. * In XR mode and presenting
  103559. */
  103560. IN_XR = 2,
  103561. /**
  103562. * Not entered XR mode
  103563. */
  103564. NOT_IN_XR = 3
  103565. }
  103566. /**
  103567. * Helper class used to enable XR
  103568. * @see https://doc.babylonjs.com/how_to/webxr
  103569. */
  103570. export class WebXRExperienceHelper implements IDisposable {
  103571. private scene;
  103572. /**
  103573. * 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
  103574. */
  103575. container: AbstractMesh;
  103576. /**
  103577. * Camera used to render xr content
  103578. */
  103579. camera: WebXRCamera;
  103580. /**
  103581. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  103582. */
  103583. state: WebXRState;
  103584. private _setState;
  103585. private static _TmpVector;
  103586. /**
  103587. * Fires when the state of the experience helper has changed
  103588. */
  103589. onStateChangedObservable: Observable<WebXRState>;
  103590. /** @hidden */
  103591. _sessionManager: WebXRSessionManager;
  103592. private _nonVRCamera;
  103593. private _originalSceneAutoClear;
  103594. private _supported;
  103595. /**
  103596. * Creates the experience helper
  103597. * @param scene the scene to attach the experience helper to
  103598. * @returns a promise for the experience helper
  103599. */
  103600. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  103601. /**
  103602. * Creates a WebXRExperienceHelper
  103603. * @param scene The scene the helper should be created in
  103604. */
  103605. private constructor();
  103606. /**
  103607. * Exits XR mode and returns the scene to its original state
  103608. * @returns promise that resolves after xr mode has exited
  103609. */
  103610. exitXRAsync(): Promise<void>;
  103611. /**
  103612. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  103613. * @param sessionCreationOptions options for the XR session
  103614. * @param frameOfReference frame of reference of the XR session
  103615. * @returns promise that resolves after xr mode has entered
  103616. */
  103617. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  103618. /**
  103619. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  103620. * @param ray ray to cast into the environment
  103621. * @returns Promise which resolves with a collision point in the environment if it exists
  103622. */
  103623. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  103624. /**
  103625. * Updates the global position of the camera by moving the camera's container
  103626. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  103627. * @param position The desired global position of the camera
  103628. */
  103629. setPositionOfCameraUsingContainer(position: Vector3): void;
  103630. /**
  103631. * Rotates the xr camera by rotating the camera's container around the camera's position
  103632. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  103633. * @param rotation the desired quaternion rotation to apply to the camera
  103634. */
  103635. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  103636. /**
  103637. * Checks if the creation options are supported by the xr session
  103638. * @param options creation options
  103639. * @returns true if supported
  103640. */
  103641. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  103642. /**
  103643. * Disposes of the experience helper
  103644. */
  103645. dispose(): void;
  103646. }
  103647. }
  103648. declare module BABYLON {
  103649. /**
  103650. * Button which can be used to enter a different mode of XR
  103651. */
  103652. export class WebXREnterExitUIButton {
  103653. /** button element */
  103654. element: HTMLElement;
  103655. /** XR initialization options for the button */
  103656. initializationOptions: XRSessionCreationOptions;
  103657. /**
  103658. * Creates a WebXREnterExitUIButton
  103659. * @param element button element
  103660. * @param initializationOptions XR initialization options for the button
  103661. */
  103662. constructor(
  103663. /** button element */
  103664. element: HTMLElement,
  103665. /** XR initialization options for the button */
  103666. initializationOptions: XRSessionCreationOptions);
  103667. /**
  103668. * Overwritable function which can be used to update the button's visuals when the state changes
  103669. * @param activeButton the current active button in the UI
  103670. */
  103671. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  103672. }
  103673. /**
  103674. * Options to create the webXR UI
  103675. */
  103676. export class WebXREnterExitUIOptions {
  103677. /**
  103678. * Context to enter xr with
  103679. */
  103680. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  103681. /**
  103682. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  103683. */
  103684. customButtons?: Array<WebXREnterExitUIButton>;
  103685. }
  103686. /**
  103687. * UI to allow the user to enter/exit XR mode
  103688. */
  103689. export class WebXREnterExitUI implements IDisposable {
  103690. private scene;
  103691. private _overlay;
  103692. private _buttons;
  103693. private _activeButton;
  103694. /**
  103695. * Fired every time the active button is changed.
  103696. *
  103697. * When xr is entered via a button that launches xr that button will be the callback parameter
  103698. *
  103699. * When exiting xr the callback parameter will be null)
  103700. */
  103701. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  103702. /**
  103703. * Creates UI to allow the user to enter/exit XR mode
  103704. * @param scene the scene to add the ui to
  103705. * @param helper the xr experience helper to enter/exit xr with
  103706. * @param options options to configure the UI
  103707. * @returns the created ui
  103708. */
  103709. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  103710. private constructor();
  103711. private _updateButtons;
  103712. /**
  103713. * Disposes of the object
  103714. */
  103715. dispose(): void;
  103716. }
  103717. }
  103718. declare module BABYLON {
  103719. /**
  103720. * Represents an XR input
  103721. */
  103722. export class WebXRController {
  103723. /**
  103724. * 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
  103725. */
  103726. grip?: AbstractMesh;
  103727. /**
  103728. * Pointer which can be used to select objects or attach a visible laser to
  103729. */
  103730. pointer: AbstractMesh;
  103731. /**
  103732. * Creates the controller
  103733. * @see https://doc.babylonjs.com/how_to/webxr
  103734. * @param scene the scene which the controller should be associated to
  103735. */
  103736. constructor(scene: Scene);
  103737. /**
  103738. * Disposes of the object
  103739. */
  103740. dispose(): void;
  103741. }
  103742. /**
  103743. * XR input used to track XR inputs such as controllers/rays
  103744. */
  103745. export class WebXRInput implements IDisposable {
  103746. private helper;
  103747. /**
  103748. * XR controllers being tracked
  103749. */
  103750. controllers: Array<WebXRController>;
  103751. private _tmpMatrix;
  103752. private _frameObserver;
  103753. /**
  103754. * Initializes the WebXRInput
  103755. * @param helper experience helper which the input should be created for
  103756. */
  103757. constructor(helper: WebXRExperienceHelper);
  103758. /**
  103759. * Disposes of the object
  103760. */
  103761. dispose(): void;
  103762. }
  103763. }
  103764. declare module BABYLON {
  103765. /**
  103766. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  103767. */
  103768. export class WebXRManagedOutputCanvas implements IDisposable {
  103769. private _canvas;
  103770. /**
  103771. * xrpresent context of the canvas which can be used to display/mirror xr content
  103772. */
  103773. canvasContext: Nullable<WebGLRenderingContext>;
  103774. /**
  103775. * Initializes the canvas to be added/removed upon entering/exiting xr
  103776. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  103777. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  103778. */
  103779. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  103780. /**
  103781. * Disposes of the object
  103782. */
  103783. dispose(): void;
  103784. private _setManagedOutputCanvas;
  103785. private _addCanvas;
  103786. private _removeCanvas;
  103787. }
  103788. }
  103789. declare module BABYLON {
  103790. /**
  103791. * Contains an array of blocks representing the octree
  103792. */
  103793. export interface IOctreeContainer<T> {
  103794. /**
  103795. * Blocks within the octree
  103796. */
  103797. blocks: Array<OctreeBlock<T>>;
  103798. }
  103799. /**
  103800. * Class used to store a cell in an octree
  103801. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103802. */
  103803. export class OctreeBlock<T> {
  103804. /**
  103805. * Gets the content of the current block
  103806. */
  103807. entries: T[];
  103808. /**
  103809. * Gets the list of block children
  103810. */
  103811. blocks: Array<OctreeBlock<T>>;
  103812. private _depth;
  103813. private _maxDepth;
  103814. private _capacity;
  103815. private _minPoint;
  103816. private _maxPoint;
  103817. private _boundingVectors;
  103818. private _creationFunc;
  103819. /**
  103820. * Creates a new block
  103821. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  103822. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  103823. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  103824. * @param depth defines the current depth of this block in the octree
  103825. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  103826. * @param creationFunc defines a callback to call when an element is added to the block
  103827. */
  103828. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  103829. /**
  103830. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  103831. */
  103832. readonly capacity: number;
  103833. /**
  103834. * Gets the minimum vector (in world space) of the block's bounding box
  103835. */
  103836. readonly minPoint: Vector3;
  103837. /**
  103838. * Gets the maximum vector (in world space) of the block's bounding box
  103839. */
  103840. readonly maxPoint: Vector3;
  103841. /**
  103842. * Add a new element to this block
  103843. * @param entry defines the element to add
  103844. */
  103845. addEntry(entry: T): void;
  103846. /**
  103847. * Remove an element from this block
  103848. * @param entry defines the element to remove
  103849. */
  103850. removeEntry(entry: T): void;
  103851. /**
  103852. * Add an array of elements to this block
  103853. * @param entries defines the array of elements to add
  103854. */
  103855. addEntries(entries: T[]): void;
  103856. /**
  103857. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  103858. * @param frustumPlanes defines the frustum planes to test
  103859. * @param selection defines the array to store current content if selection is positive
  103860. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103861. */
  103862. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  103863. /**
  103864. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  103865. * @param sphereCenter defines the bounding sphere center
  103866. * @param sphereRadius defines the bounding sphere radius
  103867. * @param selection defines the array to store current content if selection is positive
  103868. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103869. */
  103870. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  103871. /**
  103872. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  103873. * @param ray defines the ray to test with
  103874. * @param selection defines the array to store current content if selection is positive
  103875. */
  103876. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  103877. /**
  103878. * Subdivide the content into child blocks (this block will then be empty)
  103879. */
  103880. createInnerBlocks(): void;
  103881. /**
  103882. * @hidden
  103883. */
  103884. 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;
  103885. }
  103886. }
  103887. declare module BABYLON {
  103888. /**
  103889. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  103890. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103891. */
  103892. export class Octree<T> {
  103893. /** 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.) */
  103894. maxDepth: number;
  103895. /**
  103896. * Blocks within the octree containing objects
  103897. */
  103898. blocks: Array<OctreeBlock<T>>;
  103899. /**
  103900. * Content stored in the octree
  103901. */
  103902. dynamicContent: T[];
  103903. private _maxBlockCapacity;
  103904. private _selectionContent;
  103905. private _creationFunc;
  103906. /**
  103907. * Creates a octree
  103908. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103909. * @param creationFunc function to be used to instatiate the octree
  103910. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  103911. * @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.)
  103912. */
  103913. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  103914. /** 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.) */
  103915. maxDepth?: number);
  103916. /**
  103917. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  103918. * @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);
  103919. * @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);
  103920. * @param entries meshes to be added to the octree blocks
  103921. */
  103922. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  103923. /**
  103924. * Adds a mesh to the octree
  103925. * @param entry Mesh to add to the octree
  103926. */
  103927. addMesh(entry: T): void;
  103928. /**
  103929. * Remove an element from the octree
  103930. * @param entry defines the element to remove
  103931. */
  103932. removeMesh(entry: T): void;
  103933. /**
  103934. * Selects an array of meshes within the frustum
  103935. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  103936. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  103937. * @returns array of meshes within the frustum
  103938. */
  103939. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  103940. /**
  103941. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  103942. * @param sphereCenter defines the bounding sphere center
  103943. * @param sphereRadius defines the bounding sphere radius
  103944. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103945. * @returns an array of objects that intersect the sphere
  103946. */
  103947. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  103948. /**
  103949. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  103950. * @param ray defines the ray to test with
  103951. * @returns array of intersected objects
  103952. */
  103953. intersectsRay(ray: Ray): SmartArray<T>;
  103954. /**
  103955. * Adds a mesh into the octree block if it intersects the block
  103956. */
  103957. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  103958. /**
  103959. * Adds a submesh into the octree block if it intersects the block
  103960. */
  103961. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  103962. }
  103963. }
  103964. declare module BABYLON {
  103965. interface Scene {
  103966. /**
  103967. * @hidden
  103968. * Backing Filed
  103969. */
  103970. _selectionOctree: Octree<AbstractMesh>;
  103971. /**
  103972. * Gets the octree used to boost mesh selection (picking)
  103973. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103974. */
  103975. selectionOctree: Octree<AbstractMesh>;
  103976. /**
  103977. * Creates or updates the octree used to boost selection (picking)
  103978. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103979. * @param maxCapacity defines the maximum capacity per leaf
  103980. * @param maxDepth defines the maximum depth of the octree
  103981. * @returns an octree of AbstractMesh
  103982. */
  103983. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  103984. }
  103985. interface AbstractMesh {
  103986. /**
  103987. * @hidden
  103988. * Backing Field
  103989. */
  103990. _submeshesOctree: Octree<SubMesh>;
  103991. /**
  103992. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  103993. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  103994. * @param maxCapacity defines the maximum size of each block (64 by default)
  103995. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  103996. * @returns the new octree
  103997. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  103998. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103999. */
  104000. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  104001. }
  104002. /**
  104003. * Defines the octree scene component responsible to manage any octrees
  104004. * in a given scene.
  104005. */
  104006. export class OctreeSceneComponent {
  104007. /**
  104008. * The component name help to identify the component in the list of scene components.
  104009. */
  104010. readonly name: string;
  104011. /**
  104012. * The scene the component belongs to.
  104013. */
  104014. scene: Scene;
  104015. /**
  104016. * Indicates if the meshes have been checked to make sure they are isEnabled()
  104017. */
  104018. readonly checksIsEnabled: boolean;
  104019. /**
  104020. * Creates a new instance of the component for the given scene
  104021. * @param scene Defines the scene to register the component in
  104022. */
  104023. constructor(scene: Scene);
  104024. /**
  104025. * Registers the component in a given scene
  104026. */
  104027. register(): void;
  104028. /**
  104029. * Return the list of active meshes
  104030. * @returns the list of active meshes
  104031. */
  104032. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  104033. /**
  104034. * Return the list of active sub meshes
  104035. * @param mesh The mesh to get the candidates sub meshes from
  104036. * @returns the list of active sub meshes
  104037. */
  104038. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  104039. private _tempRay;
  104040. /**
  104041. * Return the list of sub meshes intersecting with a given local ray
  104042. * @param mesh defines the mesh to find the submesh for
  104043. * @param localRay defines the ray in local space
  104044. * @returns the list of intersecting sub meshes
  104045. */
  104046. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  104047. /**
  104048. * Return the list of sub meshes colliding with a collider
  104049. * @param mesh defines the mesh to find the submesh for
  104050. * @param collider defines the collider to evaluate the collision against
  104051. * @returns the list of colliding sub meshes
  104052. */
  104053. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  104054. /**
  104055. * Rebuilds the elements related to this component in case of
  104056. * context lost for instance.
  104057. */
  104058. rebuild(): void;
  104059. /**
  104060. * Disposes the component and the associated ressources.
  104061. */
  104062. dispose(): void;
  104063. }
  104064. }
  104065. declare module BABYLON {
  104066. /**
  104067. * Renders a layer on top of an existing scene
  104068. */
  104069. export class UtilityLayerRenderer implements IDisposable {
  104070. /** the original scene that will be rendered on top of */
  104071. originalScene: Scene;
  104072. private _pointerCaptures;
  104073. private _lastPointerEvents;
  104074. private static _DefaultUtilityLayer;
  104075. private static _DefaultKeepDepthUtilityLayer;
  104076. private _sharedGizmoLight;
  104077. private _renderCamera;
  104078. /**
  104079. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  104080. * @returns the camera that is used when rendering the utility layer
  104081. */
  104082. getRenderCamera(): Nullable<Camera>;
  104083. /**
  104084. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  104085. * @param cam the camera that should be used when rendering the utility layer
  104086. */
  104087. setRenderCamera(cam: Nullable<Camera>): void;
  104088. /**
  104089. * @hidden
  104090. * Light which used by gizmos to get light shading
  104091. */
  104092. _getSharedGizmoLight(): HemisphericLight;
  104093. /**
  104094. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  104095. */
  104096. pickUtilitySceneFirst: boolean;
  104097. /**
  104098. * 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)
  104099. */
  104100. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  104101. /**
  104102. * 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)
  104103. */
  104104. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  104105. /**
  104106. * The scene that is rendered on top of the original scene
  104107. */
  104108. utilityLayerScene: Scene;
  104109. /**
  104110. * If the utility layer should automatically be rendered on top of existing scene
  104111. */
  104112. shouldRender: boolean;
  104113. /**
  104114. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  104115. */
  104116. onlyCheckPointerDownEvents: boolean;
  104117. /**
  104118. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  104119. */
  104120. processAllEvents: boolean;
  104121. /**
  104122. * Observable raised when the pointer move from the utility layer scene to the main scene
  104123. */
  104124. onPointerOutObservable: Observable<number>;
  104125. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  104126. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  104127. private _afterRenderObserver;
  104128. private _sceneDisposeObserver;
  104129. private _originalPointerObserver;
  104130. /**
  104131. * Instantiates a UtilityLayerRenderer
  104132. * @param originalScene the original scene that will be rendered on top of
  104133. * @param handleEvents boolean indicating if the utility layer should handle events
  104134. */
  104135. constructor(
  104136. /** the original scene that will be rendered on top of */
  104137. originalScene: Scene, handleEvents?: boolean);
  104138. private _notifyObservers;
  104139. /**
  104140. * Renders the utility layers scene on top of the original scene
  104141. */
  104142. render(): void;
  104143. /**
  104144. * Disposes of the renderer
  104145. */
  104146. dispose(): void;
  104147. private _updateCamera;
  104148. }
  104149. }
  104150. declare module BABYLON {
  104151. /**
  104152. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  104153. */
  104154. export class Gizmo implements IDisposable {
  104155. /** The utility layer the gizmo will be added to */
  104156. gizmoLayer: UtilityLayerRenderer;
  104157. /**
  104158. * The root mesh of the gizmo
  104159. */
  104160. _rootMesh: Mesh;
  104161. private _attachedMesh;
  104162. /**
  104163. * Ratio for the scale of the gizmo (Default: 1)
  104164. */
  104165. scaleRatio: number;
  104166. /**
  104167. * If a custom mesh has been set (Default: false)
  104168. */
  104169. protected _customMeshSet: boolean;
  104170. /**
  104171. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  104172. * * When set, interactions will be enabled
  104173. */
  104174. attachedMesh: Nullable<AbstractMesh>;
  104175. /**
  104176. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  104177. * @param mesh The mesh to replace the default mesh of the gizmo
  104178. */
  104179. setCustomMesh(mesh: Mesh): void;
  104180. /**
  104181. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  104182. */
  104183. updateGizmoRotationToMatchAttachedMesh: boolean;
  104184. /**
  104185. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  104186. */
  104187. updateGizmoPositionToMatchAttachedMesh: boolean;
  104188. /**
  104189. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  104190. */
  104191. protected _updateScale: boolean;
  104192. protected _interactionsEnabled: boolean;
  104193. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  104194. private _beforeRenderObserver;
  104195. private _tempVector;
  104196. /**
  104197. * Creates a gizmo
  104198. * @param gizmoLayer The utility layer the gizmo will be added to
  104199. */
  104200. constructor(
  104201. /** The utility layer the gizmo will be added to */
  104202. gizmoLayer?: UtilityLayerRenderer);
  104203. /**
  104204. * Updates the gizmo to match the attached mesh's position/rotation
  104205. */
  104206. protected _update(): void;
  104207. /**
  104208. * Disposes of the gizmo
  104209. */
  104210. dispose(): void;
  104211. }
  104212. }
  104213. declare module BABYLON {
  104214. /**
  104215. * Single plane drag gizmo
  104216. */
  104217. export class PlaneDragGizmo extends Gizmo {
  104218. /**
  104219. * Drag behavior responsible for the gizmos dragging interactions
  104220. */
  104221. dragBehavior: PointerDragBehavior;
  104222. private _pointerObserver;
  104223. /**
  104224. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  104225. */
  104226. snapDistance: number;
  104227. /**
  104228. * Event that fires each time the gizmo snaps to a new location.
  104229. * * snapDistance is the the change in distance
  104230. */
  104231. onSnapObservable: Observable<{
  104232. snapDistance: number;
  104233. }>;
  104234. private _plane;
  104235. private _coloredMaterial;
  104236. private _hoverMaterial;
  104237. private _isEnabled;
  104238. private _parent;
  104239. /** @hidden */
  104240. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  104241. /** @hidden */
  104242. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  104243. /**
  104244. * Creates a PlaneDragGizmo
  104245. * @param gizmoLayer The utility layer the gizmo will be added to
  104246. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  104247. * @param color The color of the gizmo
  104248. */
  104249. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  104250. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  104251. /**
  104252. * If the gizmo is enabled
  104253. */
  104254. isEnabled: boolean;
  104255. /**
  104256. * Disposes of the gizmo
  104257. */
  104258. dispose(): void;
  104259. }
  104260. }
  104261. declare module BABYLON {
  104262. /**
  104263. * Gizmo that enables dragging a mesh along 3 axis
  104264. */
  104265. export class PositionGizmo extends Gizmo {
  104266. /**
  104267. * Internal gizmo used for interactions on the x axis
  104268. */
  104269. xGizmo: AxisDragGizmo;
  104270. /**
  104271. * Internal gizmo used for interactions on the y axis
  104272. */
  104273. yGizmo: AxisDragGizmo;
  104274. /**
  104275. * Internal gizmo used for interactions on the z axis
  104276. */
  104277. zGizmo: AxisDragGizmo;
  104278. /**
  104279. * Internal gizmo used for interactions on the yz plane
  104280. */
  104281. xPlaneGizmo: PlaneDragGizmo;
  104282. /**
  104283. * Internal gizmo used for interactions on the xz plane
  104284. */
  104285. yPlaneGizmo: PlaneDragGizmo;
  104286. /**
  104287. * Internal gizmo used for interactions on the xy plane
  104288. */
  104289. zPlaneGizmo: PlaneDragGizmo;
  104290. /**
  104291. * private variables
  104292. */
  104293. private _meshAttached;
  104294. private _updateGizmoRotationToMatchAttachedMesh;
  104295. private _snapDistance;
  104296. private _scaleRatio;
  104297. /** Fires an event when any of it's sub gizmos are dragged */
  104298. onDragStartObservable: Observable<unknown>;
  104299. /** Fires an event when any of it's sub gizmos are released from dragging */
  104300. onDragEndObservable: Observable<unknown>;
  104301. /**
  104302. * If set to true, planar drag is enabled
  104303. */
  104304. private _planarGizmoEnabled;
  104305. attachedMesh: Nullable<AbstractMesh>;
  104306. /**
  104307. * Creates a PositionGizmo
  104308. * @param gizmoLayer The utility layer the gizmo will be added to
  104309. */
  104310. constructor(gizmoLayer?: UtilityLayerRenderer);
  104311. /**
  104312. * If the planar drag gizmo is enabled
  104313. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  104314. */
  104315. planarGizmoEnabled: boolean;
  104316. updateGizmoRotationToMatchAttachedMesh: boolean;
  104317. /**
  104318. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  104319. */
  104320. snapDistance: number;
  104321. /**
  104322. * Ratio for the scale of the gizmo (Default: 1)
  104323. */
  104324. scaleRatio: number;
  104325. /**
  104326. * Disposes of the gizmo
  104327. */
  104328. dispose(): void;
  104329. /**
  104330. * CustomMeshes are not supported by this gizmo
  104331. * @param mesh The mesh to replace the default mesh of the gizmo
  104332. */
  104333. setCustomMesh(mesh: Mesh): void;
  104334. }
  104335. }
  104336. declare module BABYLON {
  104337. /**
  104338. * Single axis drag gizmo
  104339. */
  104340. export class AxisDragGizmo extends Gizmo {
  104341. /**
  104342. * Drag behavior responsible for the gizmos dragging interactions
  104343. */
  104344. dragBehavior: PointerDragBehavior;
  104345. private _pointerObserver;
  104346. /**
  104347. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  104348. */
  104349. snapDistance: number;
  104350. /**
  104351. * Event that fires each time the gizmo snaps to a new location.
  104352. * * snapDistance is the the change in distance
  104353. */
  104354. onSnapObservable: Observable<{
  104355. snapDistance: number;
  104356. }>;
  104357. private _isEnabled;
  104358. private _parent;
  104359. private _arrow;
  104360. private _coloredMaterial;
  104361. private _hoverMaterial;
  104362. /** @hidden */
  104363. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  104364. /** @hidden */
  104365. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  104366. /**
  104367. * Creates an AxisDragGizmo
  104368. * @param gizmoLayer The utility layer the gizmo will be added to
  104369. * @param dragAxis The axis which the gizmo will be able to drag on
  104370. * @param color The color of the gizmo
  104371. */
  104372. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  104373. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  104374. /**
  104375. * If the gizmo is enabled
  104376. */
  104377. isEnabled: boolean;
  104378. /**
  104379. * Disposes of the gizmo
  104380. */
  104381. dispose(): void;
  104382. }
  104383. }
  104384. declare module BABYLON.Debug {
  104385. /**
  104386. * The Axes viewer will show 3 axes in a specific point in space
  104387. */
  104388. export class AxesViewer {
  104389. private _xAxis;
  104390. private _yAxis;
  104391. private _zAxis;
  104392. private _scaleLinesFactor;
  104393. private _instanced;
  104394. /**
  104395. * Gets the hosting scene
  104396. */
  104397. scene: Scene;
  104398. /**
  104399. * Gets or sets a number used to scale line length
  104400. */
  104401. scaleLines: number;
  104402. /** Gets the node hierarchy used to render x-axis */
  104403. readonly xAxis: TransformNode;
  104404. /** Gets the node hierarchy used to render y-axis */
  104405. readonly yAxis: TransformNode;
  104406. /** Gets the node hierarchy used to render z-axis */
  104407. readonly zAxis: TransformNode;
  104408. /**
  104409. * Creates a new AxesViewer
  104410. * @param scene defines the hosting scene
  104411. * @param scaleLines defines a number used to scale line length (1 by default)
  104412. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  104413. * @param xAxis defines the node hierarchy used to render the x-axis
  104414. * @param yAxis defines the node hierarchy used to render the y-axis
  104415. * @param zAxis defines the node hierarchy used to render the z-axis
  104416. */
  104417. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  104418. /**
  104419. * Force the viewer to update
  104420. * @param position defines the position of the viewer
  104421. * @param xaxis defines the x axis of the viewer
  104422. * @param yaxis defines the y axis of the viewer
  104423. * @param zaxis defines the z axis of the viewer
  104424. */
  104425. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  104426. /**
  104427. * Creates an instance of this axes viewer.
  104428. * @returns a new axes viewer with instanced meshes
  104429. */
  104430. createInstance(): AxesViewer;
  104431. /** Releases resources */
  104432. dispose(): void;
  104433. private static _SetRenderingGroupId;
  104434. }
  104435. }
  104436. declare module BABYLON.Debug {
  104437. /**
  104438. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  104439. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  104440. */
  104441. export class BoneAxesViewer extends AxesViewer {
  104442. /**
  104443. * Gets or sets the target mesh where to display the axes viewer
  104444. */
  104445. mesh: Nullable<Mesh>;
  104446. /**
  104447. * Gets or sets the target bone where to display the axes viewer
  104448. */
  104449. bone: Nullable<Bone>;
  104450. /** Gets current position */
  104451. pos: Vector3;
  104452. /** Gets direction of X axis */
  104453. xaxis: Vector3;
  104454. /** Gets direction of Y axis */
  104455. yaxis: Vector3;
  104456. /** Gets direction of Z axis */
  104457. zaxis: Vector3;
  104458. /**
  104459. * Creates a new BoneAxesViewer
  104460. * @param scene defines the hosting scene
  104461. * @param bone defines the target bone
  104462. * @param mesh defines the target mesh
  104463. * @param scaleLines defines a scaling factor for line length (1 by default)
  104464. */
  104465. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  104466. /**
  104467. * Force the viewer to update
  104468. */
  104469. update(): void;
  104470. /** Releases resources */
  104471. dispose(): void;
  104472. }
  104473. }
  104474. declare module BABYLON {
  104475. /**
  104476. * Interface used to define scene explorer extensibility option
  104477. */
  104478. export interface IExplorerExtensibilityOption {
  104479. /**
  104480. * Define the option label
  104481. */
  104482. label: string;
  104483. /**
  104484. * Defines the action to execute on click
  104485. */
  104486. action: (entity: any) => void;
  104487. }
  104488. /**
  104489. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  104490. */
  104491. export interface IExplorerExtensibilityGroup {
  104492. /**
  104493. * Defines a predicate to test if a given type mut be extended
  104494. */
  104495. predicate: (entity: any) => boolean;
  104496. /**
  104497. * Gets the list of options added to a type
  104498. */
  104499. entries: IExplorerExtensibilityOption[];
  104500. }
  104501. /**
  104502. * Interface used to define the options to use to create the Inspector
  104503. */
  104504. export interface IInspectorOptions {
  104505. /**
  104506. * Display in overlay mode (default: false)
  104507. */
  104508. overlay?: boolean;
  104509. /**
  104510. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  104511. */
  104512. globalRoot?: HTMLElement;
  104513. /**
  104514. * Display the Scene explorer
  104515. */
  104516. showExplorer?: boolean;
  104517. /**
  104518. * Display the property inspector
  104519. */
  104520. showInspector?: boolean;
  104521. /**
  104522. * Display in embed mode (both panes on the right)
  104523. */
  104524. embedMode?: boolean;
  104525. /**
  104526. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  104527. */
  104528. handleResize?: boolean;
  104529. /**
  104530. * Allow the panes to popup (default: true)
  104531. */
  104532. enablePopup?: boolean;
  104533. /**
  104534. * Allow the panes to be closed by users (default: true)
  104535. */
  104536. enableClose?: boolean;
  104537. /**
  104538. * Optional list of extensibility entries
  104539. */
  104540. explorerExtensibility?: IExplorerExtensibilityGroup[];
  104541. /**
  104542. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  104543. */
  104544. inspectorURL?: string;
  104545. }
  104546. interface Scene {
  104547. /**
  104548. * @hidden
  104549. * Backing field
  104550. */
  104551. _debugLayer: DebugLayer;
  104552. /**
  104553. * Gets the debug layer (aka Inspector) associated with the scene
  104554. * @see http://doc.babylonjs.com/features/playground_debuglayer
  104555. */
  104556. debugLayer: DebugLayer;
  104557. }
  104558. /**
  104559. * The debug layer (aka Inspector) is the go to tool in order to better understand
  104560. * what is happening in your scene
  104561. * @see http://doc.babylonjs.com/features/playground_debuglayer
  104562. */
  104563. export class DebugLayer {
  104564. /**
  104565. * Define the url to get the inspector script from.
  104566. * By default it uses the babylonjs CDN.
  104567. * @ignoreNaming
  104568. */
  104569. static InspectorURL: string;
  104570. private _scene;
  104571. private BJSINSPECTOR;
  104572. private _onPropertyChangedObservable?;
  104573. /**
  104574. * Observable triggered when a property is changed through the inspector.
  104575. */
  104576. readonly onPropertyChangedObservable: any;
  104577. /**
  104578. * Instantiates a new debug layer.
  104579. * The debug layer (aka Inspector) is the go to tool in order to better understand
  104580. * what is happening in your scene
  104581. * @see http://doc.babylonjs.com/features/playground_debuglayer
  104582. * @param scene Defines the scene to inspect
  104583. */
  104584. constructor(scene: Scene);
  104585. /** Creates the inspector window. */
  104586. private _createInspector;
  104587. /**
  104588. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  104589. * @param entity defines the entity to select
  104590. * @param lineContainerTitle defines the specific block to highlight
  104591. */
  104592. select(entity: any, lineContainerTitle?: string): void;
  104593. /** Get the inspector from bundle or global */
  104594. private _getGlobalInspector;
  104595. /**
  104596. * Get if the inspector is visible or not.
  104597. * @returns true if visible otherwise, false
  104598. */
  104599. isVisible(): boolean;
  104600. /**
  104601. * Hide the inspector and close its window.
  104602. */
  104603. hide(): void;
  104604. /**
  104605. * Launch the debugLayer.
  104606. * @param config Define the configuration of the inspector
  104607. * @return a promise fulfilled when the debug layer is visible
  104608. */
  104609. show(config?: IInspectorOptions): Promise<DebugLayer>;
  104610. }
  104611. }
  104612. declare module BABYLON {
  104613. /**
  104614. * Class containing static functions to help procedurally build meshes
  104615. */
  104616. export class BoxBuilder {
  104617. /**
  104618. * Creates a box mesh
  104619. * * The parameter `size` sets the size (float) of each box side (default 1)
  104620. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  104621. * * 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)
  104622. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  104623. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104624. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104625. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104626. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  104627. * @param name defines the name of the mesh
  104628. * @param options defines the options used to create the mesh
  104629. * @param scene defines the hosting scene
  104630. * @returns the box mesh
  104631. */
  104632. static CreateBox(name: string, options: {
  104633. size?: number;
  104634. width?: number;
  104635. height?: number;
  104636. depth?: number;
  104637. faceUV?: Vector4[];
  104638. faceColors?: Color4[];
  104639. sideOrientation?: number;
  104640. frontUVs?: Vector4;
  104641. backUVs?: Vector4;
  104642. wrap?: boolean;
  104643. topBaseAt?: number;
  104644. bottomBaseAt?: number;
  104645. updatable?: boolean;
  104646. }, scene?: Nullable<Scene>): Mesh;
  104647. }
  104648. }
  104649. declare module BABYLON {
  104650. /**
  104651. * Class containing static functions to help procedurally build meshes
  104652. */
  104653. export class SphereBuilder {
  104654. /**
  104655. * Creates a sphere mesh
  104656. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  104657. * * 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`)
  104658. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  104659. * * 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
  104660. * * 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)
  104661. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104662. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104664. * @param name defines the name of the mesh
  104665. * @param options defines the options used to create the mesh
  104666. * @param scene defines the hosting scene
  104667. * @returns the sphere mesh
  104668. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  104669. */
  104670. static CreateSphere(name: string, options: {
  104671. segments?: number;
  104672. diameter?: number;
  104673. diameterX?: number;
  104674. diameterY?: number;
  104675. diameterZ?: number;
  104676. arc?: number;
  104677. slice?: number;
  104678. sideOrientation?: number;
  104679. frontUVs?: Vector4;
  104680. backUVs?: Vector4;
  104681. updatable?: boolean;
  104682. }, scene: any): Mesh;
  104683. }
  104684. }
  104685. declare module BABYLON.Debug {
  104686. /**
  104687. * Used to show the physics impostor around the specific mesh
  104688. */
  104689. export class PhysicsViewer {
  104690. /** @hidden */
  104691. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  104692. /** @hidden */
  104693. protected _meshes: Array<Nullable<AbstractMesh>>;
  104694. /** @hidden */
  104695. protected _scene: Nullable<Scene>;
  104696. /** @hidden */
  104697. protected _numMeshes: number;
  104698. /** @hidden */
  104699. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  104700. private _renderFunction;
  104701. private _utilityLayer;
  104702. private _debugBoxMesh;
  104703. private _debugSphereMesh;
  104704. private _debugCylinderMesh;
  104705. private _debugMaterial;
  104706. private _debugMeshMeshes;
  104707. /**
  104708. * Creates a new PhysicsViewer
  104709. * @param scene defines the hosting scene
  104710. */
  104711. constructor(scene: Scene);
  104712. /** @hidden */
  104713. protected _updateDebugMeshes(): void;
  104714. /**
  104715. * Renders a specified physic impostor
  104716. * @param impostor defines the impostor to render
  104717. * @param targetMesh defines the mesh represented by the impostor
  104718. * @returns the new debug mesh used to render the impostor
  104719. */
  104720. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  104721. /**
  104722. * Hides a specified physic impostor
  104723. * @param impostor defines the impostor to hide
  104724. */
  104725. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  104726. private _getDebugMaterial;
  104727. private _getDebugBoxMesh;
  104728. private _getDebugSphereMesh;
  104729. private _getDebugCylinderMesh;
  104730. private _getDebugMeshMesh;
  104731. private _getDebugMesh;
  104732. /** Releases all resources */
  104733. dispose(): void;
  104734. }
  104735. }
  104736. declare module BABYLON {
  104737. /**
  104738. * Class containing static functions to help procedurally build meshes
  104739. */
  104740. export class LinesBuilder {
  104741. /**
  104742. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  104743. * * 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
  104744. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  104745. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  104746. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  104747. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  104748. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  104749. * * 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
  104750. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  104751. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104752. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  104753. * @param name defines the name of the new line system
  104754. * @param options defines the options used to create the line system
  104755. * @param scene defines the hosting scene
  104756. * @returns a new line system mesh
  104757. */
  104758. static CreateLineSystem(name: string, options: {
  104759. lines: Vector3[][];
  104760. updatable?: boolean;
  104761. instance?: Nullable<LinesMesh>;
  104762. colors?: Nullable<Color4[][]>;
  104763. useVertexAlpha?: boolean;
  104764. }, scene: Nullable<Scene>): LinesMesh;
  104765. /**
  104766. * Creates a line mesh
  104767. * 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
  104768. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  104769. * * The parameter `points` is an array successive Vector3
  104770. * * 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
  104771. * * The optional parameter `colors` is an array of successive Color4, one per line point
  104772. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  104773. * * When updating an instance, remember that only point positions can change, not the number of points
  104774. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104775. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  104776. * @param name defines the name of the new line system
  104777. * @param options defines the options used to create the line system
  104778. * @param scene defines the hosting scene
  104779. * @returns a new line mesh
  104780. */
  104781. static CreateLines(name: string, options: {
  104782. points: Vector3[];
  104783. updatable?: boolean;
  104784. instance?: Nullable<LinesMesh>;
  104785. colors?: Color4[];
  104786. useVertexAlpha?: boolean;
  104787. }, scene?: Nullable<Scene>): LinesMesh;
  104788. /**
  104789. * Creates a dashed line mesh
  104790. * * 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
  104791. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  104792. * * The parameter `points` is an array successive Vector3
  104793. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  104794. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  104795. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  104796. * * 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
  104797. * * When updating an instance, remember that only point positions can change, not the number of points
  104798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104799. * @param name defines the name of the mesh
  104800. * @param options defines the options used to create the mesh
  104801. * @param scene defines the hosting scene
  104802. * @returns the dashed line mesh
  104803. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  104804. */
  104805. static CreateDashedLines(name: string, options: {
  104806. points: Vector3[];
  104807. dashSize?: number;
  104808. gapSize?: number;
  104809. dashNb?: number;
  104810. updatable?: boolean;
  104811. instance?: LinesMesh;
  104812. }, scene?: Nullable<Scene>): LinesMesh;
  104813. }
  104814. }
  104815. declare module BABYLON {
  104816. /**
  104817. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  104818. * in order to better appreciate the issue one might have.
  104819. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  104820. */
  104821. export class RayHelper {
  104822. /**
  104823. * Defines the ray we are currently tryin to visualize.
  104824. */
  104825. ray: Nullable<Ray>;
  104826. private _renderPoints;
  104827. private _renderLine;
  104828. private _renderFunction;
  104829. private _scene;
  104830. private _updateToMeshFunction;
  104831. private _attachedToMesh;
  104832. private _meshSpaceDirection;
  104833. private _meshSpaceOrigin;
  104834. /**
  104835. * Helper function to create a colored helper in a scene in one line.
  104836. * @param ray Defines the ray we are currently tryin to visualize
  104837. * @param scene Defines the scene the ray is used in
  104838. * @param color Defines the color we want to see the ray in
  104839. * @returns The newly created ray helper.
  104840. */
  104841. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  104842. /**
  104843. * Instantiate a new ray helper.
  104844. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  104845. * in order to better appreciate the issue one might have.
  104846. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  104847. * @param ray Defines the ray we are currently tryin to visualize
  104848. */
  104849. constructor(ray: Ray);
  104850. /**
  104851. * Shows the ray we are willing to debug.
  104852. * @param scene Defines the scene the ray needs to be rendered in
  104853. * @param color Defines the color the ray needs to be rendered in
  104854. */
  104855. show(scene: Scene, color?: Color3): void;
  104856. /**
  104857. * Hides the ray we are debugging.
  104858. */
  104859. hide(): void;
  104860. private _render;
  104861. /**
  104862. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  104863. * @param mesh Defines the mesh we want the helper attached to
  104864. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  104865. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  104866. * @param length Defines the length of the ray
  104867. */
  104868. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  104869. /**
  104870. * Detach the ray helper from the mesh it has previously been attached to.
  104871. */
  104872. detachFromMesh(): void;
  104873. private _updateToMesh;
  104874. /**
  104875. * Dispose the helper and release its associated resources.
  104876. */
  104877. dispose(): void;
  104878. }
  104879. }
  104880. declare module BABYLON.Debug {
  104881. /**
  104882. * Class used to render a debug view of a given skeleton
  104883. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  104884. */
  104885. export class SkeletonViewer {
  104886. /** defines the skeleton to render */
  104887. skeleton: Skeleton;
  104888. /** defines the mesh attached to the skeleton */
  104889. mesh: AbstractMesh;
  104890. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  104891. autoUpdateBonesMatrices: boolean;
  104892. /** defines the rendering group id to use with the viewer */
  104893. renderingGroupId: number;
  104894. /** Gets or sets the color used to render the skeleton */
  104895. color: Color3;
  104896. private _scene;
  104897. private _debugLines;
  104898. private _debugMesh;
  104899. private _isEnabled;
  104900. private _renderFunction;
  104901. private _utilityLayer;
  104902. /**
  104903. * Returns the mesh used to render the bones
  104904. */
  104905. readonly debugMesh: Nullable<LinesMesh>;
  104906. /**
  104907. * Creates a new SkeletonViewer
  104908. * @param skeleton defines the skeleton to render
  104909. * @param mesh defines the mesh attached to the skeleton
  104910. * @param scene defines the hosting scene
  104911. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  104912. * @param renderingGroupId defines the rendering group id to use with the viewer
  104913. */
  104914. constructor(
  104915. /** defines the skeleton to render */
  104916. skeleton: Skeleton,
  104917. /** defines the mesh attached to the skeleton */
  104918. mesh: AbstractMesh, scene: Scene,
  104919. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  104920. autoUpdateBonesMatrices?: boolean,
  104921. /** defines the rendering group id to use with the viewer */
  104922. renderingGroupId?: number);
  104923. /** Gets or sets a boolean indicating if the viewer is enabled */
  104924. isEnabled: boolean;
  104925. private _getBonePosition;
  104926. private _getLinesForBonesWithLength;
  104927. private _getLinesForBonesNoLength;
  104928. /** Update the viewer to sync with current skeleton state */
  104929. update(): void;
  104930. /** Release associated resources */
  104931. dispose(): void;
  104932. }
  104933. }
  104934. declare module BABYLON {
  104935. /**
  104936. * Options to create the null engine
  104937. */
  104938. export class NullEngineOptions {
  104939. /**
  104940. * Render width (Default: 512)
  104941. */
  104942. renderWidth: number;
  104943. /**
  104944. * Render height (Default: 256)
  104945. */
  104946. renderHeight: number;
  104947. /**
  104948. * Texture size (Default: 512)
  104949. */
  104950. textureSize: number;
  104951. /**
  104952. * If delta time between frames should be constant
  104953. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104954. */
  104955. deterministicLockstep: boolean;
  104956. /**
  104957. * Maximum about of steps between frames (Default: 4)
  104958. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104959. */
  104960. lockstepMaxSteps: number;
  104961. }
  104962. /**
  104963. * The null engine class provides support for headless version of babylon.js.
  104964. * This can be used in server side scenario or for testing purposes
  104965. */
  104966. export class NullEngine extends Engine {
  104967. private _options;
  104968. /**
  104969. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104970. */
  104971. isDeterministicLockStep(): boolean;
  104972. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  104973. getLockstepMaxSteps(): number;
  104974. /**
  104975. * Sets hardware scaling, used to save performance if needed
  104976. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  104977. */
  104978. getHardwareScalingLevel(): number;
  104979. constructor(options?: NullEngineOptions);
  104980. createVertexBuffer(vertices: FloatArray): DataBuffer;
  104981. createIndexBuffer(indices: IndicesArray): DataBuffer;
  104982. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  104983. getRenderWidth(useScreen?: boolean): number;
  104984. getRenderHeight(useScreen?: boolean): number;
  104985. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  104986. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  104987. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  104988. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  104989. bindSamplers(effect: Effect): void;
  104990. enableEffect(effect: Effect): void;
  104991. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  104992. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  104993. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  104994. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  104995. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  104996. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  104997. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  104998. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  104999. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  105000. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  105001. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  105002. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  105003. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  105004. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  105005. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  105006. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  105007. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  105008. setFloat(uniform: WebGLUniformLocation, value: number): void;
  105009. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  105010. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  105011. setBool(uniform: WebGLUniformLocation, bool: number): void;
  105012. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  105013. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  105014. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  105015. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  105016. bindBuffers(vertexBuffers: {
  105017. [key: string]: VertexBuffer;
  105018. }, indexBuffer: DataBuffer, effect: Effect): void;
  105019. wipeCaches(bruteForce?: boolean): void;
  105020. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  105021. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  105022. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  105023. /** @hidden */
  105024. _createTexture(): WebGLTexture;
  105025. /** @hidden */
  105026. _releaseTexture(texture: InternalTexture): void;
  105027. 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;
  105028. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  105029. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  105030. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  105031. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  105032. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  105033. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  105034. areAllEffectsReady(): boolean;
  105035. /**
  105036. * @hidden
  105037. * Get the current error code of the webGL context
  105038. * @returns the error code
  105039. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  105040. */
  105041. getError(): number;
  105042. /** @hidden */
  105043. _getUnpackAlignement(): number;
  105044. /** @hidden */
  105045. _unpackFlipY(value: boolean): void;
  105046. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  105047. /**
  105048. * Updates a dynamic vertex buffer.
  105049. * @param vertexBuffer the vertex buffer to update
  105050. * @param data the data used to update the vertex buffer
  105051. * @param byteOffset the byte offset of the data (optional)
  105052. * @param byteLength the byte length of the data (optional)
  105053. */
  105054. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  105055. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  105056. /** @hidden */
  105057. _bindTexture(channel: number, texture: InternalTexture): void;
  105058. /** @hidden */
  105059. _releaseBuffer(buffer: DataBuffer): boolean;
  105060. releaseEffects(): void;
  105061. displayLoadingUI(): void;
  105062. hideLoadingUI(): void;
  105063. /** @hidden */
  105064. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105065. /** @hidden */
  105066. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105067. /** @hidden */
  105068. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105069. /** @hidden */
  105070. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  105071. }
  105072. }
  105073. declare module BABYLON {
  105074. /** @hidden */
  105075. export class _OcclusionDataStorage {
  105076. /** @hidden */
  105077. occlusionInternalRetryCounter: number;
  105078. /** @hidden */
  105079. isOcclusionQueryInProgress: boolean;
  105080. /** @hidden */
  105081. isOccluded: boolean;
  105082. /** @hidden */
  105083. occlusionRetryCount: number;
  105084. /** @hidden */
  105085. occlusionType: number;
  105086. /** @hidden */
  105087. occlusionQueryAlgorithmType: number;
  105088. }
  105089. interface Engine {
  105090. /**
  105091. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  105092. * @return the new query
  105093. */
  105094. createQuery(): WebGLQuery;
  105095. /**
  105096. * Delete and release a webGL query
  105097. * @param query defines the query to delete
  105098. * @return the current engine
  105099. */
  105100. deleteQuery(query: WebGLQuery): Engine;
  105101. /**
  105102. * Check if a given query has resolved and got its value
  105103. * @param query defines the query to check
  105104. * @returns true if the query got its value
  105105. */
  105106. isQueryResultAvailable(query: WebGLQuery): boolean;
  105107. /**
  105108. * Gets the value of a given query
  105109. * @param query defines the query to check
  105110. * @returns the value of the query
  105111. */
  105112. getQueryResult(query: WebGLQuery): number;
  105113. /**
  105114. * Initiates an occlusion query
  105115. * @param algorithmType defines the algorithm to use
  105116. * @param query defines the query to use
  105117. * @returns the current engine
  105118. * @see http://doc.babylonjs.com/features/occlusionquery
  105119. */
  105120. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  105121. /**
  105122. * Ends an occlusion query
  105123. * @see http://doc.babylonjs.com/features/occlusionquery
  105124. * @param algorithmType defines the algorithm to use
  105125. * @returns the current engine
  105126. */
  105127. endOcclusionQuery(algorithmType: number): Engine;
  105128. /**
  105129. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  105130. * Please note that only one query can be issued at a time
  105131. * @returns a time token used to track the time span
  105132. */
  105133. startTimeQuery(): Nullable<_TimeToken>;
  105134. /**
  105135. * Ends a time query
  105136. * @param token defines the token used to measure the time span
  105137. * @returns the time spent (in ns)
  105138. */
  105139. endTimeQuery(token: _TimeToken): int;
  105140. /** @hidden */
  105141. _currentNonTimestampToken: Nullable<_TimeToken>;
  105142. /** @hidden */
  105143. _createTimeQuery(): WebGLQuery;
  105144. /** @hidden */
  105145. _deleteTimeQuery(query: WebGLQuery): void;
  105146. /** @hidden */
  105147. _getGlAlgorithmType(algorithmType: number): number;
  105148. /** @hidden */
  105149. _getTimeQueryResult(query: WebGLQuery): any;
  105150. /** @hidden */
  105151. _getTimeQueryAvailability(query: WebGLQuery): any;
  105152. }
  105153. interface AbstractMesh {
  105154. /**
  105155. * Backing filed
  105156. * @hidden
  105157. */
  105158. __occlusionDataStorage: _OcclusionDataStorage;
  105159. /**
  105160. * Access property
  105161. * @hidden
  105162. */
  105163. _occlusionDataStorage: _OcclusionDataStorage;
  105164. /**
  105165. * 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.
  105166. * The default value is -1 which means don't break the query and wait till the result
  105167. * @see http://doc.babylonjs.com/features/occlusionquery
  105168. */
  105169. occlusionRetryCount: number;
  105170. /**
  105171. * 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:
  105172. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  105173. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  105174. * * 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.
  105175. * @see http://doc.babylonjs.com/features/occlusionquery
  105176. */
  105177. occlusionType: number;
  105178. /**
  105179. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  105180. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  105181. * * 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.
  105182. * @see http://doc.babylonjs.com/features/occlusionquery
  105183. */
  105184. occlusionQueryAlgorithmType: number;
  105185. /**
  105186. * 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
  105187. * @see http://doc.babylonjs.com/features/occlusionquery
  105188. */
  105189. isOccluded: boolean;
  105190. /**
  105191. * Flag to check the progress status of the query
  105192. * @see http://doc.babylonjs.com/features/occlusionquery
  105193. */
  105194. isOcclusionQueryInProgress: boolean;
  105195. }
  105196. }
  105197. declare module BABYLON {
  105198. /** @hidden */
  105199. export var _forceTransformFeedbackToBundle: boolean;
  105200. interface Engine {
  105201. /**
  105202. * Creates a webGL transform feedback object
  105203. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  105204. * @returns the webGL transform feedback object
  105205. */
  105206. createTransformFeedback(): WebGLTransformFeedback;
  105207. /**
  105208. * Delete a webGL transform feedback object
  105209. * @param value defines the webGL transform feedback object to delete
  105210. */
  105211. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  105212. /**
  105213. * Bind a webGL transform feedback object to the webgl context
  105214. * @param value defines the webGL transform feedback object to bind
  105215. */
  105216. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  105217. /**
  105218. * Begins a transform feedback operation
  105219. * @param usePoints defines if points or triangles must be used
  105220. */
  105221. beginTransformFeedback(usePoints: boolean): void;
  105222. /**
  105223. * Ends a transform feedback operation
  105224. */
  105225. endTransformFeedback(): void;
  105226. /**
  105227. * Specify the varyings to use with transform feedback
  105228. * @param program defines the associated webGL program
  105229. * @param value defines the list of strings representing the varying names
  105230. */
  105231. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  105232. /**
  105233. * Bind a webGL buffer for a transform feedback operation
  105234. * @param value defines the webGL buffer to bind
  105235. */
  105236. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  105237. }
  105238. }
  105239. declare module BABYLON {
  105240. /**
  105241. * Creation options of the multi render target texture.
  105242. */
  105243. export interface IMultiRenderTargetOptions {
  105244. /**
  105245. * Define if the texture needs to create mip maps after render.
  105246. */
  105247. generateMipMaps?: boolean;
  105248. /**
  105249. * Define the types of all the draw buffers we want to create
  105250. */
  105251. types?: number[];
  105252. /**
  105253. * Define the sampling modes of all the draw buffers we want to create
  105254. */
  105255. samplingModes?: number[];
  105256. /**
  105257. * Define if a depth buffer is required
  105258. */
  105259. generateDepthBuffer?: boolean;
  105260. /**
  105261. * Define if a stencil buffer is required
  105262. */
  105263. generateStencilBuffer?: boolean;
  105264. /**
  105265. * Define if a depth texture is required instead of a depth buffer
  105266. */
  105267. generateDepthTexture?: boolean;
  105268. /**
  105269. * Define the number of desired draw buffers
  105270. */
  105271. textureCount?: number;
  105272. /**
  105273. * Define if aspect ratio should be adapted to the texture or stay the scene one
  105274. */
  105275. doNotChangeAspectRatio?: boolean;
  105276. /**
  105277. * Define the default type of the buffers we are creating
  105278. */
  105279. defaultType?: number;
  105280. }
  105281. /**
  105282. * A multi render target, like a render target provides the ability to render to a texture.
  105283. * Unlike the render target, it can render to several draw buffers in one draw.
  105284. * This is specially interesting in deferred rendering or for any effects requiring more than
  105285. * just one color from a single pass.
  105286. */
  105287. export class MultiRenderTarget extends RenderTargetTexture {
  105288. private _internalTextures;
  105289. private _textures;
  105290. private _multiRenderTargetOptions;
  105291. /**
  105292. * Get if draw buffers are currently supported by the used hardware and browser.
  105293. */
  105294. readonly isSupported: boolean;
  105295. /**
  105296. * Get the list of textures generated by the multi render target.
  105297. */
  105298. readonly textures: Texture[];
  105299. /**
  105300. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  105301. */
  105302. readonly depthTexture: Texture;
  105303. /**
  105304. * Set the wrapping mode on U of all the textures we are rendering to.
  105305. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  105306. */
  105307. wrapU: number;
  105308. /**
  105309. * Set the wrapping mode on V of all the textures we are rendering to.
  105310. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  105311. */
  105312. wrapV: number;
  105313. /**
  105314. * Instantiate a new multi render target texture.
  105315. * A multi render target, like a render target provides the ability to render to a texture.
  105316. * Unlike the render target, it can render to several draw buffers in one draw.
  105317. * This is specially interesting in deferred rendering or for any effects requiring more than
  105318. * just one color from a single pass.
  105319. * @param name Define the name of the texture
  105320. * @param size Define the size of the buffers to render to
  105321. * @param count Define the number of target we are rendering into
  105322. * @param scene Define the scene the texture belongs to
  105323. * @param options Define the options used to create the multi render target
  105324. */
  105325. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  105326. /** @hidden */
  105327. _rebuild(): void;
  105328. private _createInternalTextures;
  105329. private _createTextures;
  105330. /**
  105331. * Define the number of samples used if MSAA is enabled.
  105332. */
  105333. samples: number;
  105334. /**
  105335. * Resize all the textures in the multi render target.
  105336. * Be carrefull as it will recreate all the data in the new texture.
  105337. * @param size Define the new size
  105338. */
  105339. resize(size: any): void;
  105340. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  105341. /**
  105342. * Dispose the render targets and their associated resources
  105343. */
  105344. dispose(): void;
  105345. /**
  105346. * Release all the underlying texture used as draw buffers.
  105347. */
  105348. releaseInternalTextures(): void;
  105349. }
  105350. }
  105351. declare module BABYLON {
  105352. interface Engine {
  105353. /**
  105354. * Unbind a list of render target textures from the webGL context
  105355. * This is used only when drawBuffer extension or webGL2 are active
  105356. * @param textures defines the render target textures to unbind
  105357. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  105358. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  105359. */
  105360. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  105361. /**
  105362. * Create a multi render target texture
  105363. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  105364. * @param size defines the size of the texture
  105365. * @param options defines the creation options
  105366. * @returns the cube texture as an InternalTexture
  105367. */
  105368. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  105369. /**
  105370. * Update the sample count for a given multiple render target texture
  105371. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  105372. * @param textures defines the textures to update
  105373. * @param samples defines the sample count to set
  105374. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  105375. */
  105376. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  105377. }
  105378. }
  105379. declare module BABYLON {
  105380. /**
  105381. * Gather the list of clipboard event types as constants.
  105382. */
  105383. export class ClipboardEventTypes {
  105384. /**
  105385. * The clipboard event is fired when a copy command is active (pressed).
  105386. */
  105387. static readonly COPY: number;
  105388. /**
  105389. * The clipboard event is fired when a cut command is active (pressed).
  105390. */
  105391. static readonly CUT: number;
  105392. /**
  105393. * The clipboard event is fired when a paste command is active (pressed).
  105394. */
  105395. static readonly PASTE: number;
  105396. }
  105397. /**
  105398. * This class is used to store clipboard related info for the onClipboardObservable event.
  105399. */
  105400. export class ClipboardInfo {
  105401. /**
  105402. * Defines the type of event (BABYLON.ClipboardEventTypes)
  105403. */
  105404. type: number;
  105405. /**
  105406. * Defines the related dom event
  105407. */
  105408. event: ClipboardEvent;
  105409. /**
  105410. *Creates an instance of ClipboardInfo.
  105411. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  105412. * @param event Defines the related dom event
  105413. */
  105414. constructor(
  105415. /**
  105416. * Defines the type of event (BABYLON.ClipboardEventTypes)
  105417. */
  105418. type: number,
  105419. /**
  105420. * Defines the related dom event
  105421. */
  105422. event: ClipboardEvent);
  105423. /**
  105424. * Get the clipboard event's type from the keycode.
  105425. * @param keyCode Defines the keyCode for the current keyboard event.
  105426. * @return {number}
  105427. */
  105428. static GetTypeFromCharacter(keyCode: number): number;
  105429. }
  105430. }
  105431. declare module BABYLON {
  105432. /**
  105433. * Class used to represent data loading progression
  105434. */
  105435. export class SceneLoaderProgressEvent {
  105436. /** defines if data length to load can be evaluated */
  105437. readonly lengthComputable: boolean;
  105438. /** defines the loaded data length */
  105439. readonly loaded: number;
  105440. /** defines the data length to load */
  105441. readonly total: number;
  105442. /**
  105443. * Create a new progress event
  105444. * @param lengthComputable defines if data length to load can be evaluated
  105445. * @param loaded defines the loaded data length
  105446. * @param total defines the data length to load
  105447. */
  105448. constructor(
  105449. /** defines if data length to load can be evaluated */
  105450. lengthComputable: boolean,
  105451. /** defines the loaded data length */
  105452. loaded: number,
  105453. /** defines the data length to load */
  105454. total: number);
  105455. /**
  105456. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  105457. * @param event defines the source event
  105458. * @returns a new SceneLoaderProgressEvent
  105459. */
  105460. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  105461. }
  105462. /**
  105463. * Interface used by SceneLoader plugins to define supported file extensions
  105464. */
  105465. export interface ISceneLoaderPluginExtensions {
  105466. /**
  105467. * Defines the list of supported extensions
  105468. */
  105469. [extension: string]: {
  105470. isBinary: boolean;
  105471. };
  105472. }
  105473. /**
  105474. * Interface used by SceneLoader plugin factory
  105475. */
  105476. export interface ISceneLoaderPluginFactory {
  105477. /**
  105478. * Defines the name of the factory
  105479. */
  105480. name: string;
  105481. /**
  105482. * Function called to create a new plugin
  105483. * @return the new plugin
  105484. */
  105485. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  105486. /**
  105487. * Boolean indicating if the plugin can direct load specific data
  105488. */
  105489. canDirectLoad?: (data: string) => boolean;
  105490. }
  105491. /**
  105492. * Interface used to define a SceneLoader plugin
  105493. */
  105494. export interface ISceneLoaderPlugin {
  105495. /**
  105496. * The friendly name of this plugin.
  105497. */
  105498. name: string;
  105499. /**
  105500. * The file extensions supported by this plugin.
  105501. */
  105502. extensions: string | ISceneLoaderPluginExtensions;
  105503. /**
  105504. * Import meshes into a scene.
  105505. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105506. * @param scene The scene to import into
  105507. * @param data The data to import
  105508. * @param rootUrl The root url for scene and resources
  105509. * @param meshes The meshes array to import into
  105510. * @param particleSystems The particle systems array to import into
  105511. * @param skeletons The skeletons array to import into
  105512. * @param onError The callback when import fails
  105513. * @returns True if successful or false otherwise
  105514. */
  105515. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  105516. /**
  105517. * Load into a scene.
  105518. * @param scene The scene to load into
  105519. * @param data The data to import
  105520. * @param rootUrl The root url for scene and resources
  105521. * @param onError The callback when import fails
  105522. * @returns true if successful or false otherwise
  105523. */
  105524. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  105525. /**
  105526. * The callback that returns true if the data can be directly loaded.
  105527. */
  105528. canDirectLoad?: (data: string) => boolean;
  105529. /**
  105530. * The callback that allows custom handling of the root url based on the response url.
  105531. */
  105532. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  105533. /**
  105534. * Load into an asset container.
  105535. * @param scene The scene to load into
  105536. * @param data The data to import
  105537. * @param rootUrl The root url for scene and resources
  105538. * @param onError The callback when import fails
  105539. * @returns The loaded asset container
  105540. */
  105541. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  105542. }
  105543. /**
  105544. * Interface used to define an async SceneLoader plugin
  105545. */
  105546. export interface ISceneLoaderPluginAsync {
  105547. /**
  105548. * The friendly name of this plugin.
  105549. */
  105550. name: string;
  105551. /**
  105552. * The file extensions supported by this plugin.
  105553. */
  105554. extensions: string | ISceneLoaderPluginExtensions;
  105555. /**
  105556. * Import meshes into a scene.
  105557. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105558. * @param scene The scene to import into
  105559. * @param data The data to import
  105560. * @param rootUrl The root url for scene and resources
  105561. * @param onProgress The callback when the load progresses
  105562. * @param fileName Defines the name of the file to load
  105563. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  105564. */
  105565. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  105566. meshes: AbstractMesh[];
  105567. particleSystems: IParticleSystem[];
  105568. skeletons: Skeleton[];
  105569. animationGroups: AnimationGroup[];
  105570. }>;
  105571. /**
  105572. * Load into a scene.
  105573. * @param scene The scene to load into
  105574. * @param data The data to import
  105575. * @param rootUrl The root url for scene and resources
  105576. * @param onProgress The callback when the load progresses
  105577. * @param fileName Defines the name of the file to load
  105578. * @returns Nothing
  105579. */
  105580. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  105581. /**
  105582. * The callback that returns true if the data can be directly loaded.
  105583. */
  105584. canDirectLoad?: (data: string) => boolean;
  105585. /**
  105586. * The callback that allows custom handling of the root url based on the response url.
  105587. */
  105588. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  105589. /**
  105590. * Load into an asset container.
  105591. * @param scene The scene to load into
  105592. * @param data The data to import
  105593. * @param rootUrl The root url for scene and resources
  105594. * @param onProgress The callback when the load progresses
  105595. * @param fileName Defines the name of the file to load
  105596. * @returns The loaded asset container
  105597. */
  105598. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  105599. }
  105600. /**
  105601. * Class used to load scene from various file formats using registered plugins
  105602. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  105603. */
  105604. export class SceneLoader {
  105605. /**
  105606. * No logging while loading
  105607. */
  105608. static readonly NO_LOGGING: number;
  105609. /**
  105610. * Minimal logging while loading
  105611. */
  105612. static readonly MINIMAL_LOGGING: number;
  105613. /**
  105614. * Summary logging while loading
  105615. */
  105616. static readonly SUMMARY_LOGGING: number;
  105617. /**
  105618. * Detailled logging while loading
  105619. */
  105620. static readonly DETAILED_LOGGING: number;
  105621. /**
  105622. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  105623. */
  105624. static ForceFullSceneLoadingForIncremental: boolean;
  105625. /**
  105626. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  105627. */
  105628. static ShowLoadingScreen: boolean;
  105629. /**
  105630. * Defines the current logging level (while loading the scene)
  105631. * @ignorenaming
  105632. */
  105633. static loggingLevel: number;
  105634. /**
  105635. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  105636. */
  105637. static CleanBoneMatrixWeights: boolean;
  105638. /**
  105639. * Event raised when a plugin is used to load a scene
  105640. */
  105641. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  105642. private static _registeredPlugins;
  105643. private static _getDefaultPlugin;
  105644. private static _getPluginForExtension;
  105645. private static _getPluginForDirectLoad;
  105646. private static _getPluginForFilename;
  105647. private static _getDirectLoad;
  105648. private static _loadData;
  105649. private static _getFileInfo;
  105650. /**
  105651. * Gets a plugin that can load the given extension
  105652. * @param extension defines the extension to load
  105653. * @returns a plugin or null if none works
  105654. */
  105655. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  105656. /**
  105657. * Gets a boolean indicating that the given extension can be loaded
  105658. * @param extension defines the extension to load
  105659. * @returns true if the extension is supported
  105660. */
  105661. static IsPluginForExtensionAvailable(extension: string): boolean;
  105662. /**
  105663. * Adds a new plugin to the list of registered plugins
  105664. * @param plugin defines the plugin to add
  105665. */
  105666. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  105667. /**
  105668. * Import meshes into a scene
  105669. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105670. * @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)
  105671. * @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)
  105672. * @param scene the instance of BABYLON.Scene to append to
  105673. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  105674. * @param onProgress a callback with a progress event for each file being loaded
  105675. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105676. * @param pluginExtension the extension used to determine the plugin
  105677. * @returns The loaded plugin
  105678. */
  105679. 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>;
  105680. /**
  105681. * Import meshes into a scene
  105682. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105683. * @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)
  105684. * @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)
  105685. * @param scene the instance of BABYLON.Scene to append to
  105686. * @param onProgress a callback with a progress event for each file being loaded
  105687. * @param pluginExtension the extension used to determine the plugin
  105688. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  105689. */
  105690. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  105691. meshes: AbstractMesh[];
  105692. particleSystems: IParticleSystem[];
  105693. skeletons: Skeleton[];
  105694. animationGroups: AnimationGroup[];
  105695. }>;
  105696. /**
  105697. * Load a scene
  105698. * @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)
  105699. * @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)
  105700. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105701. * @param onSuccess a callback with the scene when import succeeds
  105702. * @param onProgress a callback with a progress event for each file being loaded
  105703. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105704. * @param pluginExtension the extension used to determine the plugin
  105705. * @returns The loaded plugin
  105706. */
  105707. 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>;
  105708. /**
  105709. * Load a scene
  105710. * @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)
  105711. * @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)
  105712. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105713. * @param onProgress a callback with a progress event for each file being loaded
  105714. * @param pluginExtension the extension used to determine the plugin
  105715. * @returns The loaded scene
  105716. */
  105717. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105718. /**
  105719. * Append a scene
  105720. * @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)
  105721. * @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)
  105722. * @param scene is the instance of BABYLON.Scene to append to
  105723. * @param onSuccess a callback with the scene when import succeeds
  105724. * @param onProgress a callback with a progress event for each file being loaded
  105725. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105726. * @param pluginExtension the extension used to determine the plugin
  105727. * @returns The loaded plugin
  105728. */
  105729. 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>;
  105730. /**
  105731. * Append a scene
  105732. * @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)
  105733. * @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)
  105734. * @param scene is the instance of BABYLON.Scene to append to
  105735. * @param onProgress a callback with a progress event for each file being loaded
  105736. * @param pluginExtension the extension used to determine the plugin
  105737. * @returns The given scene
  105738. */
  105739. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105740. /**
  105741. * Load a scene into an asset container
  105742. * @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)
  105743. * @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)
  105744. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  105745. * @param onSuccess a callback with the scene when import succeeds
  105746. * @param onProgress a callback with a progress event for each file being loaded
  105747. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105748. * @param pluginExtension the extension used to determine the plugin
  105749. * @returns The loaded plugin
  105750. */
  105751. 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>;
  105752. /**
  105753. * Load a scene into an asset container
  105754. * @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)
  105755. * @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)
  105756. * @param scene is the instance of Scene to append to
  105757. * @param onProgress a callback with a progress event for each file being loaded
  105758. * @param pluginExtension the extension used to determine the plugin
  105759. * @returns The loaded asset container
  105760. */
  105761. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  105762. }
  105763. }
  105764. declare module BABYLON {
  105765. /**
  105766. * Google Daydream controller
  105767. */
  105768. export class DaydreamController extends WebVRController {
  105769. /**
  105770. * Base Url for the controller model.
  105771. */
  105772. static MODEL_BASE_URL: string;
  105773. /**
  105774. * File name for the controller model.
  105775. */
  105776. static MODEL_FILENAME: string;
  105777. /**
  105778. * Gamepad Id prefix used to identify Daydream Controller.
  105779. */
  105780. static readonly GAMEPAD_ID_PREFIX: string;
  105781. /**
  105782. * Creates a new DaydreamController from a gamepad
  105783. * @param vrGamepad the gamepad that the controller should be created from
  105784. */
  105785. constructor(vrGamepad: any);
  105786. /**
  105787. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105788. * @param scene scene in which to add meshes
  105789. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105790. */
  105791. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105792. /**
  105793. * Called once for each button that changed state since the last frame
  105794. * @param buttonIdx Which button index changed
  105795. * @param state New state of the button
  105796. * @param changes Which properties on the state changed since last frame
  105797. */
  105798. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105799. }
  105800. }
  105801. declare module BABYLON {
  105802. /**
  105803. * Gear VR Controller
  105804. */
  105805. export class GearVRController extends WebVRController {
  105806. /**
  105807. * Base Url for the controller model.
  105808. */
  105809. static MODEL_BASE_URL: string;
  105810. /**
  105811. * File name for the controller model.
  105812. */
  105813. static MODEL_FILENAME: string;
  105814. /**
  105815. * Gamepad Id prefix used to identify this controller.
  105816. */
  105817. static readonly GAMEPAD_ID_PREFIX: string;
  105818. private readonly _buttonIndexToObservableNameMap;
  105819. /**
  105820. * Creates a new GearVRController from a gamepad
  105821. * @param vrGamepad the gamepad that the controller should be created from
  105822. */
  105823. constructor(vrGamepad: any);
  105824. /**
  105825. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105826. * @param scene scene in which to add meshes
  105827. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105828. */
  105829. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105830. /**
  105831. * Called once for each button that changed state since the last frame
  105832. * @param buttonIdx Which button index changed
  105833. * @param state New state of the button
  105834. * @param changes Which properties on the state changed since last frame
  105835. */
  105836. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105837. }
  105838. }
  105839. declare module BABYLON {
  105840. /**
  105841. * Generic Controller
  105842. */
  105843. export class GenericController extends WebVRController {
  105844. /**
  105845. * Base Url for the controller model.
  105846. */
  105847. static readonly MODEL_BASE_URL: string;
  105848. /**
  105849. * File name for the controller model.
  105850. */
  105851. static readonly MODEL_FILENAME: string;
  105852. /**
  105853. * Creates a new GenericController from a gamepad
  105854. * @param vrGamepad the gamepad that the controller should be created from
  105855. */
  105856. constructor(vrGamepad: any);
  105857. /**
  105858. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105859. * @param scene scene in which to add meshes
  105860. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105861. */
  105862. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105863. /**
  105864. * Called once for each button that changed state since the last frame
  105865. * @param buttonIdx Which button index changed
  105866. * @param state New state of the button
  105867. * @param changes Which properties on the state changed since last frame
  105868. */
  105869. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105870. }
  105871. }
  105872. declare module BABYLON {
  105873. /**
  105874. * Oculus Touch Controller
  105875. */
  105876. export class OculusTouchController extends WebVRController {
  105877. /**
  105878. * Base Url for the controller model.
  105879. */
  105880. static MODEL_BASE_URL: string;
  105881. /**
  105882. * File name for the left controller model.
  105883. */
  105884. static MODEL_LEFT_FILENAME: string;
  105885. /**
  105886. * File name for the right controller model.
  105887. */
  105888. static MODEL_RIGHT_FILENAME: string;
  105889. /**
  105890. * Base Url for the Quest controller model.
  105891. */
  105892. static QUEST_MODEL_BASE_URL: string;
  105893. /**
  105894. * @hidden
  105895. * If the controllers are running on a device that needs the updated Quest controller models
  105896. */
  105897. static _IsQuest: boolean;
  105898. /**
  105899. * Fired when the secondary trigger on this controller is modified
  105900. */
  105901. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  105902. /**
  105903. * Fired when the thumb rest on this controller is modified
  105904. */
  105905. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  105906. /**
  105907. * Creates a new OculusTouchController from a gamepad
  105908. * @param vrGamepad the gamepad that the controller should be created from
  105909. */
  105910. constructor(vrGamepad: any);
  105911. /**
  105912. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105913. * @param scene scene in which to add meshes
  105914. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105915. */
  105916. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105917. /**
  105918. * Fired when the A button on this controller is modified
  105919. */
  105920. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105921. /**
  105922. * Fired when the B button on this controller is modified
  105923. */
  105924. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105925. /**
  105926. * Fired when the X button on this controller is modified
  105927. */
  105928. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105929. /**
  105930. * Fired when the Y button on this controller is modified
  105931. */
  105932. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105933. /**
  105934. * Called once for each button that changed state since the last frame
  105935. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  105936. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  105937. * 2) secondary trigger (same)
  105938. * 3) A (right) X (left), touch, pressed = value
  105939. * 4) B / Y
  105940. * 5) thumb rest
  105941. * @param buttonIdx Which button index changed
  105942. * @param state New state of the button
  105943. * @param changes Which properties on the state changed since last frame
  105944. */
  105945. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105946. }
  105947. }
  105948. declare module BABYLON {
  105949. /**
  105950. * Vive Controller
  105951. */
  105952. export class ViveController extends WebVRController {
  105953. /**
  105954. * Base Url for the controller model.
  105955. */
  105956. static MODEL_BASE_URL: string;
  105957. /**
  105958. * File name for the controller model.
  105959. */
  105960. static MODEL_FILENAME: string;
  105961. /**
  105962. * Creates a new ViveController from a gamepad
  105963. * @param vrGamepad the gamepad that the controller should be created from
  105964. */
  105965. constructor(vrGamepad: any);
  105966. /**
  105967. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105968. * @param scene scene in which to add meshes
  105969. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105970. */
  105971. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105972. /**
  105973. * Fired when the left button on this controller is modified
  105974. */
  105975. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105976. /**
  105977. * Fired when the right button on this controller is modified
  105978. */
  105979. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105980. /**
  105981. * Fired when the menu button on this controller is modified
  105982. */
  105983. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105984. /**
  105985. * Called once for each button that changed state since the last frame
  105986. * Vive mapping:
  105987. * 0: touchpad
  105988. * 1: trigger
  105989. * 2: left AND right buttons
  105990. * 3: menu button
  105991. * @param buttonIdx Which button index changed
  105992. * @param state New state of the button
  105993. * @param changes Which properties on the state changed since last frame
  105994. */
  105995. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105996. }
  105997. }
  105998. declare module BABYLON {
  105999. /**
  106000. * Defines the WindowsMotionController object that the state of the windows motion controller
  106001. */
  106002. export class WindowsMotionController extends WebVRController {
  106003. /**
  106004. * The base url used to load the left and right controller models
  106005. */
  106006. static MODEL_BASE_URL: string;
  106007. /**
  106008. * The name of the left controller model file
  106009. */
  106010. static MODEL_LEFT_FILENAME: string;
  106011. /**
  106012. * The name of the right controller model file
  106013. */
  106014. static MODEL_RIGHT_FILENAME: string;
  106015. /**
  106016. * The controller name prefix for this controller type
  106017. */
  106018. static readonly GAMEPAD_ID_PREFIX: string;
  106019. /**
  106020. * The controller id pattern for this controller type
  106021. */
  106022. private static readonly GAMEPAD_ID_PATTERN;
  106023. private _loadedMeshInfo;
  106024. private readonly _mapping;
  106025. /**
  106026. * Fired when the trackpad on this controller is clicked
  106027. */
  106028. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  106029. /**
  106030. * Fired when the trackpad on this controller is modified
  106031. */
  106032. onTrackpadValuesChangedObservable: Observable<StickValues>;
  106033. /**
  106034. * The current x and y values of this controller's trackpad
  106035. */
  106036. trackpad: StickValues;
  106037. /**
  106038. * Creates a new WindowsMotionController from a gamepad
  106039. * @param vrGamepad the gamepad that the controller should be created from
  106040. */
  106041. constructor(vrGamepad: any);
  106042. /**
  106043. * Fired when the trigger on this controller is modified
  106044. */
  106045. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106046. /**
  106047. * Fired when the menu button on this controller is modified
  106048. */
  106049. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106050. /**
  106051. * Fired when the grip button on this controller is modified
  106052. */
  106053. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106054. /**
  106055. * Fired when the thumbstick button on this controller is modified
  106056. */
  106057. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106058. /**
  106059. * Fired when the touchpad button on this controller is modified
  106060. */
  106061. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106062. /**
  106063. * Fired when the touchpad values on this controller are modified
  106064. */
  106065. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  106066. private _updateTrackpad;
  106067. /**
  106068. * Called once per frame by the engine.
  106069. */
  106070. update(): void;
  106071. /**
  106072. * Called once for each button that changed state since the last frame
  106073. * @param buttonIdx Which button index changed
  106074. * @param state New state of the button
  106075. * @param changes Which properties on the state changed since last frame
  106076. */
  106077. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106078. /**
  106079. * Moves the buttons on the controller mesh based on their current state
  106080. * @param buttonName the name of the button to move
  106081. * @param buttonValue the value of the button which determines the buttons new position
  106082. */
  106083. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  106084. /**
  106085. * Moves the axis on the controller mesh based on its current state
  106086. * @param axis the index of the axis
  106087. * @param axisValue the value of the axis which determines the meshes new position
  106088. * @hidden
  106089. */
  106090. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  106091. /**
  106092. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106093. * @param scene scene in which to add meshes
  106094. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106095. */
  106096. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  106097. /**
  106098. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  106099. * can be transformed by button presses and axes values, based on this._mapping.
  106100. *
  106101. * @param scene scene in which the meshes exist
  106102. * @param meshes list of meshes that make up the controller model to process
  106103. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  106104. */
  106105. private processModel;
  106106. private createMeshInfo;
  106107. /**
  106108. * Gets the ray of the controller in the direction the controller is pointing
  106109. * @param length the length the resulting ray should be
  106110. * @returns a ray in the direction the controller is pointing
  106111. */
  106112. getForwardRay(length?: number): Ray;
  106113. /**
  106114. * Disposes of the controller
  106115. */
  106116. dispose(): void;
  106117. }
  106118. }
  106119. declare module BABYLON {
  106120. /**
  106121. * Class containing static functions to help procedurally build meshes
  106122. */
  106123. export class PolyhedronBuilder {
  106124. /**
  106125. * Creates a polyhedron mesh
  106126. * * 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
  106127. * * The parameter `size` (positive float, default 1) sets the polygon size
  106128. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  106129. * * 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`
  106130. * * 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
  106131. * * 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)`)
  106132. * * 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
  106133. * * 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
  106134. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106135. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106137. * @param name defines the name of the mesh
  106138. * @param options defines the options used to create the mesh
  106139. * @param scene defines the hosting scene
  106140. * @returns the polyhedron mesh
  106141. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  106142. */
  106143. static CreatePolyhedron(name: string, options: {
  106144. type?: number;
  106145. size?: number;
  106146. sizeX?: number;
  106147. sizeY?: number;
  106148. sizeZ?: number;
  106149. custom?: any;
  106150. faceUV?: Vector4[];
  106151. faceColors?: Color4[];
  106152. flat?: boolean;
  106153. updatable?: boolean;
  106154. sideOrientation?: number;
  106155. frontUVs?: Vector4;
  106156. backUVs?: Vector4;
  106157. }, scene?: Nullable<Scene>): Mesh;
  106158. }
  106159. }
  106160. declare module BABYLON {
  106161. /**
  106162. * Gizmo that enables scaling a mesh along 3 axis
  106163. */
  106164. export class ScaleGizmo extends Gizmo {
  106165. /**
  106166. * Internal gizmo used for interactions on the x axis
  106167. */
  106168. xGizmo: AxisScaleGizmo;
  106169. /**
  106170. * Internal gizmo used for interactions on the y axis
  106171. */
  106172. yGizmo: AxisScaleGizmo;
  106173. /**
  106174. * Internal gizmo used for interactions on the z axis
  106175. */
  106176. zGizmo: AxisScaleGizmo;
  106177. /**
  106178. * Internal gizmo used to scale all axis equally
  106179. */
  106180. uniformScaleGizmo: AxisScaleGizmo;
  106181. private _meshAttached;
  106182. private _updateGizmoRotationToMatchAttachedMesh;
  106183. private _snapDistance;
  106184. private _scaleRatio;
  106185. private _uniformScalingMesh;
  106186. private _octahedron;
  106187. /** Fires an event when any of it's sub gizmos are dragged */
  106188. onDragStartObservable: Observable<unknown>;
  106189. /** Fires an event when any of it's sub gizmos are released from dragging */
  106190. onDragEndObservable: Observable<unknown>;
  106191. attachedMesh: Nullable<AbstractMesh>;
  106192. /**
  106193. * Creates a ScaleGizmo
  106194. * @param gizmoLayer The utility layer the gizmo will be added to
  106195. */
  106196. constructor(gizmoLayer?: UtilityLayerRenderer);
  106197. updateGizmoRotationToMatchAttachedMesh: boolean;
  106198. /**
  106199. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106200. */
  106201. snapDistance: number;
  106202. /**
  106203. * Ratio for the scale of the gizmo (Default: 1)
  106204. */
  106205. scaleRatio: number;
  106206. /**
  106207. * Disposes of the gizmo
  106208. */
  106209. dispose(): void;
  106210. }
  106211. }
  106212. declare module BABYLON {
  106213. /**
  106214. * Single axis scale gizmo
  106215. */
  106216. export class AxisScaleGizmo extends Gizmo {
  106217. /**
  106218. * Drag behavior responsible for the gizmos dragging interactions
  106219. */
  106220. dragBehavior: PointerDragBehavior;
  106221. private _pointerObserver;
  106222. /**
  106223. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106224. */
  106225. snapDistance: number;
  106226. /**
  106227. * Event that fires each time the gizmo snaps to a new location.
  106228. * * snapDistance is the the change in distance
  106229. */
  106230. onSnapObservable: Observable<{
  106231. snapDistance: number;
  106232. }>;
  106233. /**
  106234. * If the scaling operation should be done on all axis (default: false)
  106235. */
  106236. uniformScaling: boolean;
  106237. private _isEnabled;
  106238. private _parent;
  106239. private _arrow;
  106240. private _coloredMaterial;
  106241. private _hoverMaterial;
  106242. /**
  106243. * Creates an AxisScaleGizmo
  106244. * @param gizmoLayer The utility layer the gizmo will be added to
  106245. * @param dragAxis The axis which the gizmo will be able to scale on
  106246. * @param color The color of the gizmo
  106247. */
  106248. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  106249. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106250. /**
  106251. * If the gizmo is enabled
  106252. */
  106253. isEnabled: boolean;
  106254. /**
  106255. * Disposes of the gizmo
  106256. */
  106257. dispose(): void;
  106258. /**
  106259. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  106260. * @param mesh The mesh to replace the default mesh of the gizmo
  106261. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  106262. */
  106263. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  106264. }
  106265. }
  106266. declare module BABYLON {
  106267. /**
  106268. * Bounding box gizmo
  106269. */
  106270. export class BoundingBoxGizmo extends Gizmo {
  106271. private _lineBoundingBox;
  106272. private _rotateSpheresParent;
  106273. private _scaleBoxesParent;
  106274. private _boundingDimensions;
  106275. private _renderObserver;
  106276. private _pointerObserver;
  106277. private _scaleDragSpeed;
  106278. private _tmpQuaternion;
  106279. private _tmpVector;
  106280. private _tmpRotationMatrix;
  106281. /**
  106282. * 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)
  106283. */
  106284. ignoreChildren: boolean;
  106285. /**
  106286. * 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)
  106287. */
  106288. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  106289. /**
  106290. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  106291. */
  106292. rotationSphereSize: number;
  106293. /**
  106294. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  106295. */
  106296. scaleBoxSize: number;
  106297. /**
  106298. * 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)
  106299. */
  106300. fixedDragMeshScreenSize: boolean;
  106301. /**
  106302. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  106303. */
  106304. fixedDragMeshScreenSizeDistanceFactor: number;
  106305. /**
  106306. * Fired when a rotation sphere or scale box is dragged
  106307. */
  106308. onDragStartObservable: Observable<{}>;
  106309. /**
  106310. * Fired when a scale box is dragged
  106311. */
  106312. onScaleBoxDragObservable: Observable<{}>;
  106313. /**
  106314. * Fired when a scale box drag is ended
  106315. */
  106316. onScaleBoxDragEndObservable: Observable<{}>;
  106317. /**
  106318. * Fired when a rotation sphere is dragged
  106319. */
  106320. onRotationSphereDragObservable: Observable<{}>;
  106321. /**
  106322. * Fired when a rotation sphere drag is ended
  106323. */
  106324. onRotationSphereDragEndObservable: Observable<{}>;
  106325. /**
  106326. * 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)
  106327. */
  106328. scalePivot: Nullable<Vector3>;
  106329. /**
  106330. * Mesh used as a pivot to rotate the attached mesh
  106331. */
  106332. private _anchorMesh;
  106333. private _existingMeshScale;
  106334. private _dragMesh;
  106335. private pointerDragBehavior;
  106336. private coloredMaterial;
  106337. private hoverColoredMaterial;
  106338. /**
  106339. * Sets the color of the bounding box gizmo
  106340. * @param color the color to set
  106341. */
  106342. setColor(color: Color3): void;
  106343. /**
  106344. * Creates an BoundingBoxGizmo
  106345. * @param gizmoLayer The utility layer the gizmo will be added to
  106346. * @param color The color of the gizmo
  106347. */
  106348. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  106349. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106350. private _selectNode;
  106351. /**
  106352. * Updates the bounding box information for the Gizmo
  106353. */
  106354. updateBoundingBox(): void;
  106355. private _updateRotationSpheres;
  106356. private _updateScaleBoxes;
  106357. /**
  106358. * Enables rotation on the specified axis and disables rotation on the others
  106359. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  106360. */
  106361. setEnabledRotationAxis(axis: string): void;
  106362. /**
  106363. * Enables/disables scaling
  106364. * @param enable if scaling should be enabled
  106365. */
  106366. setEnabledScaling(enable: boolean): void;
  106367. private _updateDummy;
  106368. /**
  106369. * Enables a pointer drag behavior on the bounding box of the gizmo
  106370. */
  106371. enableDragBehavior(): void;
  106372. /**
  106373. * Disposes of the gizmo
  106374. */
  106375. dispose(): void;
  106376. /**
  106377. * 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)
  106378. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  106379. * @returns the bounding box mesh with the passed in mesh as a child
  106380. */
  106381. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  106382. /**
  106383. * CustomMeshes are not supported by this gizmo
  106384. * @param mesh The mesh to replace the default mesh of the gizmo
  106385. */
  106386. setCustomMesh(mesh: Mesh): void;
  106387. }
  106388. }
  106389. declare module BABYLON {
  106390. /**
  106391. * Single plane rotation gizmo
  106392. */
  106393. export class PlaneRotationGizmo extends Gizmo {
  106394. /**
  106395. * Drag behavior responsible for the gizmos dragging interactions
  106396. */
  106397. dragBehavior: PointerDragBehavior;
  106398. private _pointerObserver;
  106399. /**
  106400. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  106401. */
  106402. snapDistance: number;
  106403. /**
  106404. * Event that fires each time the gizmo snaps to a new location.
  106405. * * snapDistance is the the change in distance
  106406. */
  106407. onSnapObservable: Observable<{
  106408. snapDistance: number;
  106409. }>;
  106410. private _isEnabled;
  106411. private _parent;
  106412. /**
  106413. * Creates a PlaneRotationGizmo
  106414. * @param gizmoLayer The utility layer the gizmo will be added to
  106415. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  106416. * @param color The color of the gizmo
  106417. * @param tessellation Amount of tessellation to be used when creating rotation circles
  106418. */
  106419. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  106420. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106421. /**
  106422. * If the gizmo is enabled
  106423. */
  106424. isEnabled: boolean;
  106425. /**
  106426. * Disposes of the gizmo
  106427. */
  106428. dispose(): void;
  106429. }
  106430. }
  106431. declare module BABYLON {
  106432. /**
  106433. * Gizmo that enables rotating a mesh along 3 axis
  106434. */
  106435. export class RotationGizmo extends Gizmo {
  106436. /**
  106437. * Internal gizmo used for interactions on the x axis
  106438. */
  106439. xGizmo: PlaneRotationGizmo;
  106440. /**
  106441. * Internal gizmo used for interactions on the y axis
  106442. */
  106443. yGizmo: PlaneRotationGizmo;
  106444. /**
  106445. * Internal gizmo used for interactions on the z axis
  106446. */
  106447. zGizmo: PlaneRotationGizmo;
  106448. /** Fires an event when any of it's sub gizmos are dragged */
  106449. onDragStartObservable: Observable<unknown>;
  106450. /** Fires an event when any of it's sub gizmos are released from dragging */
  106451. onDragEndObservable: Observable<unknown>;
  106452. private _meshAttached;
  106453. attachedMesh: Nullable<AbstractMesh>;
  106454. /**
  106455. * Creates a RotationGizmo
  106456. * @param gizmoLayer The utility layer the gizmo will be added to
  106457. * @param tessellation Amount of tessellation to be used when creating rotation circles
  106458. */
  106459. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  106460. updateGizmoRotationToMatchAttachedMesh: boolean;
  106461. /**
  106462. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106463. */
  106464. snapDistance: number;
  106465. /**
  106466. * Ratio for the scale of the gizmo (Default: 1)
  106467. */
  106468. scaleRatio: number;
  106469. /**
  106470. * Disposes of the gizmo
  106471. */
  106472. dispose(): void;
  106473. /**
  106474. * CustomMeshes are not supported by this gizmo
  106475. * @param mesh The mesh to replace the default mesh of the gizmo
  106476. */
  106477. setCustomMesh(mesh: Mesh): void;
  106478. }
  106479. }
  106480. declare module BABYLON {
  106481. /**
  106482. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  106483. */
  106484. export class GizmoManager implements IDisposable {
  106485. private scene;
  106486. /**
  106487. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  106488. */
  106489. gizmos: {
  106490. positionGizmo: Nullable<PositionGizmo>;
  106491. rotationGizmo: Nullable<RotationGizmo>;
  106492. scaleGizmo: Nullable<ScaleGizmo>;
  106493. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  106494. };
  106495. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  106496. clearGizmoOnEmptyPointerEvent: boolean;
  106497. /** Fires an event when the manager is attached to a mesh */
  106498. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  106499. private _gizmosEnabled;
  106500. private _pointerObserver;
  106501. private _attachedMesh;
  106502. private _boundingBoxColor;
  106503. private _defaultUtilityLayer;
  106504. private _defaultKeepDepthUtilityLayer;
  106505. /**
  106506. * When bounding box gizmo is enabled, this can be used to track drag/end events
  106507. */
  106508. boundingBoxDragBehavior: SixDofDragBehavior;
  106509. /**
  106510. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  106511. */
  106512. attachableMeshes: Nullable<Array<AbstractMesh>>;
  106513. /**
  106514. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  106515. */
  106516. usePointerToAttachGizmos: boolean;
  106517. /**
  106518. * Utility layer that the bounding box gizmo belongs to
  106519. */
  106520. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  106521. /**
  106522. * Utility layer that all gizmos besides bounding box belong to
  106523. */
  106524. readonly utilityLayer: UtilityLayerRenderer;
  106525. /**
  106526. * Instatiates a gizmo manager
  106527. * @param scene the scene to overlay the gizmos on top of
  106528. */
  106529. constructor(scene: Scene);
  106530. /**
  106531. * Attaches a set of gizmos to the specified mesh
  106532. * @param mesh The mesh the gizmo's should be attached to
  106533. */
  106534. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  106535. /**
  106536. * If the position gizmo is enabled
  106537. */
  106538. positionGizmoEnabled: boolean;
  106539. /**
  106540. * If the rotation gizmo is enabled
  106541. */
  106542. rotationGizmoEnabled: boolean;
  106543. /**
  106544. * If the scale gizmo is enabled
  106545. */
  106546. scaleGizmoEnabled: boolean;
  106547. /**
  106548. * If the boundingBox gizmo is enabled
  106549. */
  106550. boundingBoxGizmoEnabled: boolean;
  106551. /**
  106552. * Disposes of the gizmo manager
  106553. */
  106554. dispose(): void;
  106555. }
  106556. }
  106557. declare module BABYLON {
  106558. /**
  106559. * A directional light is defined by a direction (what a surprise!).
  106560. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  106561. * 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.
  106562. * Documentation: https://doc.babylonjs.com/babylon101/lights
  106563. */
  106564. export class DirectionalLight extends ShadowLight {
  106565. private _shadowFrustumSize;
  106566. /**
  106567. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  106568. */
  106569. /**
  106570. * Specifies a fix frustum size for the shadow generation.
  106571. */
  106572. shadowFrustumSize: number;
  106573. private _shadowOrthoScale;
  106574. /**
  106575. * Gets the shadow projection scale against the optimal computed one.
  106576. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  106577. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  106578. */
  106579. /**
  106580. * Sets the shadow projection scale against the optimal computed one.
  106581. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  106582. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  106583. */
  106584. shadowOrthoScale: number;
  106585. /**
  106586. * Automatically compute the projection matrix to best fit (including all the casters)
  106587. * on each frame.
  106588. */
  106589. autoUpdateExtends: boolean;
  106590. private _orthoLeft;
  106591. private _orthoRight;
  106592. private _orthoTop;
  106593. private _orthoBottom;
  106594. /**
  106595. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  106596. * The directional light is emitted from everywhere in the given direction.
  106597. * It can cast shadows.
  106598. * Documentation : https://doc.babylonjs.com/babylon101/lights
  106599. * @param name The friendly name of the light
  106600. * @param direction The direction of the light
  106601. * @param scene The scene the light belongs to
  106602. */
  106603. constructor(name: string, direction: Vector3, scene: Scene);
  106604. /**
  106605. * Returns the string "DirectionalLight".
  106606. * @return The class name
  106607. */
  106608. getClassName(): string;
  106609. /**
  106610. * Returns the integer 1.
  106611. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  106612. */
  106613. getTypeID(): number;
  106614. /**
  106615. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  106616. * Returns the DirectionalLight Shadow projection matrix.
  106617. */
  106618. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106619. /**
  106620. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  106621. * Returns the DirectionalLight Shadow projection matrix.
  106622. */
  106623. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  106624. /**
  106625. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  106626. * Returns the DirectionalLight Shadow projection matrix.
  106627. */
  106628. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106629. protected _buildUniformLayout(): void;
  106630. /**
  106631. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  106632. * @param effect The effect to update
  106633. * @param lightIndex The index of the light in the effect to update
  106634. * @returns The directional light
  106635. */
  106636. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  106637. /**
  106638. * Gets the minZ used for shadow according to both the scene and the light.
  106639. *
  106640. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  106641. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  106642. * @param activeCamera The camera we are returning the min for
  106643. * @returns the depth min z
  106644. */
  106645. getDepthMinZ(activeCamera: Camera): number;
  106646. /**
  106647. * Gets the maxZ used for shadow according to both the scene and the light.
  106648. *
  106649. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  106650. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  106651. * @param activeCamera The camera we are returning the max for
  106652. * @returns the depth max z
  106653. */
  106654. getDepthMaxZ(activeCamera: Camera): number;
  106655. /**
  106656. * Prepares the list of defines specific to the light type.
  106657. * @param defines the list of defines
  106658. * @param lightIndex defines the index of the light for the effect
  106659. */
  106660. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  106661. }
  106662. }
  106663. declare module BABYLON {
  106664. /**
  106665. * Class containing static functions to help procedurally build meshes
  106666. */
  106667. export class HemisphereBuilder {
  106668. /**
  106669. * Creates a hemisphere mesh
  106670. * @param name defines the name of the mesh
  106671. * @param options defines the options used to create the mesh
  106672. * @param scene defines the hosting scene
  106673. * @returns the hemisphere mesh
  106674. */
  106675. static CreateHemisphere(name: string, options: {
  106676. segments?: number;
  106677. diameter?: number;
  106678. sideOrientation?: number;
  106679. }, scene: any): Mesh;
  106680. }
  106681. }
  106682. declare module BABYLON {
  106683. /**
  106684. * A spot light is defined by a position, a direction, an angle, and an exponent.
  106685. * These values define a cone of light starting from the position, emitting toward the direction.
  106686. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  106687. * and the exponent defines the speed of the decay of the light with distance (reach).
  106688. * Documentation: https://doc.babylonjs.com/babylon101/lights
  106689. */
  106690. export class SpotLight extends ShadowLight {
  106691. private _angle;
  106692. private _innerAngle;
  106693. private _cosHalfAngle;
  106694. private _lightAngleScale;
  106695. private _lightAngleOffset;
  106696. /**
  106697. * Gets the cone angle of the spot light in Radians.
  106698. */
  106699. /**
  106700. * Sets the cone angle of the spot light in Radians.
  106701. */
  106702. angle: number;
  106703. /**
  106704. * Only used in gltf falloff mode, this defines the angle where
  106705. * the directional falloff will start before cutting at angle which could be seen
  106706. * as outer angle.
  106707. */
  106708. /**
  106709. * Only used in gltf falloff mode, this defines the angle where
  106710. * the directional falloff will start before cutting at angle which could be seen
  106711. * as outer angle.
  106712. */
  106713. innerAngle: number;
  106714. private _shadowAngleScale;
  106715. /**
  106716. * Allows scaling the angle of the light for shadow generation only.
  106717. */
  106718. /**
  106719. * Allows scaling the angle of the light for shadow generation only.
  106720. */
  106721. shadowAngleScale: number;
  106722. /**
  106723. * The light decay speed with the distance from the emission spot.
  106724. */
  106725. exponent: number;
  106726. private _projectionTextureMatrix;
  106727. /**
  106728. * Allows reading the projecton texture
  106729. */
  106730. readonly projectionTextureMatrix: Matrix;
  106731. protected _projectionTextureLightNear: number;
  106732. /**
  106733. * Gets the near clip of the Spotlight for texture projection.
  106734. */
  106735. /**
  106736. * Sets the near clip of the Spotlight for texture projection.
  106737. */
  106738. projectionTextureLightNear: number;
  106739. protected _projectionTextureLightFar: number;
  106740. /**
  106741. * Gets the far clip of the Spotlight for texture projection.
  106742. */
  106743. /**
  106744. * Sets the far clip of the Spotlight for texture projection.
  106745. */
  106746. projectionTextureLightFar: number;
  106747. protected _projectionTextureUpDirection: Vector3;
  106748. /**
  106749. * Gets the Up vector of the Spotlight for texture projection.
  106750. */
  106751. /**
  106752. * Sets the Up vector of the Spotlight for texture projection.
  106753. */
  106754. projectionTextureUpDirection: Vector3;
  106755. private _projectionTexture;
  106756. /**
  106757. * Gets the projection texture of the light.
  106758. */
  106759. /**
  106760. * Sets the projection texture of the light.
  106761. */
  106762. projectionTexture: Nullable<BaseTexture>;
  106763. private _projectionTextureViewLightDirty;
  106764. private _projectionTextureProjectionLightDirty;
  106765. private _projectionTextureDirty;
  106766. private _projectionTextureViewTargetVector;
  106767. private _projectionTextureViewLightMatrix;
  106768. private _projectionTextureProjectionLightMatrix;
  106769. private _projectionTextureScalingMatrix;
  106770. /**
  106771. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  106772. * It can cast shadows.
  106773. * Documentation : https://doc.babylonjs.com/babylon101/lights
  106774. * @param name The light friendly name
  106775. * @param position The position of the spot light in the scene
  106776. * @param direction The direction of the light in the scene
  106777. * @param angle The cone angle of the light in Radians
  106778. * @param exponent The light decay speed with the distance from the emission spot
  106779. * @param scene The scene the lights belongs to
  106780. */
  106781. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  106782. /**
  106783. * Returns the string "SpotLight".
  106784. * @returns the class name
  106785. */
  106786. getClassName(): string;
  106787. /**
  106788. * Returns the integer 2.
  106789. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  106790. */
  106791. getTypeID(): number;
  106792. /**
  106793. * Overrides the direction setter to recompute the projection texture view light Matrix.
  106794. */
  106795. protected _setDirection(value: Vector3): void;
  106796. /**
  106797. * Overrides the position setter to recompute the projection texture view light Matrix.
  106798. */
  106799. protected _setPosition(value: Vector3): void;
  106800. /**
  106801. * 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.
  106802. * Returns the SpotLight.
  106803. */
  106804. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106805. protected _computeProjectionTextureViewLightMatrix(): void;
  106806. protected _computeProjectionTextureProjectionLightMatrix(): void;
  106807. /**
  106808. * Main function for light texture projection matrix computing.
  106809. */
  106810. protected _computeProjectionTextureMatrix(): void;
  106811. protected _buildUniformLayout(): void;
  106812. private _computeAngleValues;
  106813. /**
  106814. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  106815. * @param effect The effect to update
  106816. * @param lightIndex The index of the light in the effect to update
  106817. * @returns The spot light
  106818. */
  106819. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  106820. /**
  106821. * Disposes the light and the associated resources.
  106822. */
  106823. dispose(): void;
  106824. /**
  106825. * Prepares the list of defines specific to the light type.
  106826. * @param defines the list of defines
  106827. * @param lightIndex defines the index of the light for the effect
  106828. */
  106829. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  106830. }
  106831. }
  106832. declare module BABYLON {
  106833. /**
  106834. * Gizmo that enables viewing a light
  106835. */
  106836. export class LightGizmo extends Gizmo {
  106837. private _lightMesh;
  106838. private _material;
  106839. private cachedPosition;
  106840. private cachedForward;
  106841. /**
  106842. * Creates a LightGizmo
  106843. * @param gizmoLayer The utility layer the gizmo will be added to
  106844. */
  106845. constructor(gizmoLayer?: UtilityLayerRenderer);
  106846. private _light;
  106847. /**
  106848. * The light that the gizmo is attached to
  106849. */
  106850. light: Nullable<Light>;
  106851. /**
  106852. * @hidden
  106853. * Updates the gizmo to match the attached mesh's position/rotation
  106854. */
  106855. protected _update(): void;
  106856. private static _Scale;
  106857. /**
  106858. * Creates the lines for a light mesh
  106859. */
  106860. private static _createLightLines;
  106861. /**
  106862. * Disposes of the light gizmo
  106863. */
  106864. dispose(): void;
  106865. private static _CreateHemisphericLightMesh;
  106866. private static _CreatePointLightMesh;
  106867. private static _CreateSpotLightMesh;
  106868. private static _CreateDirectionalLightMesh;
  106869. }
  106870. }
  106871. declare module BABYLON {
  106872. /** @hidden */
  106873. export var backgroundFragmentDeclaration: {
  106874. name: string;
  106875. shader: string;
  106876. };
  106877. }
  106878. declare module BABYLON {
  106879. /** @hidden */
  106880. export var backgroundUboDeclaration: {
  106881. name: string;
  106882. shader: string;
  106883. };
  106884. }
  106885. declare module BABYLON {
  106886. /** @hidden */
  106887. export var backgroundPixelShader: {
  106888. name: string;
  106889. shader: string;
  106890. };
  106891. }
  106892. declare module BABYLON {
  106893. /** @hidden */
  106894. export var backgroundVertexDeclaration: {
  106895. name: string;
  106896. shader: string;
  106897. };
  106898. }
  106899. declare module BABYLON {
  106900. /** @hidden */
  106901. export var backgroundVertexShader: {
  106902. name: string;
  106903. shader: string;
  106904. };
  106905. }
  106906. declare module BABYLON {
  106907. /**
  106908. * Background material used to create an efficient environement around your scene.
  106909. */
  106910. export class BackgroundMaterial extends PushMaterial {
  106911. /**
  106912. * Standard reflectance value at parallel view angle.
  106913. */
  106914. static StandardReflectance0: number;
  106915. /**
  106916. * Standard reflectance value at grazing angle.
  106917. */
  106918. static StandardReflectance90: number;
  106919. protected _primaryColor: Color3;
  106920. /**
  106921. * Key light Color (multiply against the environement texture)
  106922. */
  106923. primaryColor: Color3;
  106924. protected __perceptualColor: Nullable<Color3>;
  106925. /**
  106926. * Experimental Internal Use Only.
  106927. *
  106928. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  106929. * This acts as a helper to set the primary color to a more "human friendly" value.
  106930. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  106931. * output color as close as possible from the chosen value.
  106932. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  106933. * part of lighting setup.)
  106934. */
  106935. _perceptualColor: Nullable<Color3>;
  106936. protected _primaryColorShadowLevel: float;
  106937. /**
  106938. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  106939. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  106940. */
  106941. primaryColorShadowLevel: float;
  106942. protected _primaryColorHighlightLevel: float;
  106943. /**
  106944. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  106945. * The primary color is used at the level chosen to define what the white area would look.
  106946. */
  106947. primaryColorHighlightLevel: float;
  106948. protected _reflectionTexture: Nullable<BaseTexture>;
  106949. /**
  106950. * Reflection Texture used in the material.
  106951. * Should be author in a specific way for the best result (refer to the documentation).
  106952. */
  106953. reflectionTexture: Nullable<BaseTexture>;
  106954. protected _reflectionBlur: float;
  106955. /**
  106956. * Reflection Texture level of blur.
  106957. *
  106958. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  106959. * texture twice.
  106960. */
  106961. reflectionBlur: float;
  106962. protected _diffuseTexture: Nullable<BaseTexture>;
  106963. /**
  106964. * Diffuse Texture used in the material.
  106965. * Should be author in a specific way for the best result (refer to the documentation).
  106966. */
  106967. diffuseTexture: Nullable<BaseTexture>;
  106968. protected _shadowLights: Nullable<IShadowLight[]>;
  106969. /**
  106970. * Specify the list of lights casting shadow on the material.
  106971. * All scene shadow lights will be included if null.
  106972. */
  106973. shadowLights: Nullable<IShadowLight[]>;
  106974. protected _shadowLevel: float;
  106975. /**
  106976. * Helps adjusting the shadow to a softer level if required.
  106977. * 0 means black shadows and 1 means no shadows.
  106978. */
  106979. shadowLevel: float;
  106980. protected _sceneCenter: Vector3;
  106981. /**
  106982. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  106983. * It is usually zero but might be interesting to modify according to your setup.
  106984. */
  106985. sceneCenter: Vector3;
  106986. protected _opacityFresnel: boolean;
  106987. /**
  106988. * This helps specifying that the material is falling off to the sky box at grazing angle.
  106989. * This helps ensuring a nice transition when the camera goes under the ground.
  106990. */
  106991. opacityFresnel: boolean;
  106992. protected _reflectionFresnel: boolean;
  106993. /**
  106994. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  106995. * This helps adding a mirror texture on the ground.
  106996. */
  106997. reflectionFresnel: boolean;
  106998. protected _reflectionFalloffDistance: number;
  106999. /**
  107000. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  107001. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  107002. */
  107003. reflectionFalloffDistance: number;
  107004. protected _reflectionAmount: number;
  107005. /**
  107006. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  107007. */
  107008. reflectionAmount: number;
  107009. protected _reflectionReflectance0: number;
  107010. /**
  107011. * This specifies the weight of the reflection at grazing angle.
  107012. */
  107013. reflectionReflectance0: number;
  107014. protected _reflectionReflectance90: number;
  107015. /**
  107016. * This specifies the weight of the reflection at a perpendicular point of view.
  107017. */
  107018. reflectionReflectance90: number;
  107019. /**
  107020. * Sets the reflection reflectance fresnel values according to the default standard
  107021. * empirically know to work well :-)
  107022. */
  107023. reflectionStandardFresnelWeight: number;
  107024. protected _useRGBColor: boolean;
  107025. /**
  107026. * Helps to directly use the maps channels instead of their level.
  107027. */
  107028. useRGBColor: boolean;
  107029. protected _enableNoise: boolean;
  107030. /**
  107031. * This helps reducing the banding effect that could occur on the background.
  107032. */
  107033. enableNoise: boolean;
  107034. /**
  107035. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  107036. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  107037. * Recommended to be keep at 1.0 except for special cases.
  107038. */
  107039. fovMultiplier: number;
  107040. private _fovMultiplier;
  107041. /**
  107042. * Enable the FOV adjustment feature controlled by fovMultiplier.
  107043. */
  107044. useEquirectangularFOV: boolean;
  107045. private _maxSimultaneousLights;
  107046. /**
  107047. * Number of Simultaneous lights allowed on the material.
  107048. */
  107049. maxSimultaneousLights: int;
  107050. /**
  107051. * Default configuration related to image processing available in the Background Material.
  107052. */
  107053. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107054. /**
  107055. * Keep track of the image processing observer to allow dispose and replace.
  107056. */
  107057. private _imageProcessingObserver;
  107058. /**
  107059. * Attaches a new image processing configuration to the PBR Material.
  107060. * @param configuration (if null the scene configuration will be use)
  107061. */
  107062. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107063. /**
  107064. * Gets the image processing configuration used either in this material.
  107065. */
  107066. /**
  107067. * Sets the Default image processing configuration used either in the this material.
  107068. *
  107069. * If sets to null, the scene one is in use.
  107070. */
  107071. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  107072. /**
  107073. * Gets wether the color curves effect is enabled.
  107074. */
  107075. /**
  107076. * Sets wether the color curves effect is enabled.
  107077. */
  107078. cameraColorCurvesEnabled: boolean;
  107079. /**
  107080. * Gets wether the color grading effect is enabled.
  107081. */
  107082. /**
  107083. * Gets wether the color grading effect is enabled.
  107084. */
  107085. cameraColorGradingEnabled: boolean;
  107086. /**
  107087. * Gets wether tonemapping is enabled or not.
  107088. */
  107089. /**
  107090. * Sets wether tonemapping is enabled or not
  107091. */
  107092. cameraToneMappingEnabled: boolean;
  107093. /**
  107094. * The camera exposure used on this material.
  107095. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107096. * This corresponds to a photographic exposure.
  107097. */
  107098. /**
  107099. * The camera exposure used on this material.
  107100. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107101. * This corresponds to a photographic exposure.
  107102. */
  107103. cameraExposure: float;
  107104. /**
  107105. * Gets The camera contrast used on this material.
  107106. */
  107107. /**
  107108. * Sets The camera contrast used on this material.
  107109. */
  107110. cameraContrast: float;
  107111. /**
  107112. * Gets the Color Grading 2D Lookup Texture.
  107113. */
  107114. /**
  107115. * Sets the Color Grading 2D Lookup Texture.
  107116. */
  107117. cameraColorGradingTexture: Nullable<BaseTexture>;
  107118. /**
  107119. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107120. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107121. * 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;
  107122. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107123. */
  107124. /**
  107125. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107126. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107127. * 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;
  107128. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107129. */
  107130. cameraColorCurves: Nullable<ColorCurves>;
  107131. /**
  107132. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  107133. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  107134. */
  107135. switchToBGR: boolean;
  107136. private _renderTargets;
  107137. private _reflectionControls;
  107138. private _white;
  107139. private _primaryShadowColor;
  107140. private _primaryHighlightColor;
  107141. /**
  107142. * Instantiates a Background Material in the given scene
  107143. * @param name The friendly name of the material
  107144. * @param scene The scene to add the material to
  107145. */
  107146. constructor(name: string, scene: Scene);
  107147. /**
  107148. * Gets a boolean indicating that current material needs to register RTT
  107149. */
  107150. readonly hasRenderTargetTextures: boolean;
  107151. /**
  107152. * The entire material has been created in order to prevent overdraw.
  107153. * @returns false
  107154. */
  107155. needAlphaTesting(): boolean;
  107156. /**
  107157. * The entire material has been created in order to prevent overdraw.
  107158. * @returns true if blending is enable
  107159. */
  107160. needAlphaBlending(): boolean;
  107161. /**
  107162. * Checks wether the material is ready to be rendered for a given mesh.
  107163. * @param mesh The mesh to render
  107164. * @param subMesh The submesh to check against
  107165. * @param useInstances Specify wether or not the material is used with instances
  107166. * @returns true if all the dependencies are ready (Textures, Effects...)
  107167. */
  107168. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107169. /**
  107170. * Compute the primary color according to the chosen perceptual color.
  107171. */
  107172. private _computePrimaryColorFromPerceptualColor;
  107173. /**
  107174. * Compute the highlights and shadow colors according to their chosen levels.
  107175. */
  107176. private _computePrimaryColors;
  107177. /**
  107178. * Build the uniform buffer used in the material.
  107179. */
  107180. buildUniformLayout(): void;
  107181. /**
  107182. * Unbind the material.
  107183. */
  107184. unbind(): void;
  107185. /**
  107186. * Bind only the world matrix to the material.
  107187. * @param world The world matrix to bind.
  107188. */
  107189. bindOnlyWorldMatrix(world: Matrix): void;
  107190. /**
  107191. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  107192. * @param world The world matrix to bind.
  107193. * @param subMesh The submesh to bind for.
  107194. */
  107195. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107196. /**
  107197. * Dispose the material.
  107198. * @param forceDisposeEffect Force disposal of the associated effect.
  107199. * @param forceDisposeTextures Force disposal of the associated textures.
  107200. */
  107201. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107202. /**
  107203. * Clones the material.
  107204. * @param name The cloned name.
  107205. * @returns The cloned material.
  107206. */
  107207. clone(name: string): BackgroundMaterial;
  107208. /**
  107209. * Serializes the current material to its JSON representation.
  107210. * @returns The JSON representation.
  107211. */
  107212. serialize(): any;
  107213. /**
  107214. * Gets the class name of the material
  107215. * @returns "BackgroundMaterial"
  107216. */
  107217. getClassName(): string;
  107218. /**
  107219. * Parse a JSON input to create back a background material.
  107220. * @param source The JSON data to parse
  107221. * @param scene The scene to create the parsed material in
  107222. * @param rootUrl The root url of the assets the material depends upon
  107223. * @returns the instantiated BackgroundMaterial.
  107224. */
  107225. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  107226. }
  107227. }
  107228. declare module BABYLON {
  107229. /**
  107230. * Represents the different options available during the creation of
  107231. * a Environment helper.
  107232. *
  107233. * This can control the default ground, skybox and image processing setup of your scene.
  107234. */
  107235. export interface IEnvironmentHelperOptions {
  107236. /**
  107237. * Specifies wether or not to create a ground.
  107238. * True by default.
  107239. */
  107240. createGround: boolean;
  107241. /**
  107242. * Specifies the ground size.
  107243. * 15 by default.
  107244. */
  107245. groundSize: number;
  107246. /**
  107247. * The texture used on the ground for the main color.
  107248. * Comes from the BabylonJS CDN by default.
  107249. *
  107250. * Remarks: Can be either a texture or a url.
  107251. */
  107252. groundTexture: string | BaseTexture;
  107253. /**
  107254. * The color mixed in the ground texture by default.
  107255. * BabylonJS clearColor by default.
  107256. */
  107257. groundColor: Color3;
  107258. /**
  107259. * Specifies the ground opacity.
  107260. * 1 by default.
  107261. */
  107262. groundOpacity: number;
  107263. /**
  107264. * Enables the ground to receive shadows.
  107265. * True by default.
  107266. */
  107267. enableGroundShadow: boolean;
  107268. /**
  107269. * Helps preventing the shadow to be fully black on the ground.
  107270. * 0.5 by default.
  107271. */
  107272. groundShadowLevel: number;
  107273. /**
  107274. * Creates a mirror texture attach to the ground.
  107275. * false by default.
  107276. */
  107277. enableGroundMirror: boolean;
  107278. /**
  107279. * Specifies the ground mirror size ratio.
  107280. * 0.3 by default as the default kernel is 64.
  107281. */
  107282. groundMirrorSizeRatio: number;
  107283. /**
  107284. * Specifies the ground mirror blur kernel size.
  107285. * 64 by default.
  107286. */
  107287. groundMirrorBlurKernel: number;
  107288. /**
  107289. * Specifies the ground mirror visibility amount.
  107290. * 1 by default
  107291. */
  107292. groundMirrorAmount: number;
  107293. /**
  107294. * Specifies the ground mirror reflectance weight.
  107295. * This uses the standard weight of the background material to setup the fresnel effect
  107296. * of the mirror.
  107297. * 1 by default.
  107298. */
  107299. groundMirrorFresnelWeight: number;
  107300. /**
  107301. * Specifies the ground mirror Falloff distance.
  107302. * This can helps reducing the size of the reflection.
  107303. * 0 by Default.
  107304. */
  107305. groundMirrorFallOffDistance: number;
  107306. /**
  107307. * Specifies the ground mirror texture type.
  107308. * Unsigned Int by Default.
  107309. */
  107310. groundMirrorTextureType: number;
  107311. /**
  107312. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  107313. * the shown objects.
  107314. */
  107315. groundYBias: number;
  107316. /**
  107317. * Specifies wether or not to create a skybox.
  107318. * True by default.
  107319. */
  107320. createSkybox: boolean;
  107321. /**
  107322. * Specifies the skybox size.
  107323. * 20 by default.
  107324. */
  107325. skyboxSize: number;
  107326. /**
  107327. * The texture used on the skybox for the main color.
  107328. * Comes from the BabylonJS CDN by default.
  107329. *
  107330. * Remarks: Can be either a texture or a url.
  107331. */
  107332. skyboxTexture: string | BaseTexture;
  107333. /**
  107334. * The color mixed in the skybox texture by default.
  107335. * BabylonJS clearColor by default.
  107336. */
  107337. skyboxColor: Color3;
  107338. /**
  107339. * The background rotation around the Y axis of the scene.
  107340. * This helps aligning the key lights of your scene with the background.
  107341. * 0 by default.
  107342. */
  107343. backgroundYRotation: number;
  107344. /**
  107345. * Compute automatically the size of the elements to best fit with the scene.
  107346. */
  107347. sizeAuto: boolean;
  107348. /**
  107349. * Default position of the rootMesh if autoSize is not true.
  107350. */
  107351. rootPosition: Vector3;
  107352. /**
  107353. * Sets up the image processing in the scene.
  107354. * true by default.
  107355. */
  107356. setupImageProcessing: boolean;
  107357. /**
  107358. * The texture used as your environment texture in the scene.
  107359. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  107360. *
  107361. * Remarks: Can be either a texture or a url.
  107362. */
  107363. environmentTexture: string | BaseTexture;
  107364. /**
  107365. * The value of the exposure to apply to the scene.
  107366. * 0.6 by default if setupImageProcessing is true.
  107367. */
  107368. cameraExposure: number;
  107369. /**
  107370. * The value of the contrast to apply to the scene.
  107371. * 1.6 by default if setupImageProcessing is true.
  107372. */
  107373. cameraContrast: number;
  107374. /**
  107375. * Specifies wether or not tonemapping should be enabled in the scene.
  107376. * true by default if setupImageProcessing is true.
  107377. */
  107378. toneMappingEnabled: boolean;
  107379. }
  107380. /**
  107381. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  107382. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  107383. * It also helps with the default setup of your imageProcessing configuration.
  107384. */
  107385. export class EnvironmentHelper {
  107386. /**
  107387. * Default ground texture URL.
  107388. */
  107389. private static _groundTextureCDNUrl;
  107390. /**
  107391. * Default skybox texture URL.
  107392. */
  107393. private static _skyboxTextureCDNUrl;
  107394. /**
  107395. * Default environment texture URL.
  107396. */
  107397. private static _environmentTextureCDNUrl;
  107398. /**
  107399. * Creates the default options for the helper.
  107400. */
  107401. private static _getDefaultOptions;
  107402. private _rootMesh;
  107403. /**
  107404. * Gets the root mesh created by the helper.
  107405. */
  107406. readonly rootMesh: Mesh;
  107407. private _skybox;
  107408. /**
  107409. * Gets the skybox created by the helper.
  107410. */
  107411. readonly skybox: Nullable<Mesh>;
  107412. private _skyboxTexture;
  107413. /**
  107414. * Gets the skybox texture created by the helper.
  107415. */
  107416. readonly skyboxTexture: Nullable<BaseTexture>;
  107417. private _skyboxMaterial;
  107418. /**
  107419. * Gets the skybox material created by the helper.
  107420. */
  107421. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  107422. private _ground;
  107423. /**
  107424. * Gets the ground mesh created by the helper.
  107425. */
  107426. readonly ground: Nullable<Mesh>;
  107427. private _groundTexture;
  107428. /**
  107429. * Gets the ground texture created by the helper.
  107430. */
  107431. readonly groundTexture: Nullable<BaseTexture>;
  107432. private _groundMirror;
  107433. /**
  107434. * Gets the ground mirror created by the helper.
  107435. */
  107436. readonly groundMirror: Nullable<MirrorTexture>;
  107437. /**
  107438. * Gets the ground mirror render list to helps pushing the meshes
  107439. * you wish in the ground reflection.
  107440. */
  107441. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  107442. private _groundMaterial;
  107443. /**
  107444. * Gets the ground material created by the helper.
  107445. */
  107446. readonly groundMaterial: Nullable<BackgroundMaterial>;
  107447. /**
  107448. * Stores the creation options.
  107449. */
  107450. private readonly _scene;
  107451. private _options;
  107452. /**
  107453. * This observable will be notified with any error during the creation of the environment,
  107454. * mainly texture creation errors.
  107455. */
  107456. onErrorObservable: Observable<{
  107457. message?: string;
  107458. exception?: any;
  107459. }>;
  107460. /**
  107461. * constructor
  107462. * @param options Defines the options we want to customize the helper
  107463. * @param scene The scene to add the material to
  107464. */
  107465. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  107466. /**
  107467. * Updates the background according to the new options
  107468. * @param options
  107469. */
  107470. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  107471. /**
  107472. * Sets the primary color of all the available elements.
  107473. * @param color the main color to affect to the ground and the background
  107474. */
  107475. setMainColor(color: Color3): void;
  107476. /**
  107477. * Setup the image processing according to the specified options.
  107478. */
  107479. private _setupImageProcessing;
  107480. /**
  107481. * Setup the environment texture according to the specified options.
  107482. */
  107483. private _setupEnvironmentTexture;
  107484. /**
  107485. * Setup the background according to the specified options.
  107486. */
  107487. private _setupBackground;
  107488. /**
  107489. * Get the scene sizes according to the setup.
  107490. */
  107491. private _getSceneSize;
  107492. /**
  107493. * Setup the ground according to the specified options.
  107494. */
  107495. private _setupGround;
  107496. /**
  107497. * Setup the ground material according to the specified options.
  107498. */
  107499. private _setupGroundMaterial;
  107500. /**
  107501. * Setup the ground diffuse texture according to the specified options.
  107502. */
  107503. private _setupGroundDiffuseTexture;
  107504. /**
  107505. * Setup the ground mirror texture according to the specified options.
  107506. */
  107507. private _setupGroundMirrorTexture;
  107508. /**
  107509. * Setup the ground to receive the mirror texture.
  107510. */
  107511. private _setupMirrorInGroundMaterial;
  107512. /**
  107513. * Setup the skybox according to the specified options.
  107514. */
  107515. private _setupSkybox;
  107516. /**
  107517. * Setup the skybox material according to the specified options.
  107518. */
  107519. private _setupSkyboxMaterial;
  107520. /**
  107521. * Setup the skybox reflection texture according to the specified options.
  107522. */
  107523. private _setupSkyboxReflectionTexture;
  107524. private _errorHandler;
  107525. /**
  107526. * Dispose all the elements created by the Helper.
  107527. */
  107528. dispose(): void;
  107529. }
  107530. }
  107531. declare module BABYLON {
  107532. /**
  107533. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  107534. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  107535. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  107536. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  107537. */
  107538. export class PhotoDome extends TransformNode {
  107539. /**
  107540. * Define the image as a Monoscopic panoramic 360 image.
  107541. */
  107542. static readonly MODE_MONOSCOPIC: number;
  107543. /**
  107544. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  107545. */
  107546. static readonly MODE_TOPBOTTOM: number;
  107547. /**
  107548. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  107549. */
  107550. static readonly MODE_SIDEBYSIDE: number;
  107551. private _useDirectMapping;
  107552. /**
  107553. * The texture being displayed on the sphere
  107554. */
  107555. protected _photoTexture: Texture;
  107556. /**
  107557. * Gets or sets the texture being displayed on the sphere
  107558. */
  107559. photoTexture: Texture;
  107560. /**
  107561. * Observable raised when an error occured while loading the 360 image
  107562. */
  107563. onLoadErrorObservable: Observable<string>;
  107564. /**
  107565. * The skybox material
  107566. */
  107567. protected _material: BackgroundMaterial;
  107568. /**
  107569. * The surface used for the skybox
  107570. */
  107571. protected _mesh: Mesh;
  107572. /**
  107573. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  107574. * Also see the options.resolution property.
  107575. */
  107576. fovMultiplier: number;
  107577. private _imageMode;
  107578. /**
  107579. * Gets or set the current video mode for the video. It can be:
  107580. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  107581. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  107582. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  107583. */
  107584. imageMode: number;
  107585. /**
  107586. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  107587. * @param name Element's name, child elements will append suffixes for their own names.
  107588. * @param urlsOfPhoto defines the url of the photo to display
  107589. * @param options defines an object containing optional or exposed sub element properties
  107590. * @param onError defines a callback called when an error occured while loading the texture
  107591. */
  107592. constructor(name: string, urlOfPhoto: string, options: {
  107593. resolution?: number;
  107594. size?: number;
  107595. useDirectMapping?: boolean;
  107596. faceForward?: boolean;
  107597. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  107598. private _onBeforeCameraRenderObserver;
  107599. private _changeImageMode;
  107600. /**
  107601. * Releases resources associated with this node.
  107602. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  107603. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  107604. */
  107605. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  107606. }
  107607. }
  107608. declare module BABYLON {
  107609. /** @hidden */
  107610. export var rgbdDecodePixelShader: {
  107611. name: string;
  107612. shader: string;
  107613. };
  107614. }
  107615. declare module BABYLON {
  107616. /**
  107617. * Class used to host texture specific utilities
  107618. */
  107619. export class BRDFTextureTools {
  107620. /**
  107621. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  107622. * @param texture the texture to expand.
  107623. */
  107624. private static _ExpandDefaultBRDFTexture;
  107625. /**
  107626. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  107627. * @param scene defines the hosting scene
  107628. * @returns the environment BRDF texture
  107629. */
  107630. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  107631. private static _environmentBRDFBase64Texture;
  107632. }
  107633. }
  107634. declare module BABYLON {
  107635. /**
  107636. * @hidden
  107637. */
  107638. export interface IMaterialClearCoatDefines {
  107639. CLEARCOAT: boolean;
  107640. CLEARCOAT_DEFAULTIOR: boolean;
  107641. CLEARCOAT_TEXTURE: boolean;
  107642. CLEARCOAT_TEXTUREDIRECTUV: number;
  107643. CLEARCOAT_BUMP: boolean;
  107644. CLEARCOAT_BUMPDIRECTUV: number;
  107645. CLEARCOAT_TINT: boolean;
  107646. CLEARCOAT_TINT_TEXTURE: boolean;
  107647. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  107648. /** @hidden */
  107649. _areTexturesDirty: boolean;
  107650. }
  107651. /**
  107652. * Define the code related to the clear coat parameters of the pbr material.
  107653. */
  107654. export class PBRClearCoatConfiguration {
  107655. /**
  107656. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  107657. * The default fits with a polyurethane material.
  107658. */
  107659. private static readonly _DefaultIndexOfRefraction;
  107660. private _isEnabled;
  107661. /**
  107662. * Defines if the clear coat is enabled in the material.
  107663. */
  107664. isEnabled: boolean;
  107665. /**
  107666. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  107667. */
  107668. intensity: number;
  107669. /**
  107670. * Defines the clear coat layer roughness.
  107671. */
  107672. roughness: number;
  107673. private _indexOfRefraction;
  107674. /**
  107675. * Defines the index of refraction of the clear coat.
  107676. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  107677. * The default fits with a polyurethane material.
  107678. * Changing the default value is more performance intensive.
  107679. */
  107680. indexOfRefraction: number;
  107681. private _texture;
  107682. /**
  107683. * Stores the clear coat values in a texture.
  107684. */
  107685. texture: Nullable<BaseTexture>;
  107686. private _bumpTexture;
  107687. /**
  107688. * Define the clear coat specific bump texture.
  107689. */
  107690. bumpTexture: Nullable<BaseTexture>;
  107691. private _isTintEnabled;
  107692. /**
  107693. * Defines if the clear coat tint is enabled in the material.
  107694. */
  107695. isTintEnabled: boolean;
  107696. /**
  107697. * Defines the clear coat tint of the material.
  107698. * This is only use if tint is enabled
  107699. */
  107700. tintColor: Color3;
  107701. /**
  107702. * Defines the distance at which the tint color should be found in the
  107703. * clear coat media.
  107704. * This is only use if tint is enabled
  107705. */
  107706. tintColorAtDistance: number;
  107707. /**
  107708. * Defines the clear coat layer thickness.
  107709. * This is only use if tint is enabled
  107710. */
  107711. tintThickness: number;
  107712. private _tintTexture;
  107713. /**
  107714. * Stores the clear tint values in a texture.
  107715. * rgb is tint
  107716. * a is a thickness factor
  107717. */
  107718. tintTexture: Nullable<BaseTexture>;
  107719. /** @hidden */
  107720. private _internalMarkAllSubMeshesAsTexturesDirty;
  107721. /** @hidden */
  107722. _markAllSubMeshesAsTexturesDirty(): void;
  107723. /**
  107724. * Instantiate a new istance of clear coat configuration.
  107725. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107726. */
  107727. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107728. /**
  107729. * Gets wehter the submesh is ready to be used or not.
  107730. * @param defines the list of "defines" to update.
  107731. * @param scene defines the scene the material belongs to.
  107732. * @param engine defines the engine the material belongs to.
  107733. * @param disableBumpMap defines wether the material disables bump or not.
  107734. * @returns - boolean indicating that the submesh is ready or not.
  107735. */
  107736. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  107737. /**
  107738. * Checks to see if a texture is used in the material.
  107739. * @param defines the list of "defines" to update.
  107740. * @param scene defines the scene to the material belongs to.
  107741. */
  107742. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  107743. /**
  107744. * Binds the material data.
  107745. * @param uniformBuffer defines the Uniform buffer to fill in.
  107746. * @param scene defines the scene the material belongs to.
  107747. * @param engine defines the engine the material belongs to.
  107748. * @param disableBumpMap defines wether the material disables bump or not.
  107749. * @param isFrozen defines wether the material is frozen or not.
  107750. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  107751. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  107752. */
  107753. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  107754. /**
  107755. * Checks to see if a texture is used in the material.
  107756. * @param texture - Base texture to use.
  107757. * @returns - Boolean specifying if a texture is used in the material.
  107758. */
  107759. hasTexture(texture: BaseTexture): boolean;
  107760. /**
  107761. * Returns an array of the actively used textures.
  107762. * @param activeTextures Array of BaseTextures
  107763. */
  107764. getActiveTextures(activeTextures: BaseTexture[]): void;
  107765. /**
  107766. * Returns the animatable textures.
  107767. * @param animatables Array of animatable textures.
  107768. */
  107769. getAnimatables(animatables: IAnimatable[]): void;
  107770. /**
  107771. * Disposes the resources of the material.
  107772. * @param forceDisposeTextures - Forces the disposal of all textures.
  107773. */
  107774. dispose(forceDisposeTextures?: boolean): void;
  107775. /**
  107776. * Get the current class name of the texture useful for serialization or dynamic coding.
  107777. * @returns "PBRClearCoatConfiguration"
  107778. */
  107779. getClassName(): string;
  107780. /**
  107781. * Add fallbacks to the effect fallbacks list.
  107782. * @param defines defines the Base texture to use.
  107783. * @param fallbacks defines the current fallback list.
  107784. * @param currentRank defines the current fallback rank.
  107785. * @returns the new fallback rank.
  107786. */
  107787. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107788. /**
  107789. * Add the required uniforms to the current list.
  107790. * @param uniforms defines the current uniform list.
  107791. */
  107792. static AddUniforms(uniforms: string[]): void;
  107793. /**
  107794. * Add the required samplers to the current list.
  107795. * @param samplers defines the current sampler list.
  107796. */
  107797. static AddSamplers(samplers: string[]): void;
  107798. /**
  107799. * Add the required uniforms to the current buffer.
  107800. * @param uniformBuffer defines the current uniform buffer.
  107801. */
  107802. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107803. /**
  107804. * Makes a duplicate of the current configuration into another one.
  107805. * @param clearCoatConfiguration define the config where to copy the info
  107806. */
  107807. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  107808. /**
  107809. * Serializes this clear coat configuration.
  107810. * @returns - An object with the serialized config.
  107811. */
  107812. serialize(): any;
  107813. /**
  107814. * Parses a anisotropy Configuration from a serialized object.
  107815. * @param source - Serialized object.
  107816. * @param scene Defines the scene we are parsing for
  107817. * @param rootUrl Defines the rootUrl to load from
  107818. */
  107819. parse(source: any, scene: Scene, rootUrl: string): void;
  107820. }
  107821. }
  107822. declare module BABYLON {
  107823. /**
  107824. * @hidden
  107825. */
  107826. export interface IMaterialAnisotropicDefines {
  107827. ANISOTROPIC: boolean;
  107828. ANISOTROPIC_TEXTURE: boolean;
  107829. ANISOTROPIC_TEXTUREDIRECTUV: number;
  107830. MAINUV1: boolean;
  107831. _areTexturesDirty: boolean;
  107832. _needUVs: boolean;
  107833. }
  107834. /**
  107835. * Define the code related to the anisotropic parameters of the pbr material.
  107836. */
  107837. export class PBRAnisotropicConfiguration {
  107838. private _isEnabled;
  107839. /**
  107840. * Defines if the anisotropy is enabled in the material.
  107841. */
  107842. isEnabled: boolean;
  107843. /**
  107844. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  107845. */
  107846. intensity: number;
  107847. /**
  107848. * Defines if the effect is along the tangents, bitangents or in between.
  107849. * By default, the effect is "strectching" the highlights along the tangents.
  107850. */
  107851. direction: Vector2;
  107852. private _texture;
  107853. /**
  107854. * Stores the anisotropy values in a texture.
  107855. * rg is direction (like normal from -1 to 1)
  107856. * b is a intensity
  107857. */
  107858. texture: Nullable<BaseTexture>;
  107859. /** @hidden */
  107860. private _internalMarkAllSubMeshesAsTexturesDirty;
  107861. /** @hidden */
  107862. _markAllSubMeshesAsTexturesDirty(): void;
  107863. /**
  107864. * Instantiate a new istance of anisotropy configuration.
  107865. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107866. */
  107867. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107868. /**
  107869. * Specifies that the submesh is ready to be used.
  107870. * @param defines the list of "defines" to update.
  107871. * @param scene defines the scene the material belongs to.
  107872. * @returns - boolean indicating that the submesh is ready or not.
  107873. */
  107874. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  107875. /**
  107876. * Checks to see if a texture is used in the material.
  107877. * @param defines the list of "defines" to update.
  107878. * @param mesh the mesh we are preparing the defines for.
  107879. * @param scene defines the scene the material belongs to.
  107880. */
  107881. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  107882. /**
  107883. * Binds the material data.
  107884. * @param uniformBuffer defines the Uniform buffer to fill in.
  107885. * @param scene defines the scene the material belongs to.
  107886. * @param isFrozen defines wether the material is frozen or not.
  107887. */
  107888. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107889. /**
  107890. * Checks to see if a texture is used in the material.
  107891. * @param texture - Base texture to use.
  107892. * @returns - Boolean specifying if a texture is used in the material.
  107893. */
  107894. hasTexture(texture: BaseTexture): boolean;
  107895. /**
  107896. * Returns an array of the actively used textures.
  107897. * @param activeTextures Array of BaseTextures
  107898. */
  107899. getActiveTextures(activeTextures: BaseTexture[]): void;
  107900. /**
  107901. * Returns the animatable textures.
  107902. * @param animatables Array of animatable textures.
  107903. */
  107904. getAnimatables(animatables: IAnimatable[]): void;
  107905. /**
  107906. * Disposes the resources of the material.
  107907. * @param forceDisposeTextures - Forces the disposal of all textures.
  107908. */
  107909. dispose(forceDisposeTextures?: boolean): void;
  107910. /**
  107911. * Get the current class name of the texture useful for serialization or dynamic coding.
  107912. * @returns "PBRAnisotropicConfiguration"
  107913. */
  107914. getClassName(): string;
  107915. /**
  107916. * Add fallbacks to the effect fallbacks list.
  107917. * @param defines defines the Base texture to use.
  107918. * @param fallbacks defines the current fallback list.
  107919. * @param currentRank defines the current fallback rank.
  107920. * @returns the new fallback rank.
  107921. */
  107922. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107923. /**
  107924. * Add the required uniforms to the current list.
  107925. * @param uniforms defines the current uniform list.
  107926. */
  107927. static AddUniforms(uniforms: string[]): void;
  107928. /**
  107929. * Add the required uniforms to the current buffer.
  107930. * @param uniformBuffer defines the current uniform buffer.
  107931. */
  107932. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107933. /**
  107934. * Add the required samplers to the current list.
  107935. * @param samplers defines the current sampler list.
  107936. */
  107937. static AddSamplers(samplers: string[]): void;
  107938. /**
  107939. * Makes a duplicate of the current configuration into another one.
  107940. * @param anisotropicConfiguration define the config where to copy the info
  107941. */
  107942. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  107943. /**
  107944. * Serializes this anisotropy configuration.
  107945. * @returns - An object with the serialized config.
  107946. */
  107947. serialize(): any;
  107948. /**
  107949. * Parses a anisotropy Configuration from a serialized object.
  107950. * @param source - Serialized object.
  107951. * @param scene Defines the scene we are parsing for
  107952. * @param rootUrl Defines the rootUrl to load from
  107953. */
  107954. parse(source: any, scene: Scene, rootUrl: string): void;
  107955. }
  107956. }
  107957. declare module BABYLON {
  107958. /**
  107959. * @hidden
  107960. */
  107961. export interface IMaterialBRDFDefines {
  107962. BRDF_V_HEIGHT_CORRELATED: boolean;
  107963. MS_BRDF_ENERGY_CONSERVATION: boolean;
  107964. SPHERICAL_HARMONICS: boolean;
  107965. /** @hidden */
  107966. _areMiscDirty: boolean;
  107967. }
  107968. /**
  107969. * Define the code related to the BRDF parameters of the pbr material.
  107970. */
  107971. export class PBRBRDFConfiguration {
  107972. /**
  107973. * Default value used for the energy conservation.
  107974. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  107975. */
  107976. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  107977. /**
  107978. * Default value used for the Smith Visibility Height Correlated mode.
  107979. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  107980. */
  107981. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  107982. /**
  107983. * Default value used for the IBL diffuse part.
  107984. * This can help switching back to the polynomials mode globally which is a tiny bit
  107985. * less GPU intensive at the drawback of a lower quality.
  107986. */
  107987. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  107988. private _useEnergyConservation;
  107989. /**
  107990. * Defines if the material uses energy conservation.
  107991. */
  107992. useEnergyConservation: boolean;
  107993. private _useSmithVisibilityHeightCorrelated;
  107994. /**
  107995. * LEGACY Mode set to false
  107996. * Defines if the material uses height smith correlated visibility term.
  107997. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  107998. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  107999. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  108000. * Not relying on height correlated will also disable energy conservation.
  108001. */
  108002. useSmithVisibilityHeightCorrelated: boolean;
  108003. private _useSphericalHarmonics;
  108004. /**
  108005. * LEGACY Mode set to false
  108006. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  108007. * diffuse part of the IBL.
  108008. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  108009. * to the ground truth.
  108010. */
  108011. useSphericalHarmonics: boolean;
  108012. /** @hidden */
  108013. private _internalMarkAllSubMeshesAsMiscDirty;
  108014. /** @hidden */
  108015. _markAllSubMeshesAsMiscDirty(): void;
  108016. /**
  108017. * Instantiate a new istance of clear coat configuration.
  108018. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  108019. */
  108020. constructor(markAllSubMeshesAsMiscDirty: () => void);
  108021. /**
  108022. * Checks to see if a texture is used in the material.
  108023. * @param defines the list of "defines" to update.
  108024. */
  108025. prepareDefines(defines: IMaterialBRDFDefines): void;
  108026. /**
  108027. * Get the current class name of the texture useful for serialization or dynamic coding.
  108028. * @returns "PBRClearCoatConfiguration"
  108029. */
  108030. getClassName(): string;
  108031. /**
  108032. * Makes a duplicate of the current configuration into another one.
  108033. * @param brdfConfiguration define the config where to copy the info
  108034. */
  108035. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  108036. /**
  108037. * Serializes this BRDF configuration.
  108038. * @returns - An object with the serialized config.
  108039. */
  108040. serialize(): any;
  108041. /**
  108042. * Parses a anisotropy Configuration from a serialized object.
  108043. * @param source - Serialized object.
  108044. * @param scene Defines the scene we are parsing for
  108045. * @param rootUrl Defines the rootUrl to load from
  108046. */
  108047. parse(source: any, scene: Scene, rootUrl: string): void;
  108048. }
  108049. }
  108050. declare module BABYLON {
  108051. /**
  108052. * @hidden
  108053. */
  108054. export interface IMaterialSheenDefines {
  108055. SHEEN: boolean;
  108056. SHEEN_TEXTURE: boolean;
  108057. SHEEN_TEXTUREDIRECTUV: number;
  108058. SHEEN_LINKWITHALBEDO: boolean;
  108059. /** @hidden */
  108060. _areTexturesDirty: boolean;
  108061. }
  108062. /**
  108063. * Define the code related to the Sheen parameters of the pbr material.
  108064. */
  108065. export class PBRSheenConfiguration {
  108066. private _isEnabled;
  108067. /**
  108068. * Defines if the material uses sheen.
  108069. */
  108070. isEnabled: boolean;
  108071. private _linkSheenWithAlbedo;
  108072. /**
  108073. * Defines if the sheen is linked to the sheen color.
  108074. */
  108075. linkSheenWithAlbedo: boolean;
  108076. /**
  108077. * Defines the sheen intensity.
  108078. */
  108079. intensity: number;
  108080. /**
  108081. * Defines the sheen color.
  108082. */
  108083. color: Color3;
  108084. private _texture;
  108085. /**
  108086. * Stores the sheen tint values in a texture.
  108087. * rgb is tint
  108088. * a is a intensity
  108089. */
  108090. texture: Nullable<BaseTexture>;
  108091. /** @hidden */
  108092. private _internalMarkAllSubMeshesAsTexturesDirty;
  108093. /** @hidden */
  108094. _markAllSubMeshesAsTexturesDirty(): void;
  108095. /**
  108096. * Instantiate a new istance of clear coat configuration.
  108097. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  108098. */
  108099. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  108100. /**
  108101. * Specifies that the submesh is ready to be used.
  108102. * @param defines the list of "defines" to update.
  108103. * @param scene defines the scene the material belongs to.
  108104. * @returns - boolean indicating that the submesh is ready or not.
  108105. */
  108106. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  108107. /**
  108108. * Checks to see if a texture is used in the material.
  108109. * @param defines the list of "defines" to update.
  108110. * @param scene defines the scene the material belongs to.
  108111. */
  108112. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  108113. /**
  108114. * Binds the material data.
  108115. * @param uniformBuffer defines the Uniform buffer to fill in.
  108116. * @param scene defines the scene the material belongs to.
  108117. * @param isFrozen defines wether the material is frozen or not.
  108118. */
  108119. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  108120. /**
  108121. * Checks to see if a texture is used in the material.
  108122. * @param texture - Base texture to use.
  108123. * @returns - Boolean specifying if a texture is used in the material.
  108124. */
  108125. hasTexture(texture: BaseTexture): boolean;
  108126. /**
  108127. * Returns an array of the actively used textures.
  108128. * @param activeTextures Array of BaseTextures
  108129. */
  108130. getActiveTextures(activeTextures: BaseTexture[]): void;
  108131. /**
  108132. * Returns the animatable textures.
  108133. * @param animatables Array of animatable textures.
  108134. */
  108135. getAnimatables(animatables: IAnimatable[]): void;
  108136. /**
  108137. * Disposes the resources of the material.
  108138. * @param forceDisposeTextures - Forces the disposal of all textures.
  108139. */
  108140. dispose(forceDisposeTextures?: boolean): void;
  108141. /**
  108142. * Get the current class name of the texture useful for serialization or dynamic coding.
  108143. * @returns "PBRSheenConfiguration"
  108144. */
  108145. getClassName(): string;
  108146. /**
  108147. * Add fallbacks to the effect fallbacks list.
  108148. * @param defines defines the Base texture to use.
  108149. * @param fallbacks defines the current fallback list.
  108150. * @param currentRank defines the current fallback rank.
  108151. * @returns the new fallback rank.
  108152. */
  108153. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  108154. /**
  108155. * Add the required uniforms to the current list.
  108156. * @param uniforms defines the current uniform list.
  108157. */
  108158. static AddUniforms(uniforms: string[]): void;
  108159. /**
  108160. * Add the required uniforms to the current buffer.
  108161. * @param uniformBuffer defines the current uniform buffer.
  108162. */
  108163. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  108164. /**
  108165. * Add the required samplers to the current list.
  108166. * @param samplers defines the current sampler list.
  108167. */
  108168. static AddSamplers(samplers: string[]): void;
  108169. /**
  108170. * Makes a duplicate of the current configuration into another one.
  108171. * @param sheenConfiguration define the config where to copy the info
  108172. */
  108173. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  108174. /**
  108175. * Serializes this BRDF configuration.
  108176. * @returns - An object with the serialized config.
  108177. */
  108178. serialize(): any;
  108179. /**
  108180. * Parses a anisotropy Configuration from a serialized object.
  108181. * @param source - Serialized object.
  108182. * @param scene Defines the scene we are parsing for
  108183. * @param rootUrl Defines the rootUrl to load from
  108184. */
  108185. parse(source: any, scene: Scene, rootUrl: string): void;
  108186. }
  108187. }
  108188. declare module BABYLON {
  108189. /**
  108190. * @hidden
  108191. */
  108192. export interface IMaterialSubSurfaceDefines {
  108193. SUBSURFACE: boolean;
  108194. SS_REFRACTION: boolean;
  108195. SS_TRANSLUCENCY: boolean;
  108196. SS_SCATERRING: boolean;
  108197. SS_THICKNESSANDMASK_TEXTURE: boolean;
  108198. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  108199. SS_REFRACTIONMAP_3D: boolean;
  108200. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  108201. SS_LODINREFRACTIONALPHA: boolean;
  108202. SS_GAMMAREFRACTION: boolean;
  108203. SS_RGBDREFRACTION: boolean;
  108204. SS_LINEARSPECULARREFRACTION: boolean;
  108205. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  108206. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  108207. /** @hidden */
  108208. _areTexturesDirty: boolean;
  108209. }
  108210. /**
  108211. * Define the code related to the sub surface parameters of the pbr material.
  108212. */
  108213. export class PBRSubSurfaceConfiguration {
  108214. private _isRefractionEnabled;
  108215. /**
  108216. * Defines if the refraction is enabled in the material.
  108217. */
  108218. isRefractionEnabled: boolean;
  108219. private _isTranslucencyEnabled;
  108220. /**
  108221. * Defines if the translucency is enabled in the material.
  108222. */
  108223. isTranslucencyEnabled: boolean;
  108224. private _isScatteringEnabled;
  108225. /**
  108226. * Defines the refraction intensity of the material.
  108227. * The refraction when enabled replaces the Diffuse part of the material.
  108228. * The intensity helps transitionning between diffuse and refraction.
  108229. */
  108230. refractionIntensity: number;
  108231. /**
  108232. * Defines the translucency intensity of the material.
  108233. * When translucency has been enabled, this defines how much of the "translucency"
  108234. * is addded to the diffuse part of the material.
  108235. */
  108236. translucencyIntensity: number;
  108237. /**
  108238. * Defines the scattering intensity of the material.
  108239. * When scattering has been enabled, this defines how much of the "scattered light"
  108240. * is addded to the diffuse part of the material.
  108241. */
  108242. scatteringIntensity: number;
  108243. private _thicknessTexture;
  108244. /**
  108245. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  108246. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  108247. * 0 would mean minimumThickness
  108248. * 1 would mean maximumThickness
  108249. * The other channels might be use as a mask to vary the different effects intensity.
  108250. */
  108251. thicknessTexture: Nullable<BaseTexture>;
  108252. private _refractionTexture;
  108253. /**
  108254. * Defines the texture to use for refraction.
  108255. */
  108256. refractionTexture: Nullable<BaseTexture>;
  108257. private _indexOfRefraction;
  108258. /**
  108259. * Defines the index of refraction used in the material.
  108260. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  108261. */
  108262. indexOfRefraction: number;
  108263. private _invertRefractionY;
  108264. /**
  108265. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  108266. */
  108267. invertRefractionY: boolean;
  108268. private _linkRefractionWithTransparency;
  108269. /**
  108270. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  108271. * Materials half opaque for instance using refraction could benefit from this control.
  108272. */
  108273. linkRefractionWithTransparency: boolean;
  108274. /**
  108275. * Defines the minimum thickness stored in the thickness map.
  108276. * If no thickness map is defined, this value will be used to simulate thickness.
  108277. */
  108278. minimumThickness: number;
  108279. /**
  108280. * Defines the maximum thickness stored in the thickness map.
  108281. */
  108282. maximumThickness: number;
  108283. /**
  108284. * Defines the volume tint of the material.
  108285. * This is used for both translucency and scattering.
  108286. */
  108287. tintColor: Color3;
  108288. /**
  108289. * Defines the distance at which the tint color should be found in the media.
  108290. * This is used for refraction only.
  108291. */
  108292. tintColorAtDistance: number;
  108293. /**
  108294. * Defines how far each channel transmit through the media.
  108295. * It is defined as a color to simplify it selection.
  108296. */
  108297. diffusionDistance: Color3;
  108298. private _useMaskFromThicknessTexture;
  108299. /**
  108300. * Stores the intensity of the different subsurface effects in the thickness texture.
  108301. * * the green channel is the translucency intensity.
  108302. * * the blue channel is the scattering intensity.
  108303. * * the alpha channel is the refraction intensity.
  108304. */
  108305. useMaskFromThicknessTexture: boolean;
  108306. /** @hidden */
  108307. private _internalMarkAllSubMeshesAsTexturesDirty;
  108308. /** @hidden */
  108309. _markAllSubMeshesAsTexturesDirty(): void;
  108310. /**
  108311. * Instantiate a new istance of sub surface configuration.
  108312. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  108313. */
  108314. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  108315. /**
  108316. * Gets wehter the submesh is ready to be used or not.
  108317. * @param defines the list of "defines" to update.
  108318. * @param scene defines the scene the material belongs to.
  108319. * @returns - boolean indicating that the submesh is ready or not.
  108320. */
  108321. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  108322. /**
  108323. * Checks to see if a texture is used in the material.
  108324. * @param defines the list of "defines" to update.
  108325. * @param scene defines the scene to the material belongs to.
  108326. */
  108327. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  108328. /**
  108329. * Binds the material data.
  108330. * @param uniformBuffer defines the Uniform buffer to fill in.
  108331. * @param scene defines the scene the material belongs to.
  108332. * @param engine defines the engine the material belongs to.
  108333. * @param isFrozen defines wether the material is frozen or not.
  108334. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  108335. */
  108336. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  108337. /**
  108338. * Unbinds the material from the mesh.
  108339. * @param activeEffect defines the effect that should be unbound from.
  108340. * @returns true if unbound, otherwise false
  108341. */
  108342. unbind(activeEffect: Effect): boolean;
  108343. /**
  108344. * Returns the texture used for refraction or null if none is used.
  108345. * @param scene defines the scene the material belongs to.
  108346. * @returns - Refraction texture if present. If no refraction texture and refraction
  108347. * is linked with transparency, returns environment texture. Otherwise, returns null.
  108348. */
  108349. private _getRefractionTexture;
  108350. /**
  108351. * Returns true if alpha blending should be disabled.
  108352. */
  108353. readonly disableAlphaBlending: boolean;
  108354. /**
  108355. * Fills the list of render target textures.
  108356. * @param renderTargets the list of render targets to update
  108357. */
  108358. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  108359. /**
  108360. * Checks to see if a texture is used in the material.
  108361. * @param texture - Base texture to use.
  108362. * @returns - Boolean specifying if a texture is used in the material.
  108363. */
  108364. hasTexture(texture: BaseTexture): boolean;
  108365. /**
  108366. * Gets a boolean indicating that current material needs to register RTT
  108367. * @returns true if this uses a render target otherwise false.
  108368. */
  108369. hasRenderTargetTextures(): boolean;
  108370. /**
  108371. * Returns an array of the actively used textures.
  108372. * @param activeTextures Array of BaseTextures
  108373. */
  108374. getActiveTextures(activeTextures: BaseTexture[]): void;
  108375. /**
  108376. * Returns the animatable textures.
  108377. * @param animatables Array of animatable textures.
  108378. */
  108379. getAnimatables(animatables: IAnimatable[]): void;
  108380. /**
  108381. * Disposes the resources of the material.
  108382. * @param forceDisposeTextures - Forces the disposal of all textures.
  108383. */
  108384. dispose(forceDisposeTextures?: boolean): void;
  108385. /**
  108386. * Get the current class name of the texture useful for serialization or dynamic coding.
  108387. * @returns "PBRSubSurfaceConfiguration"
  108388. */
  108389. getClassName(): string;
  108390. /**
  108391. * Add fallbacks to the effect fallbacks list.
  108392. * @param defines defines the Base texture to use.
  108393. * @param fallbacks defines the current fallback list.
  108394. * @param currentRank defines the current fallback rank.
  108395. * @returns the new fallback rank.
  108396. */
  108397. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  108398. /**
  108399. * Add the required uniforms to the current list.
  108400. * @param uniforms defines the current uniform list.
  108401. */
  108402. static AddUniforms(uniforms: string[]): void;
  108403. /**
  108404. * Add the required samplers to the current list.
  108405. * @param samplers defines the current sampler list.
  108406. */
  108407. static AddSamplers(samplers: string[]): void;
  108408. /**
  108409. * Add the required uniforms to the current buffer.
  108410. * @param uniformBuffer defines the current uniform buffer.
  108411. */
  108412. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  108413. /**
  108414. * Makes a duplicate of the current configuration into another one.
  108415. * @param configuration define the config where to copy the info
  108416. */
  108417. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  108418. /**
  108419. * Serializes this Sub Surface configuration.
  108420. * @returns - An object with the serialized config.
  108421. */
  108422. serialize(): any;
  108423. /**
  108424. * Parses a anisotropy Configuration from a serialized object.
  108425. * @param source - Serialized object.
  108426. * @param scene Defines the scene we are parsing for
  108427. * @param rootUrl Defines the rootUrl to load from
  108428. */
  108429. parse(source: any, scene: Scene, rootUrl: string): void;
  108430. }
  108431. }
  108432. declare module BABYLON {
  108433. /** @hidden */
  108434. export var pbrFragmentDeclaration: {
  108435. name: string;
  108436. shader: string;
  108437. };
  108438. }
  108439. declare module BABYLON {
  108440. /** @hidden */
  108441. export var pbrUboDeclaration: {
  108442. name: string;
  108443. shader: string;
  108444. };
  108445. }
  108446. declare module BABYLON {
  108447. /** @hidden */
  108448. export var pbrFragmentExtraDeclaration: {
  108449. name: string;
  108450. shader: string;
  108451. };
  108452. }
  108453. declare module BABYLON {
  108454. /** @hidden */
  108455. export var pbrFragmentSamplersDeclaration: {
  108456. name: string;
  108457. shader: string;
  108458. };
  108459. }
  108460. declare module BABYLON {
  108461. /** @hidden */
  108462. export var pbrHelperFunctions: {
  108463. name: string;
  108464. shader: string;
  108465. };
  108466. }
  108467. declare module BABYLON {
  108468. /** @hidden */
  108469. export var harmonicsFunctions: {
  108470. name: string;
  108471. shader: string;
  108472. };
  108473. }
  108474. declare module BABYLON {
  108475. /** @hidden */
  108476. export var pbrDirectLightingSetupFunctions: {
  108477. name: string;
  108478. shader: string;
  108479. };
  108480. }
  108481. declare module BABYLON {
  108482. /** @hidden */
  108483. export var pbrDirectLightingFalloffFunctions: {
  108484. name: string;
  108485. shader: string;
  108486. };
  108487. }
  108488. declare module BABYLON {
  108489. /** @hidden */
  108490. export var pbrBRDFFunctions: {
  108491. name: string;
  108492. shader: string;
  108493. };
  108494. }
  108495. declare module BABYLON {
  108496. /** @hidden */
  108497. export var pbrDirectLightingFunctions: {
  108498. name: string;
  108499. shader: string;
  108500. };
  108501. }
  108502. declare module BABYLON {
  108503. /** @hidden */
  108504. export var pbrIBLFunctions: {
  108505. name: string;
  108506. shader: string;
  108507. };
  108508. }
  108509. declare module BABYLON {
  108510. /** @hidden */
  108511. export var pbrDebug: {
  108512. name: string;
  108513. shader: string;
  108514. };
  108515. }
  108516. declare module BABYLON {
  108517. /** @hidden */
  108518. export var pbrPixelShader: {
  108519. name: string;
  108520. shader: string;
  108521. };
  108522. }
  108523. declare module BABYLON {
  108524. /** @hidden */
  108525. export var pbrVertexDeclaration: {
  108526. name: string;
  108527. shader: string;
  108528. };
  108529. }
  108530. declare module BABYLON {
  108531. /** @hidden */
  108532. export var pbrVertexShader: {
  108533. name: string;
  108534. shader: string;
  108535. };
  108536. }
  108537. declare module BABYLON {
  108538. /**
  108539. * Manages the defines for the PBR Material.
  108540. * @hidden
  108541. */
  108542. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  108543. PBR: boolean;
  108544. MAINUV1: boolean;
  108545. MAINUV2: boolean;
  108546. UV1: boolean;
  108547. UV2: boolean;
  108548. ALBEDO: boolean;
  108549. ALBEDODIRECTUV: number;
  108550. VERTEXCOLOR: boolean;
  108551. AMBIENT: boolean;
  108552. AMBIENTDIRECTUV: number;
  108553. AMBIENTINGRAYSCALE: boolean;
  108554. OPACITY: boolean;
  108555. VERTEXALPHA: boolean;
  108556. OPACITYDIRECTUV: number;
  108557. OPACITYRGB: boolean;
  108558. ALPHATEST: boolean;
  108559. DEPTHPREPASS: boolean;
  108560. ALPHABLEND: boolean;
  108561. ALPHAFROMALBEDO: boolean;
  108562. ALPHATESTVALUE: string;
  108563. SPECULAROVERALPHA: boolean;
  108564. RADIANCEOVERALPHA: boolean;
  108565. ALPHAFRESNEL: boolean;
  108566. LINEARALPHAFRESNEL: boolean;
  108567. PREMULTIPLYALPHA: boolean;
  108568. EMISSIVE: boolean;
  108569. EMISSIVEDIRECTUV: number;
  108570. REFLECTIVITY: boolean;
  108571. REFLECTIVITYDIRECTUV: number;
  108572. SPECULARTERM: boolean;
  108573. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  108574. MICROSURFACEAUTOMATIC: boolean;
  108575. LODBASEDMICROSFURACE: boolean;
  108576. MICROSURFACEMAP: boolean;
  108577. MICROSURFACEMAPDIRECTUV: number;
  108578. METALLICWORKFLOW: boolean;
  108579. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  108580. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  108581. METALLNESSSTOREINMETALMAPBLUE: boolean;
  108582. AOSTOREINMETALMAPRED: boolean;
  108583. ENVIRONMENTBRDF: boolean;
  108584. ENVIRONMENTBRDF_RGBD: boolean;
  108585. NORMAL: boolean;
  108586. TANGENT: boolean;
  108587. BUMP: boolean;
  108588. BUMPDIRECTUV: number;
  108589. OBJECTSPACE_NORMALMAP: boolean;
  108590. PARALLAX: boolean;
  108591. PARALLAXOCCLUSION: boolean;
  108592. NORMALXYSCALE: boolean;
  108593. LIGHTMAP: boolean;
  108594. LIGHTMAPDIRECTUV: number;
  108595. USELIGHTMAPASSHADOWMAP: boolean;
  108596. GAMMALIGHTMAP: boolean;
  108597. REFLECTION: boolean;
  108598. REFLECTIONMAP_3D: boolean;
  108599. REFLECTIONMAP_SPHERICAL: boolean;
  108600. REFLECTIONMAP_PLANAR: boolean;
  108601. REFLECTIONMAP_CUBIC: boolean;
  108602. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  108603. REFLECTIONMAP_PROJECTION: boolean;
  108604. REFLECTIONMAP_SKYBOX: boolean;
  108605. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  108606. REFLECTIONMAP_EXPLICIT: boolean;
  108607. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  108608. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  108609. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  108610. INVERTCUBICMAP: boolean;
  108611. USESPHERICALFROMREFLECTIONMAP: boolean;
  108612. USEIRRADIANCEMAP: boolean;
  108613. SPHERICAL_HARMONICS: boolean;
  108614. USESPHERICALINVERTEX: boolean;
  108615. REFLECTIONMAP_OPPOSITEZ: boolean;
  108616. LODINREFLECTIONALPHA: boolean;
  108617. GAMMAREFLECTION: boolean;
  108618. RGBDREFLECTION: boolean;
  108619. LINEARSPECULARREFLECTION: boolean;
  108620. RADIANCEOCCLUSION: boolean;
  108621. HORIZONOCCLUSION: boolean;
  108622. INSTANCES: boolean;
  108623. NUM_BONE_INFLUENCERS: number;
  108624. BonesPerMesh: number;
  108625. BONETEXTURE: boolean;
  108626. NONUNIFORMSCALING: boolean;
  108627. MORPHTARGETS: boolean;
  108628. MORPHTARGETS_NORMAL: boolean;
  108629. MORPHTARGETS_TANGENT: boolean;
  108630. MORPHTARGETS_UV: boolean;
  108631. NUM_MORPH_INFLUENCERS: number;
  108632. IMAGEPROCESSING: boolean;
  108633. VIGNETTE: boolean;
  108634. VIGNETTEBLENDMODEMULTIPLY: boolean;
  108635. VIGNETTEBLENDMODEOPAQUE: boolean;
  108636. TONEMAPPING: boolean;
  108637. TONEMAPPING_ACES: boolean;
  108638. CONTRAST: boolean;
  108639. COLORCURVES: boolean;
  108640. COLORGRADING: boolean;
  108641. COLORGRADING3D: boolean;
  108642. SAMPLER3DGREENDEPTH: boolean;
  108643. SAMPLER3DBGRMAP: boolean;
  108644. IMAGEPROCESSINGPOSTPROCESS: boolean;
  108645. EXPOSURE: boolean;
  108646. MULTIVIEW: boolean;
  108647. USEPHYSICALLIGHTFALLOFF: boolean;
  108648. USEGLTFLIGHTFALLOFF: boolean;
  108649. TWOSIDEDLIGHTING: boolean;
  108650. SHADOWFLOAT: boolean;
  108651. CLIPPLANE: boolean;
  108652. CLIPPLANE2: boolean;
  108653. CLIPPLANE3: boolean;
  108654. CLIPPLANE4: boolean;
  108655. POINTSIZE: boolean;
  108656. FOG: boolean;
  108657. LOGARITHMICDEPTH: boolean;
  108658. FORCENORMALFORWARD: boolean;
  108659. SPECULARAA: boolean;
  108660. CLEARCOAT: boolean;
  108661. CLEARCOAT_DEFAULTIOR: boolean;
  108662. CLEARCOAT_TEXTURE: boolean;
  108663. CLEARCOAT_TEXTUREDIRECTUV: number;
  108664. CLEARCOAT_BUMP: boolean;
  108665. CLEARCOAT_BUMPDIRECTUV: number;
  108666. CLEARCOAT_TINT: boolean;
  108667. CLEARCOAT_TINT_TEXTURE: boolean;
  108668. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  108669. ANISOTROPIC: boolean;
  108670. ANISOTROPIC_TEXTURE: boolean;
  108671. ANISOTROPIC_TEXTUREDIRECTUV: number;
  108672. BRDF_V_HEIGHT_CORRELATED: boolean;
  108673. MS_BRDF_ENERGY_CONSERVATION: boolean;
  108674. SHEEN: boolean;
  108675. SHEEN_TEXTURE: boolean;
  108676. SHEEN_TEXTUREDIRECTUV: number;
  108677. SHEEN_LINKWITHALBEDO: boolean;
  108678. SUBSURFACE: boolean;
  108679. SS_REFRACTION: boolean;
  108680. SS_TRANSLUCENCY: boolean;
  108681. SS_SCATERRING: boolean;
  108682. SS_THICKNESSANDMASK_TEXTURE: boolean;
  108683. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  108684. SS_REFRACTIONMAP_3D: boolean;
  108685. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  108686. SS_LODINREFRACTIONALPHA: boolean;
  108687. SS_GAMMAREFRACTION: boolean;
  108688. SS_RGBDREFRACTION: boolean;
  108689. SS_LINEARSPECULARREFRACTION: boolean;
  108690. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  108691. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  108692. UNLIT: boolean;
  108693. DEBUGMODE: number;
  108694. /**
  108695. * Initializes the PBR Material defines.
  108696. */
  108697. constructor();
  108698. /**
  108699. * Resets the PBR Material defines.
  108700. */
  108701. reset(): void;
  108702. }
  108703. /**
  108704. * The Physically based material base class of BJS.
  108705. *
  108706. * This offers the main features of a standard PBR material.
  108707. * For more information, please refer to the documentation :
  108708. * https://doc.babylonjs.com/how_to/physically_based_rendering
  108709. */
  108710. export abstract class PBRBaseMaterial extends PushMaterial {
  108711. /**
  108712. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  108713. */
  108714. static readonly PBRMATERIAL_OPAQUE: number;
  108715. /**
  108716. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  108717. */
  108718. static readonly PBRMATERIAL_ALPHATEST: number;
  108719. /**
  108720. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108721. */
  108722. static readonly PBRMATERIAL_ALPHABLEND: number;
  108723. /**
  108724. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108725. * They are also discarded below the alpha cutoff threshold to improve performances.
  108726. */
  108727. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  108728. /**
  108729. * Defines the default value of how much AO map is occluding the analytical lights
  108730. * (point spot...).
  108731. */
  108732. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  108733. /**
  108734. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  108735. */
  108736. static readonly LIGHTFALLOFF_PHYSICAL: number;
  108737. /**
  108738. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  108739. * to enhance interoperability with other engines.
  108740. */
  108741. static readonly LIGHTFALLOFF_GLTF: number;
  108742. /**
  108743. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  108744. * to enhance interoperability with other materials.
  108745. */
  108746. static readonly LIGHTFALLOFF_STANDARD: number;
  108747. /**
  108748. * Intensity of the direct lights e.g. the four lights available in your scene.
  108749. * This impacts both the direct diffuse and specular highlights.
  108750. */
  108751. protected _directIntensity: number;
  108752. /**
  108753. * Intensity of the emissive part of the material.
  108754. * This helps controlling the emissive effect without modifying the emissive color.
  108755. */
  108756. protected _emissiveIntensity: number;
  108757. /**
  108758. * Intensity of the environment e.g. how much the environment will light the object
  108759. * either through harmonics for rough material or through the refelction for shiny ones.
  108760. */
  108761. protected _environmentIntensity: number;
  108762. /**
  108763. * This is a special control allowing the reduction of the specular highlights coming from the
  108764. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  108765. */
  108766. protected _specularIntensity: number;
  108767. /**
  108768. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  108769. */
  108770. private _lightingInfos;
  108771. /**
  108772. * Debug Control allowing disabling the bump map on this material.
  108773. */
  108774. protected _disableBumpMap: boolean;
  108775. /**
  108776. * AKA Diffuse Texture in standard nomenclature.
  108777. */
  108778. protected _albedoTexture: Nullable<BaseTexture>;
  108779. /**
  108780. * AKA Occlusion Texture in other nomenclature.
  108781. */
  108782. protected _ambientTexture: Nullable<BaseTexture>;
  108783. /**
  108784. * AKA Occlusion Texture Intensity in other nomenclature.
  108785. */
  108786. protected _ambientTextureStrength: number;
  108787. /**
  108788. * Defines how much the AO map is occluding the analytical lights (point spot...).
  108789. * 1 means it completely occludes it
  108790. * 0 mean it has no impact
  108791. */
  108792. protected _ambientTextureImpactOnAnalyticalLights: number;
  108793. /**
  108794. * Stores the alpha values in a texture.
  108795. */
  108796. protected _opacityTexture: Nullable<BaseTexture>;
  108797. /**
  108798. * Stores the reflection values in a texture.
  108799. */
  108800. protected _reflectionTexture: Nullable<BaseTexture>;
  108801. /**
  108802. * Stores the emissive values in a texture.
  108803. */
  108804. protected _emissiveTexture: Nullable<BaseTexture>;
  108805. /**
  108806. * AKA Specular texture in other nomenclature.
  108807. */
  108808. protected _reflectivityTexture: Nullable<BaseTexture>;
  108809. /**
  108810. * Used to switch from specular/glossiness to metallic/roughness workflow.
  108811. */
  108812. protected _metallicTexture: Nullable<BaseTexture>;
  108813. /**
  108814. * Specifies the metallic scalar of the metallic/roughness workflow.
  108815. * Can also be used to scale the metalness values of the metallic texture.
  108816. */
  108817. protected _metallic: Nullable<number>;
  108818. /**
  108819. * Specifies the roughness scalar of the metallic/roughness workflow.
  108820. * Can also be used to scale the roughness values of the metallic texture.
  108821. */
  108822. protected _roughness: Nullable<number>;
  108823. /**
  108824. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  108825. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  108826. */
  108827. protected _microSurfaceTexture: Nullable<BaseTexture>;
  108828. /**
  108829. * Stores surface normal data used to displace a mesh in a texture.
  108830. */
  108831. protected _bumpTexture: Nullable<BaseTexture>;
  108832. /**
  108833. * Stores the pre-calculated light information of a mesh in a texture.
  108834. */
  108835. protected _lightmapTexture: Nullable<BaseTexture>;
  108836. /**
  108837. * The color of a material in ambient lighting.
  108838. */
  108839. protected _ambientColor: Color3;
  108840. /**
  108841. * AKA Diffuse Color in other nomenclature.
  108842. */
  108843. protected _albedoColor: Color3;
  108844. /**
  108845. * AKA Specular Color in other nomenclature.
  108846. */
  108847. protected _reflectivityColor: Color3;
  108848. /**
  108849. * The color applied when light is reflected from a material.
  108850. */
  108851. protected _reflectionColor: Color3;
  108852. /**
  108853. * The color applied when light is emitted from a material.
  108854. */
  108855. protected _emissiveColor: Color3;
  108856. /**
  108857. * AKA Glossiness in other nomenclature.
  108858. */
  108859. protected _microSurface: number;
  108860. /**
  108861. * Specifies that the material will use the light map as a show map.
  108862. */
  108863. protected _useLightmapAsShadowmap: boolean;
  108864. /**
  108865. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  108866. * makes the reflect vector face the model (under horizon).
  108867. */
  108868. protected _useHorizonOcclusion: boolean;
  108869. /**
  108870. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  108871. * too much the area relying on ambient texture to define their ambient occlusion.
  108872. */
  108873. protected _useRadianceOcclusion: boolean;
  108874. /**
  108875. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  108876. */
  108877. protected _useAlphaFromAlbedoTexture: boolean;
  108878. /**
  108879. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  108880. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108881. */
  108882. protected _useSpecularOverAlpha: boolean;
  108883. /**
  108884. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  108885. */
  108886. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  108887. /**
  108888. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  108889. */
  108890. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  108891. /**
  108892. * Specifies if the metallic texture contains the roughness information in its green channel.
  108893. */
  108894. protected _useRoughnessFromMetallicTextureGreen: boolean;
  108895. /**
  108896. * Specifies if the metallic texture contains the metallness information in its blue channel.
  108897. */
  108898. protected _useMetallnessFromMetallicTextureBlue: boolean;
  108899. /**
  108900. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  108901. */
  108902. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  108903. /**
  108904. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  108905. */
  108906. protected _useAmbientInGrayScale: boolean;
  108907. /**
  108908. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  108909. * The material will try to infer what glossiness each pixel should be.
  108910. */
  108911. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  108912. /**
  108913. * Defines the falloff type used in this material.
  108914. * It by default is Physical.
  108915. */
  108916. protected _lightFalloff: number;
  108917. /**
  108918. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108919. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108920. */
  108921. protected _useRadianceOverAlpha: boolean;
  108922. /**
  108923. * Allows using an object space normal map (instead of tangent space).
  108924. */
  108925. protected _useObjectSpaceNormalMap: boolean;
  108926. /**
  108927. * Allows using the bump map in parallax mode.
  108928. */
  108929. protected _useParallax: boolean;
  108930. /**
  108931. * Allows using the bump map in parallax occlusion mode.
  108932. */
  108933. protected _useParallaxOcclusion: boolean;
  108934. /**
  108935. * Controls the scale bias of the parallax mode.
  108936. */
  108937. protected _parallaxScaleBias: number;
  108938. /**
  108939. * If sets to true, disables all the lights affecting the material.
  108940. */
  108941. protected _disableLighting: boolean;
  108942. /**
  108943. * Number of Simultaneous lights allowed on the material.
  108944. */
  108945. protected _maxSimultaneousLights: number;
  108946. /**
  108947. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  108948. */
  108949. protected _invertNormalMapX: boolean;
  108950. /**
  108951. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  108952. */
  108953. protected _invertNormalMapY: boolean;
  108954. /**
  108955. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108956. */
  108957. protected _twoSidedLighting: boolean;
  108958. /**
  108959. * Defines the alpha limits in alpha test mode.
  108960. */
  108961. protected _alphaCutOff: number;
  108962. /**
  108963. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  108964. */
  108965. protected _forceAlphaTest: boolean;
  108966. /**
  108967. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108968. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  108969. */
  108970. protected _useAlphaFresnel: boolean;
  108971. /**
  108972. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108973. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  108974. */
  108975. protected _useLinearAlphaFresnel: boolean;
  108976. /**
  108977. * The transparency mode of the material.
  108978. */
  108979. protected _transparencyMode: Nullable<number>;
  108980. /**
  108981. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  108982. * from cos thetav and roughness:
  108983. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  108984. */
  108985. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  108986. /**
  108987. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  108988. */
  108989. protected _forceIrradianceInFragment: boolean;
  108990. /**
  108991. * Force normal to face away from face.
  108992. */
  108993. protected _forceNormalForward: boolean;
  108994. /**
  108995. * Enables specular anti aliasing in the PBR shader.
  108996. * It will both interacts on the Geometry for analytical and IBL lighting.
  108997. * It also prefilter the roughness map based on the bump values.
  108998. */
  108999. protected _enableSpecularAntiAliasing: boolean;
  109000. /**
  109001. * Default configuration related to image processing available in the PBR Material.
  109002. */
  109003. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109004. /**
  109005. * Keep track of the image processing observer to allow dispose and replace.
  109006. */
  109007. private _imageProcessingObserver;
  109008. /**
  109009. * Attaches a new image processing configuration to the PBR Material.
  109010. * @param configuration
  109011. */
  109012. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  109013. /**
  109014. * Stores the available render targets.
  109015. */
  109016. private _renderTargets;
  109017. /**
  109018. * Sets the global ambient color for the material used in lighting calculations.
  109019. */
  109020. private _globalAmbientColor;
  109021. /**
  109022. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  109023. */
  109024. private _useLogarithmicDepth;
  109025. /**
  109026. * If set to true, no lighting calculations will be applied.
  109027. */
  109028. private _unlit;
  109029. private _debugMode;
  109030. /**
  109031. * @hidden
  109032. * This is reserved for the inspector.
  109033. * Defines the material debug mode.
  109034. * It helps seeing only some components of the material while troubleshooting.
  109035. */
  109036. debugMode: number;
  109037. /**
  109038. * @hidden
  109039. * This is reserved for the inspector.
  109040. * Specify from where on screen the debug mode should start.
  109041. * The value goes from -1 (full screen) to 1 (not visible)
  109042. * It helps with side by side comparison against the final render
  109043. * This defaults to -1
  109044. */
  109045. private debugLimit;
  109046. /**
  109047. * @hidden
  109048. * This is reserved for the inspector.
  109049. * As the default viewing range might not be enough (if the ambient is really small for instance)
  109050. * You can use the factor to better multiply the final value.
  109051. */
  109052. private debugFactor;
  109053. /**
  109054. * Defines the clear coat layer parameters for the material.
  109055. */
  109056. readonly clearCoat: PBRClearCoatConfiguration;
  109057. /**
  109058. * Defines the anisotropic parameters for the material.
  109059. */
  109060. readonly anisotropy: PBRAnisotropicConfiguration;
  109061. /**
  109062. * Defines the BRDF parameters for the material.
  109063. */
  109064. readonly brdf: PBRBRDFConfiguration;
  109065. /**
  109066. * Defines the Sheen parameters for the material.
  109067. */
  109068. readonly sheen: PBRSheenConfiguration;
  109069. /**
  109070. * Defines the SubSurface parameters for the material.
  109071. */
  109072. readonly subSurface: PBRSubSurfaceConfiguration;
  109073. /**
  109074. * Custom callback helping to override the default shader used in the material.
  109075. */
  109076. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  109077. /**
  109078. * Instantiates a new PBRMaterial instance.
  109079. *
  109080. * @param name The material name
  109081. * @param scene The scene the material will be use in.
  109082. */
  109083. constructor(name: string, scene: Scene);
  109084. /**
  109085. * Gets a boolean indicating that current material needs to register RTT
  109086. */
  109087. readonly hasRenderTargetTextures: boolean;
  109088. /**
  109089. * Gets the name of the material class.
  109090. */
  109091. getClassName(): string;
  109092. /**
  109093. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  109094. */
  109095. /**
  109096. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  109097. */
  109098. useLogarithmicDepth: boolean;
  109099. /**
  109100. * Gets the current transparency mode.
  109101. */
  109102. /**
  109103. * Sets the transparency mode of the material.
  109104. *
  109105. * | Value | Type | Description |
  109106. * | ----- | ----------------------------------- | ----------- |
  109107. * | 0 | OPAQUE | |
  109108. * | 1 | ALPHATEST | |
  109109. * | 2 | ALPHABLEND | |
  109110. * | 3 | ALPHATESTANDBLEND | |
  109111. *
  109112. */
  109113. transparencyMode: Nullable<number>;
  109114. /**
  109115. * Returns true if alpha blending should be disabled.
  109116. */
  109117. private readonly _disableAlphaBlending;
  109118. /**
  109119. * Specifies whether or not this material should be rendered in alpha blend mode.
  109120. */
  109121. needAlphaBlending(): boolean;
  109122. /**
  109123. * Specifies if the mesh will require alpha blending.
  109124. * @param mesh - BJS mesh.
  109125. */
  109126. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  109127. /**
  109128. * Specifies whether or not this material should be rendered in alpha test mode.
  109129. */
  109130. needAlphaTesting(): boolean;
  109131. /**
  109132. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  109133. */
  109134. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  109135. /**
  109136. * Gets the texture used for the alpha test.
  109137. */
  109138. getAlphaTestTexture(): Nullable<BaseTexture>;
  109139. /**
  109140. * Specifies that the submesh is ready to be used.
  109141. * @param mesh - BJS mesh.
  109142. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  109143. * @param useInstances - Specifies that instances should be used.
  109144. * @returns - boolean indicating that the submesh is ready or not.
  109145. */
  109146. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109147. /**
  109148. * Specifies if the material uses metallic roughness workflow.
  109149. * @returns boolean specifiying if the material uses metallic roughness workflow.
  109150. */
  109151. isMetallicWorkflow(): boolean;
  109152. private _prepareEffect;
  109153. private _prepareDefines;
  109154. /**
  109155. * Force shader compilation
  109156. */
  109157. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  109158. clipPlane: boolean;
  109159. }>): void;
  109160. /**
  109161. * Initializes the uniform buffer layout for the shader.
  109162. */
  109163. buildUniformLayout(): void;
  109164. /**
  109165. * Unbinds the material from the mesh
  109166. */
  109167. unbind(): void;
  109168. /**
  109169. * Binds the submesh data.
  109170. * @param world - The world matrix.
  109171. * @param mesh - The BJS mesh.
  109172. * @param subMesh - A submesh of the BJS mesh.
  109173. */
  109174. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109175. /**
  109176. * Returns the animatable textures.
  109177. * @returns - Array of animatable textures.
  109178. */
  109179. getAnimatables(): IAnimatable[];
  109180. /**
  109181. * Returns the texture used for reflections.
  109182. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  109183. */
  109184. private _getReflectionTexture;
  109185. /**
  109186. * Returns an array of the actively used textures.
  109187. * @returns - Array of BaseTextures
  109188. */
  109189. getActiveTextures(): BaseTexture[];
  109190. /**
  109191. * Checks to see if a texture is used in the material.
  109192. * @param texture - Base texture to use.
  109193. * @returns - Boolean specifying if a texture is used in the material.
  109194. */
  109195. hasTexture(texture: BaseTexture): boolean;
  109196. /**
  109197. * Disposes the resources of the material.
  109198. * @param forceDisposeEffect - Forces the disposal of effects.
  109199. * @param forceDisposeTextures - Forces the disposal of all textures.
  109200. */
  109201. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  109202. }
  109203. }
  109204. declare module BABYLON {
  109205. /**
  109206. * The Physically based material of BJS.
  109207. *
  109208. * This offers the main features of a standard PBR material.
  109209. * For more information, please refer to the documentation :
  109210. * https://doc.babylonjs.com/how_to/physically_based_rendering
  109211. */
  109212. export class PBRMaterial extends PBRBaseMaterial {
  109213. /**
  109214. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  109215. */
  109216. static readonly PBRMATERIAL_OPAQUE: number;
  109217. /**
  109218. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  109219. */
  109220. static readonly PBRMATERIAL_ALPHATEST: number;
  109221. /**
  109222. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109223. */
  109224. static readonly PBRMATERIAL_ALPHABLEND: number;
  109225. /**
  109226. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109227. * They are also discarded below the alpha cutoff threshold to improve performances.
  109228. */
  109229. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  109230. /**
  109231. * Defines the default value of how much AO map is occluding the analytical lights
  109232. * (point spot...).
  109233. */
  109234. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  109235. /**
  109236. * Intensity of the direct lights e.g. the four lights available in your scene.
  109237. * This impacts both the direct diffuse and specular highlights.
  109238. */
  109239. directIntensity: number;
  109240. /**
  109241. * Intensity of the emissive part of the material.
  109242. * This helps controlling the emissive effect without modifying the emissive color.
  109243. */
  109244. emissiveIntensity: number;
  109245. /**
  109246. * Intensity of the environment e.g. how much the environment will light the object
  109247. * either through harmonics for rough material or through the refelction for shiny ones.
  109248. */
  109249. environmentIntensity: number;
  109250. /**
  109251. * This is a special control allowing the reduction of the specular highlights coming from the
  109252. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  109253. */
  109254. specularIntensity: number;
  109255. /**
  109256. * Debug Control allowing disabling the bump map on this material.
  109257. */
  109258. disableBumpMap: boolean;
  109259. /**
  109260. * AKA Diffuse Texture in standard nomenclature.
  109261. */
  109262. albedoTexture: BaseTexture;
  109263. /**
  109264. * AKA Occlusion Texture in other nomenclature.
  109265. */
  109266. ambientTexture: BaseTexture;
  109267. /**
  109268. * AKA Occlusion Texture Intensity in other nomenclature.
  109269. */
  109270. ambientTextureStrength: number;
  109271. /**
  109272. * Defines how much the AO map is occluding the analytical lights (point spot...).
  109273. * 1 means it completely occludes it
  109274. * 0 mean it has no impact
  109275. */
  109276. ambientTextureImpactOnAnalyticalLights: number;
  109277. /**
  109278. * Stores the alpha values in a texture.
  109279. */
  109280. opacityTexture: BaseTexture;
  109281. /**
  109282. * Stores the reflection values in a texture.
  109283. */
  109284. reflectionTexture: Nullable<BaseTexture>;
  109285. /**
  109286. * Stores the emissive values in a texture.
  109287. */
  109288. emissiveTexture: BaseTexture;
  109289. /**
  109290. * AKA Specular texture in other nomenclature.
  109291. */
  109292. reflectivityTexture: BaseTexture;
  109293. /**
  109294. * Used to switch from specular/glossiness to metallic/roughness workflow.
  109295. */
  109296. metallicTexture: BaseTexture;
  109297. /**
  109298. * Specifies the metallic scalar of the metallic/roughness workflow.
  109299. * Can also be used to scale the metalness values of the metallic texture.
  109300. */
  109301. metallic: Nullable<number>;
  109302. /**
  109303. * Specifies the roughness scalar of the metallic/roughness workflow.
  109304. * Can also be used to scale the roughness values of the metallic texture.
  109305. */
  109306. roughness: Nullable<number>;
  109307. /**
  109308. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  109309. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  109310. */
  109311. microSurfaceTexture: BaseTexture;
  109312. /**
  109313. * Stores surface normal data used to displace a mesh in a texture.
  109314. */
  109315. bumpTexture: BaseTexture;
  109316. /**
  109317. * Stores the pre-calculated light information of a mesh in a texture.
  109318. */
  109319. lightmapTexture: BaseTexture;
  109320. /**
  109321. * Stores the refracted light information in a texture.
  109322. */
  109323. refractionTexture: Nullable<BaseTexture>;
  109324. /**
  109325. * The color of a material in ambient lighting.
  109326. */
  109327. ambientColor: Color3;
  109328. /**
  109329. * AKA Diffuse Color in other nomenclature.
  109330. */
  109331. albedoColor: Color3;
  109332. /**
  109333. * AKA Specular Color in other nomenclature.
  109334. */
  109335. reflectivityColor: Color3;
  109336. /**
  109337. * The color reflected from the material.
  109338. */
  109339. reflectionColor: Color3;
  109340. /**
  109341. * The color emitted from the material.
  109342. */
  109343. emissiveColor: Color3;
  109344. /**
  109345. * AKA Glossiness in other nomenclature.
  109346. */
  109347. microSurface: number;
  109348. /**
  109349. * source material index of refraction (IOR)' / 'destination material IOR.
  109350. */
  109351. indexOfRefraction: number;
  109352. /**
  109353. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  109354. */
  109355. invertRefractionY: boolean;
  109356. /**
  109357. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  109358. * Materials half opaque for instance using refraction could benefit from this control.
  109359. */
  109360. linkRefractionWithTransparency: boolean;
  109361. /**
  109362. * If true, the light map contains occlusion information instead of lighting info.
  109363. */
  109364. useLightmapAsShadowmap: boolean;
  109365. /**
  109366. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  109367. */
  109368. useAlphaFromAlbedoTexture: boolean;
  109369. /**
  109370. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  109371. */
  109372. forceAlphaTest: boolean;
  109373. /**
  109374. * Defines the alpha limits in alpha test mode.
  109375. */
  109376. alphaCutOff: number;
  109377. /**
  109378. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  109379. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  109380. */
  109381. useSpecularOverAlpha: boolean;
  109382. /**
  109383. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  109384. */
  109385. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  109386. /**
  109387. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  109388. */
  109389. useRoughnessFromMetallicTextureAlpha: boolean;
  109390. /**
  109391. * Specifies if the metallic texture contains the roughness information in its green channel.
  109392. */
  109393. useRoughnessFromMetallicTextureGreen: boolean;
  109394. /**
  109395. * Specifies if the metallic texture contains the metallness information in its blue channel.
  109396. */
  109397. useMetallnessFromMetallicTextureBlue: boolean;
  109398. /**
  109399. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  109400. */
  109401. useAmbientOcclusionFromMetallicTextureRed: boolean;
  109402. /**
  109403. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  109404. */
  109405. useAmbientInGrayScale: boolean;
  109406. /**
  109407. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  109408. * The material will try to infer what glossiness each pixel should be.
  109409. */
  109410. useAutoMicroSurfaceFromReflectivityMap: boolean;
  109411. /**
  109412. * BJS is using an harcoded light falloff based on a manually sets up range.
  109413. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  109414. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  109415. */
  109416. /**
  109417. * BJS is using an harcoded light falloff based on a manually sets up range.
  109418. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  109419. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  109420. */
  109421. usePhysicalLightFalloff: boolean;
  109422. /**
  109423. * In order to support the falloff compatibility with gltf, a special mode has been added
  109424. * to reproduce the gltf light falloff.
  109425. */
  109426. /**
  109427. * In order to support the falloff compatibility with gltf, a special mode has been added
  109428. * to reproduce the gltf light falloff.
  109429. */
  109430. useGLTFLightFalloff: boolean;
  109431. /**
  109432. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  109433. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  109434. */
  109435. useRadianceOverAlpha: boolean;
  109436. /**
  109437. * Allows using an object space normal map (instead of tangent space).
  109438. */
  109439. useObjectSpaceNormalMap: boolean;
  109440. /**
  109441. * Allows using the bump map in parallax mode.
  109442. */
  109443. useParallax: boolean;
  109444. /**
  109445. * Allows using the bump map in parallax occlusion mode.
  109446. */
  109447. useParallaxOcclusion: boolean;
  109448. /**
  109449. * Controls the scale bias of the parallax mode.
  109450. */
  109451. parallaxScaleBias: number;
  109452. /**
  109453. * If sets to true, disables all the lights affecting the material.
  109454. */
  109455. disableLighting: boolean;
  109456. /**
  109457. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  109458. */
  109459. forceIrradianceInFragment: boolean;
  109460. /**
  109461. * Number of Simultaneous lights allowed on the material.
  109462. */
  109463. maxSimultaneousLights: number;
  109464. /**
  109465. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  109466. */
  109467. invertNormalMapX: boolean;
  109468. /**
  109469. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  109470. */
  109471. invertNormalMapY: boolean;
  109472. /**
  109473. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  109474. */
  109475. twoSidedLighting: boolean;
  109476. /**
  109477. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  109478. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  109479. */
  109480. useAlphaFresnel: boolean;
  109481. /**
  109482. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  109483. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  109484. */
  109485. useLinearAlphaFresnel: boolean;
  109486. /**
  109487. * Let user defines the brdf lookup texture used for IBL.
  109488. * A default 8bit version is embedded but you could point at :
  109489. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  109490. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  109491. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  109492. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  109493. */
  109494. environmentBRDFTexture: Nullable<BaseTexture>;
  109495. /**
  109496. * Force normal to face away from face.
  109497. */
  109498. forceNormalForward: boolean;
  109499. /**
  109500. * Enables specular anti aliasing in the PBR shader.
  109501. * It will both interacts on the Geometry for analytical and IBL lighting.
  109502. * It also prefilter the roughness map based on the bump values.
  109503. */
  109504. enableSpecularAntiAliasing: boolean;
  109505. /**
  109506. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  109507. * makes the reflect vector face the model (under horizon).
  109508. */
  109509. useHorizonOcclusion: boolean;
  109510. /**
  109511. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  109512. * too much the area relying on ambient texture to define their ambient occlusion.
  109513. */
  109514. useRadianceOcclusion: boolean;
  109515. /**
  109516. * If set to true, no lighting calculations will be applied.
  109517. */
  109518. unlit: boolean;
  109519. /**
  109520. * Gets the image processing configuration used either in this material.
  109521. */
  109522. /**
  109523. * Sets the Default image processing configuration used either in the this material.
  109524. *
  109525. * If sets to null, the scene one is in use.
  109526. */
  109527. imageProcessingConfiguration: ImageProcessingConfiguration;
  109528. /**
  109529. * Gets wether the color curves effect is enabled.
  109530. */
  109531. /**
  109532. * Sets wether the color curves effect is enabled.
  109533. */
  109534. cameraColorCurvesEnabled: boolean;
  109535. /**
  109536. * Gets wether the color grading effect is enabled.
  109537. */
  109538. /**
  109539. * Gets wether the color grading effect is enabled.
  109540. */
  109541. cameraColorGradingEnabled: boolean;
  109542. /**
  109543. * Gets wether tonemapping is enabled or not.
  109544. */
  109545. /**
  109546. * Sets wether tonemapping is enabled or not
  109547. */
  109548. cameraToneMappingEnabled: boolean;
  109549. /**
  109550. * The camera exposure used on this material.
  109551. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109552. * This corresponds to a photographic exposure.
  109553. */
  109554. /**
  109555. * The camera exposure used on this material.
  109556. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109557. * This corresponds to a photographic exposure.
  109558. */
  109559. cameraExposure: number;
  109560. /**
  109561. * Gets The camera contrast used on this material.
  109562. */
  109563. /**
  109564. * Sets The camera contrast used on this material.
  109565. */
  109566. cameraContrast: number;
  109567. /**
  109568. * Gets the Color Grading 2D Lookup Texture.
  109569. */
  109570. /**
  109571. * Sets the Color Grading 2D Lookup Texture.
  109572. */
  109573. cameraColorGradingTexture: Nullable<BaseTexture>;
  109574. /**
  109575. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109576. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109577. * 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;
  109578. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109579. */
  109580. /**
  109581. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109582. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109583. * 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;
  109584. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109585. */
  109586. cameraColorCurves: Nullable<ColorCurves>;
  109587. /**
  109588. * Instantiates a new PBRMaterial instance.
  109589. *
  109590. * @param name The material name
  109591. * @param scene The scene the material will be use in.
  109592. */
  109593. constructor(name: string, scene: Scene);
  109594. /**
  109595. * Returns the name of this material class.
  109596. */
  109597. getClassName(): string;
  109598. /**
  109599. * Makes a duplicate of the current material.
  109600. * @param name - name to use for the new material.
  109601. */
  109602. clone(name: string): PBRMaterial;
  109603. /**
  109604. * Serializes this PBR Material.
  109605. * @returns - An object with the serialized material.
  109606. */
  109607. serialize(): any;
  109608. /**
  109609. * Parses a PBR Material from a serialized object.
  109610. * @param source - Serialized object.
  109611. * @param scene - BJS scene instance.
  109612. * @param rootUrl - url for the scene object
  109613. * @returns - PBRMaterial
  109614. */
  109615. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  109616. }
  109617. }
  109618. declare module BABYLON {
  109619. /**
  109620. * Direct draw surface info
  109621. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  109622. */
  109623. export interface DDSInfo {
  109624. /**
  109625. * Width of the texture
  109626. */
  109627. width: number;
  109628. /**
  109629. * Width of the texture
  109630. */
  109631. height: number;
  109632. /**
  109633. * Number of Mipmaps for the texture
  109634. * @see https://en.wikipedia.org/wiki/Mipmap
  109635. */
  109636. mipmapCount: number;
  109637. /**
  109638. * If the textures format is a known fourCC format
  109639. * @see https://www.fourcc.org/
  109640. */
  109641. isFourCC: boolean;
  109642. /**
  109643. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  109644. */
  109645. isRGB: boolean;
  109646. /**
  109647. * If the texture is a lumincance format
  109648. */
  109649. isLuminance: boolean;
  109650. /**
  109651. * If this is a cube texture
  109652. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  109653. */
  109654. isCube: boolean;
  109655. /**
  109656. * If the texture is a compressed format eg. FOURCC_DXT1
  109657. */
  109658. isCompressed: boolean;
  109659. /**
  109660. * The dxgiFormat of the texture
  109661. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  109662. */
  109663. dxgiFormat: number;
  109664. /**
  109665. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  109666. */
  109667. textureType: number;
  109668. /**
  109669. * Sphericle polynomial created for the dds texture
  109670. */
  109671. sphericalPolynomial?: SphericalPolynomial;
  109672. }
  109673. /**
  109674. * Class used to provide DDS decompression tools
  109675. */
  109676. export class DDSTools {
  109677. /**
  109678. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  109679. */
  109680. static StoreLODInAlphaChannel: boolean;
  109681. /**
  109682. * Gets DDS information from an array buffer
  109683. * @param arrayBuffer defines the array buffer to read data from
  109684. * @returns the DDS information
  109685. */
  109686. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  109687. private static _FloatView;
  109688. private static _Int32View;
  109689. private static _ToHalfFloat;
  109690. private static _FromHalfFloat;
  109691. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  109692. private static _GetHalfFloatRGBAArrayBuffer;
  109693. private static _GetFloatRGBAArrayBuffer;
  109694. private static _GetFloatAsUIntRGBAArrayBuffer;
  109695. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  109696. private static _GetRGBAArrayBuffer;
  109697. private static _ExtractLongWordOrder;
  109698. private static _GetRGBArrayBuffer;
  109699. private static _GetLuminanceArrayBuffer;
  109700. /**
  109701. * Uploads DDS Levels to a Babylon Texture
  109702. * @hidden
  109703. */
  109704. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  109705. }
  109706. interface Engine {
  109707. /**
  109708. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  109709. * @param rootUrl defines the url where the file to load is located
  109710. * @param scene defines the current scene
  109711. * @param lodScale defines scale to apply to the mip map selection
  109712. * @param lodOffset defines offset to apply to the mip map selection
  109713. * @param onLoad defines an optional callback raised when the texture is loaded
  109714. * @param onError defines an optional callback raised if there is an issue to load the texture
  109715. * @param format defines the format of the data
  109716. * @param forcedExtension defines the extension to use to pick the right loader
  109717. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  109718. * @returns the cube texture as an InternalTexture
  109719. */
  109720. 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;
  109721. }
  109722. }
  109723. declare module BABYLON {
  109724. /**
  109725. * Implementation of the DDS Texture Loader.
  109726. * @hidden
  109727. */
  109728. export class _DDSTextureLoader implements IInternalTextureLoader {
  109729. /**
  109730. * Defines wether the loader supports cascade loading the different faces.
  109731. */
  109732. readonly supportCascades: boolean;
  109733. /**
  109734. * This returns if the loader support the current file information.
  109735. * @param extension defines the file extension of the file being loaded
  109736. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109737. * @param fallback defines the fallback internal texture if any
  109738. * @param isBase64 defines whether the texture is encoded as a base64
  109739. * @param isBuffer defines whether the texture data are stored as a buffer
  109740. * @returns true if the loader can load the specified file
  109741. */
  109742. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109743. /**
  109744. * Transform the url before loading if required.
  109745. * @param rootUrl the url of the texture
  109746. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109747. * @returns the transformed texture
  109748. */
  109749. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109750. /**
  109751. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109752. * @param rootUrl the url of the texture
  109753. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109754. * @returns the fallback texture
  109755. */
  109756. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109757. /**
  109758. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109759. * @param data contains the texture data
  109760. * @param texture defines the BabylonJS internal texture
  109761. * @param createPolynomials will be true if polynomials have been requested
  109762. * @param onLoad defines the callback to trigger once the texture is ready
  109763. * @param onError defines the callback to trigger in case of error
  109764. */
  109765. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109766. /**
  109767. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109768. * @param data contains the texture data
  109769. * @param texture defines the BabylonJS internal texture
  109770. * @param callback defines the method to call once ready to upload
  109771. */
  109772. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109773. }
  109774. }
  109775. declare module BABYLON {
  109776. /** @hidden */
  109777. export var rgbdEncodePixelShader: {
  109778. name: string;
  109779. shader: string;
  109780. };
  109781. }
  109782. declare module BABYLON {
  109783. /**
  109784. * Raw texture data and descriptor sufficient for WebGL texture upload
  109785. */
  109786. export interface EnvironmentTextureInfo {
  109787. /**
  109788. * Version of the environment map
  109789. */
  109790. version: number;
  109791. /**
  109792. * Width of image
  109793. */
  109794. width: number;
  109795. /**
  109796. * Irradiance information stored in the file.
  109797. */
  109798. irradiance: any;
  109799. /**
  109800. * Specular information stored in the file.
  109801. */
  109802. specular: any;
  109803. }
  109804. /**
  109805. * Sets of helpers addressing the serialization and deserialization of environment texture
  109806. * stored in a BabylonJS env file.
  109807. * Those files are usually stored as .env files.
  109808. */
  109809. export class EnvironmentTextureTools {
  109810. /**
  109811. * Magic number identifying the env file.
  109812. */
  109813. private static _MagicBytes;
  109814. /**
  109815. * Gets the environment info from an env file.
  109816. * @param data The array buffer containing the .env bytes.
  109817. * @returns the environment file info (the json header) if successfully parsed.
  109818. */
  109819. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  109820. /**
  109821. * Creates an environment texture from a loaded cube texture.
  109822. * @param texture defines the cube texture to convert in env file
  109823. * @return a promise containing the environment data if succesfull.
  109824. */
  109825. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  109826. /**
  109827. * Creates a JSON representation of the spherical data.
  109828. * @param texture defines the texture containing the polynomials
  109829. * @return the JSON representation of the spherical info
  109830. */
  109831. private static _CreateEnvTextureIrradiance;
  109832. /**
  109833. * Uploads the texture info contained in the env file to the GPU.
  109834. * @param texture defines the internal texture to upload to
  109835. * @param arrayBuffer defines the buffer cotaining the data to load
  109836. * @param info defines the texture info retrieved through the GetEnvInfo method
  109837. * @returns a promise
  109838. */
  109839. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  109840. /**
  109841. * Uploads the levels of image data to the GPU.
  109842. * @param texture defines the internal texture to upload to
  109843. * @param imageData defines the array buffer views of image data [mipmap][face]
  109844. * @returns a promise
  109845. */
  109846. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  109847. /**
  109848. * Uploads spherical polynomials information to the texture.
  109849. * @param texture defines the texture we are trying to upload the information to
  109850. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  109851. */
  109852. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  109853. /** @hidden */
  109854. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109855. }
  109856. }
  109857. declare module BABYLON {
  109858. /**
  109859. * Implementation of the ENV Texture Loader.
  109860. * @hidden
  109861. */
  109862. export class _ENVTextureLoader implements IInternalTextureLoader {
  109863. /**
  109864. * Defines wether the loader supports cascade loading the different faces.
  109865. */
  109866. readonly supportCascades: boolean;
  109867. /**
  109868. * This returns if the loader support the current file information.
  109869. * @param extension defines the file extension of the file being loaded
  109870. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109871. * @param fallback defines the fallback internal texture if any
  109872. * @param isBase64 defines whether the texture is encoded as a base64
  109873. * @param isBuffer defines whether the texture data are stored as a buffer
  109874. * @returns true if the loader can load the specified file
  109875. */
  109876. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109877. /**
  109878. * Transform the url before loading if required.
  109879. * @param rootUrl the url of the texture
  109880. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109881. * @returns the transformed texture
  109882. */
  109883. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109884. /**
  109885. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109886. * @param rootUrl the url of the texture
  109887. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109888. * @returns the fallback texture
  109889. */
  109890. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109891. /**
  109892. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109893. * @param data contains the texture data
  109894. * @param texture defines the BabylonJS internal texture
  109895. * @param createPolynomials will be true if polynomials have been requested
  109896. * @param onLoad defines the callback to trigger once the texture is ready
  109897. * @param onError defines the callback to trigger in case of error
  109898. */
  109899. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109900. /**
  109901. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109902. * @param data contains the texture data
  109903. * @param texture defines the BabylonJS internal texture
  109904. * @param callback defines the method to call once ready to upload
  109905. */
  109906. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109907. }
  109908. }
  109909. declare module BABYLON {
  109910. /**
  109911. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  109912. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  109913. */
  109914. export class KhronosTextureContainer {
  109915. /** contents of the KTX container file */
  109916. arrayBuffer: any;
  109917. private static HEADER_LEN;
  109918. private static COMPRESSED_2D;
  109919. private static COMPRESSED_3D;
  109920. private static TEX_2D;
  109921. private static TEX_3D;
  109922. /**
  109923. * Gets the openGL type
  109924. */
  109925. glType: number;
  109926. /**
  109927. * Gets the openGL type size
  109928. */
  109929. glTypeSize: number;
  109930. /**
  109931. * Gets the openGL format
  109932. */
  109933. glFormat: number;
  109934. /**
  109935. * Gets the openGL internal format
  109936. */
  109937. glInternalFormat: number;
  109938. /**
  109939. * Gets the base internal format
  109940. */
  109941. glBaseInternalFormat: number;
  109942. /**
  109943. * Gets image width in pixel
  109944. */
  109945. pixelWidth: number;
  109946. /**
  109947. * Gets image height in pixel
  109948. */
  109949. pixelHeight: number;
  109950. /**
  109951. * Gets image depth in pixels
  109952. */
  109953. pixelDepth: number;
  109954. /**
  109955. * Gets the number of array elements
  109956. */
  109957. numberOfArrayElements: number;
  109958. /**
  109959. * Gets the number of faces
  109960. */
  109961. numberOfFaces: number;
  109962. /**
  109963. * Gets the number of mipmap levels
  109964. */
  109965. numberOfMipmapLevels: number;
  109966. /**
  109967. * Gets the bytes of key value data
  109968. */
  109969. bytesOfKeyValueData: number;
  109970. /**
  109971. * Gets the load type
  109972. */
  109973. loadType: number;
  109974. /**
  109975. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  109976. */
  109977. isInvalid: boolean;
  109978. /**
  109979. * Creates a new KhronosTextureContainer
  109980. * @param arrayBuffer contents of the KTX container file
  109981. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  109982. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  109983. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  109984. */
  109985. constructor(
  109986. /** contents of the KTX container file */
  109987. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  109988. /**
  109989. * Uploads KTX content to a Babylon Texture.
  109990. * It is assumed that the texture has already been created & is currently bound
  109991. * @hidden
  109992. */
  109993. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  109994. private _upload2DCompressedLevels;
  109995. }
  109996. }
  109997. declare module BABYLON {
  109998. /**
  109999. * Implementation of the KTX Texture Loader.
  110000. * @hidden
  110001. */
  110002. export class _KTXTextureLoader implements IInternalTextureLoader {
  110003. /**
  110004. * Defines wether the loader supports cascade loading the different faces.
  110005. */
  110006. readonly supportCascades: boolean;
  110007. /**
  110008. * This returns if the loader support the current file information.
  110009. * @param extension defines the file extension of the file being loaded
  110010. * @param textureFormatInUse defines the current compressed format in use iun the engine
  110011. * @param fallback defines the fallback internal texture if any
  110012. * @param isBase64 defines whether the texture is encoded as a base64
  110013. * @param isBuffer defines whether the texture data are stored as a buffer
  110014. * @returns true if the loader can load the specified file
  110015. */
  110016. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  110017. /**
  110018. * Transform the url before loading if required.
  110019. * @param rootUrl the url of the texture
  110020. * @param textureFormatInUse defines the current compressed format in use iun the engine
  110021. * @returns the transformed texture
  110022. */
  110023. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  110024. /**
  110025. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  110026. * @param rootUrl the url of the texture
  110027. * @param textureFormatInUse defines the current compressed format in use iun the engine
  110028. * @returns the fallback texture
  110029. */
  110030. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  110031. /**
  110032. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  110033. * @param data contains the texture data
  110034. * @param texture defines the BabylonJS internal texture
  110035. * @param createPolynomials will be true if polynomials have been requested
  110036. * @param onLoad defines the callback to trigger once the texture is ready
  110037. * @param onError defines the callback to trigger in case of error
  110038. */
  110039. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  110040. /**
  110041. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  110042. * @param data contains the texture data
  110043. * @param texture defines the BabylonJS internal texture
  110044. * @param callback defines the method to call once ready to upload
  110045. */
  110046. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  110047. }
  110048. }
  110049. declare module BABYLON {
  110050. /** @hidden */
  110051. export var _forceSceneHelpersToBundle: boolean;
  110052. interface Scene {
  110053. /**
  110054. * Creates a default light for the scene.
  110055. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  110056. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  110057. */
  110058. createDefaultLight(replace?: boolean): void;
  110059. /**
  110060. * Creates a default camera for the scene.
  110061. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  110062. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  110063. * @param replace has default false, when true replaces the active camera in the scene
  110064. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  110065. */
  110066. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  110067. /**
  110068. * Creates a default camera and a default light.
  110069. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  110070. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  110071. * @param replace has the default false, when true replaces the active camera/light in the scene
  110072. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  110073. */
  110074. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  110075. /**
  110076. * Creates a new sky box
  110077. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  110078. * @param environmentTexture defines the texture to use as environment texture
  110079. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  110080. * @param scale defines the overall scale of the skybox
  110081. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  110082. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  110083. * @returns a new mesh holding the sky box
  110084. */
  110085. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  110086. /**
  110087. * Creates a new environment
  110088. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  110089. * @param options defines the options you can use to configure the environment
  110090. * @returns the new EnvironmentHelper
  110091. */
  110092. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  110093. /**
  110094. * Creates a new VREXperienceHelper
  110095. * @see http://doc.babylonjs.com/how_to/webvr_helper
  110096. * @param webVROptions defines the options used to create the new VREXperienceHelper
  110097. * @returns a new VREXperienceHelper
  110098. */
  110099. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  110100. /**
  110101. * Creates a new XREXperienceHelper
  110102. * @see http://doc.babylonjs.com/how_to/webxr
  110103. * @returns a promise for a new XREXperienceHelper
  110104. */
  110105. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  110106. }
  110107. }
  110108. declare module BABYLON {
  110109. /**
  110110. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  110111. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  110112. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  110113. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  110114. */
  110115. export class VideoDome extends TransformNode {
  110116. /**
  110117. * Define the video source as a Monoscopic panoramic 360 video.
  110118. */
  110119. static readonly MODE_MONOSCOPIC: number;
  110120. /**
  110121. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  110122. */
  110123. static readonly MODE_TOPBOTTOM: number;
  110124. /**
  110125. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  110126. */
  110127. static readonly MODE_SIDEBYSIDE: number;
  110128. private _useDirectMapping;
  110129. /**
  110130. * The video texture being displayed on the sphere
  110131. */
  110132. protected _videoTexture: VideoTexture;
  110133. /**
  110134. * Gets the video texture being displayed on the sphere
  110135. */
  110136. readonly videoTexture: VideoTexture;
  110137. /**
  110138. * The skybox material
  110139. */
  110140. protected _material: BackgroundMaterial;
  110141. /**
  110142. * The surface used for the skybox
  110143. */
  110144. protected _mesh: Mesh;
  110145. /**
  110146. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  110147. * Also see the options.resolution property.
  110148. */
  110149. fovMultiplier: number;
  110150. private _videoMode;
  110151. /**
  110152. * Gets or set the current video mode for the video. It can be:
  110153. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  110154. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  110155. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  110156. */
  110157. videoMode: number;
  110158. /**
  110159. * Oberserver used in Stereoscopic VR Mode.
  110160. */
  110161. private _onBeforeCameraRenderObserver;
  110162. /**
  110163. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  110164. * @param name Element's name, child elements will append suffixes for their own names.
  110165. * @param urlsOrVideo defines the url(s) or the video element to use
  110166. * @param options An object containing optional or exposed sub element properties
  110167. */
  110168. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  110169. resolution?: number;
  110170. clickToPlay?: boolean;
  110171. autoPlay?: boolean;
  110172. loop?: boolean;
  110173. size?: number;
  110174. poster?: string;
  110175. faceForward?: boolean;
  110176. useDirectMapping?: boolean;
  110177. }, scene: Scene);
  110178. private _changeVideoMode;
  110179. /**
  110180. * Releases resources associated with this node.
  110181. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  110182. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  110183. */
  110184. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  110185. }
  110186. }
  110187. declare module BABYLON {
  110188. /**
  110189. * This class can be used to get instrumentation data from a Babylon engine
  110190. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  110191. */
  110192. export class EngineInstrumentation implements IDisposable {
  110193. /**
  110194. * Define the instrumented engine.
  110195. */
  110196. engine: Engine;
  110197. private _captureGPUFrameTime;
  110198. private _gpuFrameTimeToken;
  110199. private _gpuFrameTime;
  110200. private _captureShaderCompilationTime;
  110201. private _shaderCompilationTime;
  110202. private _onBeginFrameObserver;
  110203. private _onEndFrameObserver;
  110204. private _onBeforeShaderCompilationObserver;
  110205. private _onAfterShaderCompilationObserver;
  110206. /**
  110207. * Gets the perf counter used for GPU frame time
  110208. */
  110209. readonly gpuFrameTimeCounter: PerfCounter;
  110210. /**
  110211. * Gets the GPU frame time capture status
  110212. */
  110213. /**
  110214. * Enable or disable the GPU frame time capture
  110215. */
  110216. captureGPUFrameTime: boolean;
  110217. /**
  110218. * Gets the perf counter used for shader compilation time
  110219. */
  110220. readonly shaderCompilationTimeCounter: PerfCounter;
  110221. /**
  110222. * Gets the shader compilation time capture status
  110223. */
  110224. /**
  110225. * Enable or disable the shader compilation time capture
  110226. */
  110227. captureShaderCompilationTime: boolean;
  110228. /**
  110229. * Instantiates a new engine instrumentation.
  110230. * This class can be used to get instrumentation data from a Babylon engine
  110231. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  110232. * @param engine Defines the engine to instrument
  110233. */
  110234. constructor(
  110235. /**
  110236. * Define the instrumented engine.
  110237. */
  110238. engine: Engine);
  110239. /**
  110240. * Dispose and release associated resources.
  110241. */
  110242. dispose(): void;
  110243. }
  110244. }
  110245. declare module BABYLON {
  110246. /**
  110247. * This class can be used to get instrumentation data from a Babylon engine
  110248. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  110249. */
  110250. export class SceneInstrumentation implements IDisposable {
  110251. /**
  110252. * Defines the scene to instrument
  110253. */
  110254. scene: Scene;
  110255. private _captureActiveMeshesEvaluationTime;
  110256. private _activeMeshesEvaluationTime;
  110257. private _captureRenderTargetsRenderTime;
  110258. private _renderTargetsRenderTime;
  110259. private _captureFrameTime;
  110260. private _frameTime;
  110261. private _captureRenderTime;
  110262. private _renderTime;
  110263. private _captureInterFrameTime;
  110264. private _interFrameTime;
  110265. private _captureParticlesRenderTime;
  110266. private _particlesRenderTime;
  110267. private _captureSpritesRenderTime;
  110268. private _spritesRenderTime;
  110269. private _capturePhysicsTime;
  110270. private _physicsTime;
  110271. private _captureAnimationsTime;
  110272. private _animationsTime;
  110273. private _captureCameraRenderTime;
  110274. private _cameraRenderTime;
  110275. private _onBeforeActiveMeshesEvaluationObserver;
  110276. private _onAfterActiveMeshesEvaluationObserver;
  110277. private _onBeforeRenderTargetsRenderObserver;
  110278. private _onAfterRenderTargetsRenderObserver;
  110279. private _onAfterRenderObserver;
  110280. private _onBeforeDrawPhaseObserver;
  110281. private _onAfterDrawPhaseObserver;
  110282. private _onBeforeAnimationsObserver;
  110283. private _onBeforeParticlesRenderingObserver;
  110284. private _onAfterParticlesRenderingObserver;
  110285. private _onBeforeSpritesRenderingObserver;
  110286. private _onAfterSpritesRenderingObserver;
  110287. private _onBeforePhysicsObserver;
  110288. private _onAfterPhysicsObserver;
  110289. private _onAfterAnimationsObserver;
  110290. private _onBeforeCameraRenderObserver;
  110291. private _onAfterCameraRenderObserver;
  110292. /**
  110293. * Gets the perf counter used for active meshes evaluation time
  110294. */
  110295. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  110296. /**
  110297. * Gets the active meshes evaluation time capture status
  110298. */
  110299. /**
  110300. * Enable or disable the active meshes evaluation time capture
  110301. */
  110302. captureActiveMeshesEvaluationTime: boolean;
  110303. /**
  110304. * Gets the perf counter used for render targets render time
  110305. */
  110306. readonly renderTargetsRenderTimeCounter: PerfCounter;
  110307. /**
  110308. * Gets the render targets render time capture status
  110309. */
  110310. /**
  110311. * Enable or disable the render targets render time capture
  110312. */
  110313. captureRenderTargetsRenderTime: boolean;
  110314. /**
  110315. * Gets the perf counter used for particles render time
  110316. */
  110317. readonly particlesRenderTimeCounter: PerfCounter;
  110318. /**
  110319. * Gets the particles render time capture status
  110320. */
  110321. /**
  110322. * Enable or disable the particles render time capture
  110323. */
  110324. captureParticlesRenderTime: boolean;
  110325. /**
  110326. * Gets the perf counter used for sprites render time
  110327. */
  110328. readonly spritesRenderTimeCounter: PerfCounter;
  110329. /**
  110330. * Gets the sprites render time capture status
  110331. */
  110332. /**
  110333. * Enable or disable the sprites render time capture
  110334. */
  110335. captureSpritesRenderTime: boolean;
  110336. /**
  110337. * Gets the perf counter used for physics time
  110338. */
  110339. readonly physicsTimeCounter: PerfCounter;
  110340. /**
  110341. * Gets the physics time capture status
  110342. */
  110343. /**
  110344. * Enable or disable the physics time capture
  110345. */
  110346. capturePhysicsTime: boolean;
  110347. /**
  110348. * Gets the perf counter used for animations time
  110349. */
  110350. readonly animationsTimeCounter: PerfCounter;
  110351. /**
  110352. * Gets the animations time capture status
  110353. */
  110354. /**
  110355. * Enable or disable the animations time capture
  110356. */
  110357. captureAnimationsTime: boolean;
  110358. /**
  110359. * Gets the perf counter used for frame time capture
  110360. */
  110361. readonly frameTimeCounter: PerfCounter;
  110362. /**
  110363. * Gets the frame time capture status
  110364. */
  110365. /**
  110366. * Enable or disable the frame time capture
  110367. */
  110368. captureFrameTime: boolean;
  110369. /**
  110370. * Gets the perf counter used for inter-frames time capture
  110371. */
  110372. readonly interFrameTimeCounter: PerfCounter;
  110373. /**
  110374. * Gets the inter-frames time capture status
  110375. */
  110376. /**
  110377. * Enable or disable the inter-frames time capture
  110378. */
  110379. captureInterFrameTime: boolean;
  110380. /**
  110381. * Gets the perf counter used for render time capture
  110382. */
  110383. readonly renderTimeCounter: PerfCounter;
  110384. /**
  110385. * Gets the render time capture status
  110386. */
  110387. /**
  110388. * Enable or disable the render time capture
  110389. */
  110390. captureRenderTime: boolean;
  110391. /**
  110392. * Gets the perf counter used for camera render time capture
  110393. */
  110394. readonly cameraRenderTimeCounter: PerfCounter;
  110395. /**
  110396. * Gets the camera render time capture status
  110397. */
  110398. /**
  110399. * Enable or disable the camera render time capture
  110400. */
  110401. captureCameraRenderTime: boolean;
  110402. /**
  110403. * Gets the perf counter used for draw calls
  110404. */
  110405. readonly drawCallsCounter: PerfCounter;
  110406. /**
  110407. * Instantiates a new scene instrumentation.
  110408. * This class can be used to get instrumentation data from a Babylon engine
  110409. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  110410. * @param scene Defines the scene to instrument
  110411. */
  110412. constructor(
  110413. /**
  110414. * Defines the scene to instrument
  110415. */
  110416. scene: Scene);
  110417. /**
  110418. * Dispose and release associated resources.
  110419. */
  110420. dispose(): void;
  110421. }
  110422. }
  110423. declare module BABYLON {
  110424. /** @hidden */
  110425. export var glowMapGenerationPixelShader: {
  110426. name: string;
  110427. shader: string;
  110428. };
  110429. }
  110430. declare module BABYLON {
  110431. /** @hidden */
  110432. export var glowMapGenerationVertexShader: {
  110433. name: string;
  110434. shader: string;
  110435. };
  110436. }
  110437. declare module BABYLON {
  110438. /**
  110439. * Effect layer options. This helps customizing the behaviour
  110440. * of the effect layer.
  110441. */
  110442. export interface IEffectLayerOptions {
  110443. /**
  110444. * Multiplication factor apply to the canvas size to compute the render target size
  110445. * used to generated the objects (the smaller the faster).
  110446. */
  110447. mainTextureRatio: number;
  110448. /**
  110449. * Enforces a fixed size texture to ensure effect stability across devices.
  110450. */
  110451. mainTextureFixedSize?: number;
  110452. /**
  110453. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  110454. */
  110455. alphaBlendingMode: number;
  110456. /**
  110457. * The camera attached to the layer.
  110458. */
  110459. camera: Nullable<Camera>;
  110460. /**
  110461. * The rendering group to draw the layer in.
  110462. */
  110463. renderingGroupId: number;
  110464. }
  110465. /**
  110466. * The effect layer Helps adding post process effect blended with the main pass.
  110467. *
  110468. * This can be for instance use to generate glow or higlight effects on the scene.
  110469. *
  110470. * The effect layer class can not be used directly and is intented to inherited from to be
  110471. * customized per effects.
  110472. */
  110473. export abstract class EffectLayer {
  110474. private _vertexBuffers;
  110475. private _indexBuffer;
  110476. private _cachedDefines;
  110477. private _effectLayerMapGenerationEffect;
  110478. private _effectLayerOptions;
  110479. private _mergeEffect;
  110480. protected _scene: Scene;
  110481. protected _engine: Engine;
  110482. protected _maxSize: number;
  110483. protected _mainTextureDesiredSize: ISize;
  110484. protected _mainTexture: RenderTargetTexture;
  110485. protected _shouldRender: boolean;
  110486. protected _postProcesses: PostProcess[];
  110487. protected _textures: BaseTexture[];
  110488. protected _emissiveTextureAndColor: {
  110489. texture: Nullable<BaseTexture>;
  110490. color: Color4;
  110491. };
  110492. /**
  110493. * The name of the layer
  110494. */
  110495. name: string;
  110496. /**
  110497. * The clear color of the texture used to generate the glow map.
  110498. */
  110499. neutralColor: Color4;
  110500. /**
  110501. * Specifies wether the highlight layer is enabled or not.
  110502. */
  110503. isEnabled: boolean;
  110504. /**
  110505. * Gets the camera attached to the layer.
  110506. */
  110507. readonly camera: Nullable<Camera>;
  110508. /**
  110509. * Gets the rendering group id the layer should render in.
  110510. */
  110511. renderingGroupId: number;
  110512. /**
  110513. * An event triggered when the effect layer has been disposed.
  110514. */
  110515. onDisposeObservable: Observable<EffectLayer>;
  110516. /**
  110517. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  110518. */
  110519. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  110520. /**
  110521. * An event triggered when the generated texture is being merged in the scene.
  110522. */
  110523. onBeforeComposeObservable: Observable<EffectLayer>;
  110524. /**
  110525. * An event triggered when the generated texture has been merged in the scene.
  110526. */
  110527. onAfterComposeObservable: Observable<EffectLayer>;
  110528. /**
  110529. * An event triggered when the efffect layer changes its size.
  110530. */
  110531. onSizeChangedObservable: Observable<EffectLayer>;
  110532. /** @hidden */
  110533. static _SceneComponentInitialization: (scene: Scene) => void;
  110534. /**
  110535. * Instantiates a new effect Layer and references it in the scene.
  110536. * @param name The name of the layer
  110537. * @param scene The scene to use the layer in
  110538. */
  110539. constructor(
  110540. /** The Friendly of the effect in the scene */
  110541. name: string, scene: Scene);
  110542. /**
  110543. * Get the effect name of the layer.
  110544. * @return The effect name
  110545. */
  110546. abstract getEffectName(): string;
  110547. /**
  110548. * Checks for the readiness of the element composing the layer.
  110549. * @param subMesh the mesh to check for
  110550. * @param useInstances specify wether or not to use instances to render the mesh
  110551. * @return true if ready otherwise, false
  110552. */
  110553. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110554. /**
  110555. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  110556. * @returns true if the effect requires stencil during the main canvas render pass.
  110557. */
  110558. abstract needStencil(): boolean;
  110559. /**
  110560. * Create the merge effect. This is the shader use to blit the information back
  110561. * to the main canvas at the end of the scene rendering.
  110562. * @returns The effect containing the shader used to merge the effect on the main canvas
  110563. */
  110564. protected abstract _createMergeEffect(): Effect;
  110565. /**
  110566. * Creates the render target textures and post processes used in the effect layer.
  110567. */
  110568. protected abstract _createTextureAndPostProcesses(): void;
  110569. /**
  110570. * Implementation specific of rendering the generating effect on the main canvas.
  110571. * @param effect The effect used to render through
  110572. */
  110573. protected abstract _internalRender(effect: Effect): void;
  110574. /**
  110575. * Sets the required values for both the emissive texture and and the main color.
  110576. */
  110577. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110578. /**
  110579. * Free any resources and references associated to a mesh.
  110580. * Internal use
  110581. * @param mesh The mesh to free.
  110582. */
  110583. abstract _disposeMesh(mesh: Mesh): void;
  110584. /**
  110585. * Serializes this layer (Glow or Highlight for example)
  110586. * @returns a serialized layer object
  110587. */
  110588. abstract serialize?(): any;
  110589. /**
  110590. * Initializes the effect layer with the required options.
  110591. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  110592. */
  110593. protected _init(options: Partial<IEffectLayerOptions>): void;
  110594. /**
  110595. * Generates the index buffer of the full screen quad blending to the main canvas.
  110596. */
  110597. private _generateIndexBuffer;
  110598. /**
  110599. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  110600. */
  110601. private _generateVertexBuffer;
  110602. /**
  110603. * Sets the main texture desired size which is the closest power of two
  110604. * of the engine canvas size.
  110605. */
  110606. private _setMainTextureSize;
  110607. /**
  110608. * Creates the main texture for the effect layer.
  110609. */
  110610. protected _createMainTexture(): void;
  110611. /**
  110612. * Adds specific effects defines.
  110613. * @param defines The defines to add specifics to.
  110614. */
  110615. protected _addCustomEffectDefines(defines: string[]): void;
  110616. /**
  110617. * Checks for the readiness of the element composing the layer.
  110618. * @param subMesh the mesh to check for
  110619. * @param useInstances specify wether or not to use instances to render the mesh
  110620. * @param emissiveTexture the associated emissive texture used to generate the glow
  110621. * @return true if ready otherwise, false
  110622. */
  110623. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  110624. /**
  110625. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  110626. */
  110627. render(): void;
  110628. /**
  110629. * Determine if a given mesh will be used in the current effect.
  110630. * @param mesh mesh to test
  110631. * @returns true if the mesh will be used
  110632. */
  110633. hasMesh(mesh: AbstractMesh): boolean;
  110634. /**
  110635. * Returns true if the layer contains information to display, otherwise false.
  110636. * @returns true if the glow layer should be rendered
  110637. */
  110638. shouldRender(): boolean;
  110639. /**
  110640. * Returns true if the mesh should render, otherwise false.
  110641. * @param mesh The mesh to render
  110642. * @returns true if it should render otherwise false
  110643. */
  110644. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  110645. /**
  110646. * Returns true if the mesh can be rendered, otherwise false.
  110647. * @param mesh The mesh to render
  110648. * @param material The material used on the mesh
  110649. * @returns true if it can be rendered otherwise false
  110650. */
  110651. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  110652. /**
  110653. * Returns true if the mesh should render, otherwise false.
  110654. * @param mesh The mesh to render
  110655. * @returns true if it should render otherwise false
  110656. */
  110657. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  110658. /**
  110659. * Renders the submesh passed in parameter to the generation map.
  110660. */
  110661. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  110662. /**
  110663. * Rebuild the required buffers.
  110664. * @hidden Internal use only.
  110665. */
  110666. _rebuild(): void;
  110667. /**
  110668. * Dispose only the render target textures and post process.
  110669. */
  110670. private _disposeTextureAndPostProcesses;
  110671. /**
  110672. * Dispose the highlight layer and free resources.
  110673. */
  110674. dispose(): void;
  110675. /**
  110676. * Gets the class name of the effect layer
  110677. * @returns the string with the class name of the effect layer
  110678. */
  110679. getClassName(): string;
  110680. /**
  110681. * Creates an effect layer from parsed effect layer data
  110682. * @param parsedEffectLayer defines effect layer data
  110683. * @param scene defines the current scene
  110684. * @param rootUrl defines the root URL containing the effect layer information
  110685. * @returns a parsed effect Layer
  110686. */
  110687. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  110688. }
  110689. }
  110690. declare module BABYLON {
  110691. interface AbstractScene {
  110692. /**
  110693. * The list of effect layers (highlights/glow) added to the scene
  110694. * @see http://doc.babylonjs.com/how_to/highlight_layer
  110695. * @see http://doc.babylonjs.com/how_to/glow_layer
  110696. */
  110697. effectLayers: Array<EffectLayer>;
  110698. /**
  110699. * Removes the given effect layer from this scene.
  110700. * @param toRemove defines the effect layer to remove
  110701. * @returns the index of the removed effect layer
  110702. */
  110703. removeEffectLayer(toRemove: EffectLayer): number;
  110704. /**
  110705. * Adds the given effect layer to this scene
  110706. * @param newEffectLayer defines the effect layer to add
  110707. */
  110708. addEffectLayer(newEffectLayer: EffectLayer): void;
  110709. }
  110710. /**
  110711. * Defines the layer scene component responsible to manage any effect layers
  110712. * in a given scene.
  110713. */
  110714. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  110715. /**
  110716. * The component name helpfull to identify the component in the list of scene components.
  110717. */
  110718. readonly name: string;
  110719. /**
  110720. * The scene the component belongs to.
  110721. */
  110722. scene: Scene;
  110723. private _engine;
  110724. private _renderEffects;
  110725. private _needStencil;
  110726. private _previousStencilState;
  110727. /**
  110728. * Creates a new instance of the component for the given scene
  110729. * @param scene Defines the scene to register the component in
  110730. */
  110731. constructor(scene: Scene);
  110732. /**
  110733. * Registers the component in a given scene
  110734. */
  110735. register(): void;
  110736. /**
  110737. * Rebuilds the elements related to this component in case of
  110738. * context lost for instance.
  110739. */
  110740. rebuild(): void;
  110741. /**
  110742. * Serializes the component data to the specified json object
  110743. * @param serializationObject The object to serialize to
  110744. */
  110745. serialize(serializationObject: any): void;
  110746. /**
  110747. * Adds all the elements from the container to the scene
  110748. * @param container the container holding the elements
  110749. */
  110750. addFromContainer(container: AbstractScene): void;
  110751. /**
  110752. * Removes all the elements in the container from the scene
  110753. * @param container contains the elements to remove
  110754. * @param dispose if the removed element should be disposed (default: false)
  110755. */
  110756. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110757. /**
  110758. * Disposes the component and the associated ressources.
  110759. */
  110760. dispose(): void;
  110761. private _isReadyForMesh;
  110762. private _renderMainTexture;
  110763. private _setStencil;
  110764. private _setStencilBack;
  110765. private _draw;
  110766. private _drawCamera;
  110767. private _drawRenderingGroup;
  110768. }
  110769. }
  110770. declare module BABYLON {
  110771. /** @hidden */
  110772. export var glowMapMergePixelShader: {
  110773. name: string;
  110774. shader: string;
  110775. };
  110776. }
  110777. declare module BABYLON {
  110778. /** @hidden */
  110779. export var glowMapMergeVertexShader: {
  110780. name: string;
  110781. shader: string;
  110782. };
  110783. }
  110784. declare module BABYLON {
  110785. interface AbstractScene {
  110786. /**
  110787. * Return a the first highlight layer of the scene with a given name.
  110788. * @param name The name of the highlight layer to look for.
  110789. * @return The highlight layer if found otherwise null.
  110790. */
  110791. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  110792. }
  110793. /**
  110794. * Glow layer options. This helps customizing the behaviour
  110795. * of the glow layer.
  110796. */
  110797. export interface IGlowLayerOptions {
  110798. /**
  110799. * Multiplication factor apply to the canvas size to compute the render target size
  110800. * used to generated the glowing objects (the smaller the faster).
  110801. */
  110802. mainTextureRatio: number;
  110803. /**
  110804. * Enforces a fixed size texture to ensure resize independant blur.
  110805. */
  110806. mainTextureFixedSize?: number;
  110807. /**
  110808. * How big is the kernel of the blur texture.
  110809. */
  110810. blurKernelSize: number;
  110811. /**
  110812. * The camera attached to the layer.
  110813. */
  110814. camera: Nullable<Camera>;
  110815. /**
  110816. * Enable MSAA by chosing the number of samples.
  110817. */
  110818. mainTextureSamples?: number;
  110819. /**
  110820. * The rendering group to draw the layer in.
  110821. */
  110822. renderingGroupId: number;
  110823. }
  110824. /**
  110825. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  110826. *
  110827. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  110828. * glowy meshes to your scene.
  110829. *
  110830. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  110831. */
  110832. export class GlowLayer extends EffectLayer {
  110833. /**
  110834. * Effect Name of the layer.
  110835. */
  110836. static readonly EffectName: string;
  110837. /**
  110838. * The default blur kernel size used for the glow.
  110839. */
  110840. static DefaultBlurKernelSize: number;
  110841. /**
  110842. * The default texture size ratio used for the glow.
  110843. */
  110844. static DefaultTextureRatio: number;
  110845. /**
  110846. * Sets the kernel size of the blur.
  110847. */
  110848. /**
  110849. * Gets the kernel size of the blur.
  110850. */
  110851. blurKernelSize: number;
  110852. /**
  110853. * Sets the glow intensity.
  110854. */
  110855. /**
  110856. * Gets the glow intensity.
  110857. */
  110858. intensity: number;
  110859. private _options;
  110860. private _intensity;
  110861. private _horizontalBlurPostprocess1;
  110862. private _verticalBlurPostprocess1;
  110863. private _horizontalBlurPostprocess2;
  110864. private _verticalBlurPostprocess2;
  110865. private _blurTexture1;
  110866. private _blurTexture2;
  110867. private _postProcesses1;
  110868. private _postProcesses2;
  110869. private _includedOnlyMeshes;
  110870. private _excludedMeshes;
  110871. /**
  110872. * Callback used to let the user override the color selection on a per mesh basis
  110873. */
  110874. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  110875. /**
  110876. * Callback used to let the user override the texture selection on a per mesh basis
  110877. */
  110878. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  110879. /**
  110880. * Instantiates a new glow Layer and references it to the scene.
  110881. * @param name The name of the layer
  110882. * @param scene The scene to use the layer in
  110883. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  110884. */
  110885. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  110886. /**
  110887. * Get the effect name of the layer.
  110888. * @return The effect name
  110889. */
  110890. getEffectName(): string;
  110891. /**
  110892. * Create the merge effect. This is the shader use to blit the information back
  110893. * to the main canvas at the end of the scene rendering.
  110894. */
  110895. protected _createMergeEffect(): Effect;
  110896. /**
  110897. * Creates the render target textures and post processes used in the glow layer.
  110898. */
  110899. protected _createTextureAndPostProcesses(): void;
  110900. /**
  110901. * Checks for the readiness of the element composing the layer.
  110902. * @param subMesh the mesh to check for
  110903. * @param useInstances specify wether or not to use instances to render the mesh
  110904. * @param emissiveTexture the associated emissive texture used to generate the glow
  110905. * @return true if ready otherwise, false
  110906. */
  110907. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110908. /**
  110909. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  110910. */
  110911. needStencil(): boolean;
  110912. /**
  110913. * Returns true if the mesh can be rendered, otherwise false.
  110914. * @param mesh The mesh to render
  110915. * @param material The material used on the mesh
  110916. * @returns true if it can be rendered otherwise false
  110917. */
  110918. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  110919. /**
  110920. * Implementation specific of rendering the generating effect on the main canvas.
  110921. * @param effect The effect used to render through
  110922. */
  110923. protected _internalRender(effect: Effect): void;
  110924. /**
  110925. * Sets the required values for both the emissive texture and and the main color.
  110926. */
  110927. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110928. /**
  110929. * Returns true if the mesh should render, otherwise false.
  110930. * @param mesh The mesh to render
  110931. * @returns true if it should render otherwise false
  110932. */
  110933. protected _shouldRenderMesh(mesh: Mesh): boolean;
  110934. /**
  110935. * Adds specific effects defines.
  110936. * @param defines The defines to add specifics to.
  110937. */
  110938. protected _addCustomEffectDefines(defines: string[]): void;
  110939. /**
  110940. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  110941. * @param mesh The mesh to exclude from the glow layer
  110942. */
  110943. addExcludedMesh(mesh: Mesh): void;
  110944. /**
  110945. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  110946. * @param mesh The mesh to remove
  110947. */
  110948. removeExcludedMesh(mesh: Mesh): void;
  110949. /**
  110950. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  110951. * @param mesh The mesh to include in the glow layer
  110952. */
  110953. addIncludedOnlyMesh(mesh: Mesh): void;
  110954. /**
  110955. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  110956. * @param mesh The mesh to remove
  110957. */
  110958. removeIncludedOnlyMesh(mesh: Mesh): void;
  110959. /**
  110960. * Determine if a given mesh will be used in the glow layer
  110961. * @param mesh The mesh to test
  110962. * @returns true if the mesh will be highlighted by the current glow layer
  110963. */
  110964. hasMesh(mesh: AbstractMesh): boolean;
  110965. /**
  110966. * Free any resources and references associated to a mesh.
  110967. * Internal use
  110968. * @param mesh The mesh to free.
  110969. * @hidden
  110970. */
  110971. _disposeMesh(mesh: Mesh): void;
  110972. /**
  110973. * Gets the class name of the effect layer
  110974. * @returns the string with the class name of the effect layer
  110975. */
  110976. getClassName(): string;
  110977. /**
  110978. * Serializes this glow layer
  110979. * @returns a serialized glow layer object
  110980. */
  110981. serialize(): any;
  110982. /**
  110983. * Creates a Glow Layer from parsed glow layer data
  110984. * @param parsedGlowLayer defines glow layer data
  110985. * @param scene defines the current scene
  110986. * @param rootUrl defines the root URL containing the glow layer information
  110987. * @returns a parsed Glow Layer
  110988. */
  110989. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  110990. }
  110991. }
  110992. declare module BABYLON {
  110993. /** @hidden */
  110994. export var glowBlurPostProcessPixelShader: {
  110995. name: string;
  110996. shader: string;
  110997. };
  110998. }
  110999. declare module BABYLON {
  111000. interface AbstractScene {
  111001. /**
  111002. * Return a the first highlight layer of the scene with a given name.
  111003. * @param name The name of the highlight layer to look for.
  111004. * @return The highlight layer if found otherwise null.
  111005. */
  111006. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  111007. }
  111008. /**
  111009. * Highlight layer options. This helps customizing the behaviour
  111010. * of the highlight layer.
  111011. */
  111012. export interface IHighlightLayerOptions {
  111013. /**
  111014. * Multiplication factor apply to the canvas size to compute the render target size
  111015. * used to generated the glowing objects (the smaller the faster).
  111016. */
  111017. mainTextureRatio: number;
  111018. /**
  111019. * Enforces a fixed size texture to ensure resize independant blur.
  111020. */
  111021. mainTextureFixedSize?: number;
  111022. /**
  111023. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  111024. * of the picture to blur (the smaller the faster).
  111025. */
  111026. blurTextureSizeRatio: number;
  111027. /**
  111028. * How big in texel of the blur texture is the vertical blur.
  111029. */
  111030. blurVerticalSize: number;
  111031. /**
  111032. * How big in texel of the blur texture is the horizontal blur.
  111033. */
  111034. blurHorizontalSize: number;
  111035. /**
  111036. * Alpha blending mode used to apply the blur. Default is combine.
  111037. */
  111038. alphaBlendingMode: number;
  111039. /**
  111040. * The camera attached to the layer.
  111041. */
  111042. camera: Nullable<Camera>;
  111043. /**
  111044. * Should we display highlight as a solid stroke?
  111045. */
  111046. isStroke?: boolean;
  111047. /**
  111048. * The rendering group to draw the layer in.
  111049. */
  111050. renderingGroupId: number;
  111051. }
  111052. /**
  111053. * The highlight layer Helps adding a glow effect around a mesh.
  111054. *
  111055. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  111056. * glowy meshes to your scene.
  111057. *
  111058. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  111059. */
  111060. export class HighlightLayer extends EffectLayer {
  111061. name: string;
  111062. /**
  111063. * Effect Name of the highlight layer.
  111064. */
  111065. static readonly EffectName: string;
  111066. /**
  111067. * The neutral color used during the preparation of the glow effect.
  111068. * This is black by default as the blend operation is a blend operation.
  111069. */
  111070. static NeutralColor: Color4;
  111071. /**
  111072. * Stencil value used for glowing meshes.
  111073. */
  111074. static GlowingMeshStencilReference: number;
  111075. /**
  111076. * Stencil value used for the other meshes in the scene.
  111077. */
  111078. static NormalMeshStencilReference: number;
  111079. /**
  111080. * Specifies whether or not the inner glow is ACTIVE in the layer.
  111081. */
  111082. innerGlow: boolean;
  111083. /**
  111084. * Specifies whether or not the outer glow is ACTIVE in the layer.
  111085. */
  111086. outerGlow: boolean;
  111087. /**
  111088. * Specifies the horizontal size of the blur.
  111089. */
  111090. /**
  111091. * Gets the horizontal size of the blur.
  111092. */
  111093. blurHorizontalSize: number;
  111094. /**
  111095. * Specifies the vertical size of the blur.
  111096. */
  111097. /**
  111098. * Gets the vertical size of the blur.
  111099. */
  111100. blurVerticalSize: number;
  111101. /**
  111102. * An event triggered when the highlight layer is being blurred.
  111103. */
  111104. onBeforeBlurObservable: Observable<HighlightLayer>;
  111105. /**
  111106. * An event triggered when the highlight layer has been blurred.
  111107. */
  111108. onAfterBlurObservable: Observable<HighlightLayer>;
  111109. private _instanceGlowingMeshStencilReference;
  111110. private _options;
  111111. private _downSamplePostprocess;
  111112. private _horizontalBlurPostprocess;
  111113. private _verticalBlurPostprocess;
  111114. private _blurTexture;
  111115. private _meshes;
  111116. private _excludedMeshes;
  111117. /**
  111118. * Instantiates a new highlight Layer and references it to the scene..
  111119. * @param name The name of the layer
  111120. * @param scene The scene to use the layer in
  111121. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  111122. */
  111123. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  111124. /**
  111125. * Get the effect name of the layer.
  111126. * @return The effect name
  111127. */
  111128. getEffectName(): string;
  111129. /**
  111130. * Create the merge effect. This is the shader use to blit the information back
  111131. * to the main canvas at the end of the scene rendering.
  111132. */
  111133. protected _createMergeEffect(): Effect;
  111134. /**
  111135. * Creates the render target textures and post processes used in the highlight layer.
  111136. */
  111137. protected _createTextureAndPostProcesses(): void;
  111138. /**
  111139. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  111140. */
  111141. needStencil(): boolean;
  111142. /**
  111143. * Checks for the readiness of the element composing the layer.
  111144. * @param subMesh the mesh to check for
  111145. * @param useInstances specify wether or not to use instances to render the mesh
  111146. * @param emissiveTexture the associated emissive texture used to generate the glow
  111147. * @return true if ready otherwise, false
  111148. */
  111149. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  111150. /**
  111151. * Implementation specific of rendering the generating effect on the main canvas.
  111152. * @param effect The effect used to render through
  111153. */
  111154. protected _internalRender(effect: Effect): void;
  111155. /**
  111156. * Returns true if the layer contains information to display, otherwise false.
  111157. */
  111158. shouldRender(): boolean;
  111159. /**
  111160. * Returns true if the mesh should render, otherwise false.
  111161. * @param mesh The mesh to render
  111162. * @returns true if it should render otherwise false
  111163. */
  111164. protected _shouldRenderMesh(mesh: Mesh): boolean;
  111165. /**
  111166. * Sets the required values for both the emissive texture and and the main color.
  111167. */
  111168. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  111169. /**
  111170. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  111171. * @param mesh The mesh to exclude from the highlight layer
  111172. */
  111173. addExcludedMesh(mesh: Mesh): void;
  111174. /**
  111175. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  111176. * @param mesh The mesh to highlight
  111177. */
  111178. removeExcludedMesh(mesh: Mesh): void;
  111179. /**
  111180. * Determine if a given mesh will be highlighted by the current HighlightLayer
  111181. * @param mesh mesh to test
  111182. * @returns true if the mesh will be highlighted by the current HighlightLayer
  111183. */
  111184. hasMesh(mesh: AbstractMesh): boolean;
  111185. /**
  111186. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  111187. * @param mesh The mesh to highlight
  111188. * @param color The color of the highlight
  111189. * @param glowEmissiveOnly Extract the glow from the emissive texture
  111190. */
  111191. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  111192. /**
  111193. * Remove a mesh from the highlight layer in order to make it stop glowing.
  111194. * @param mesh The mesh to highlight
  111195. */
  111196. removeMesh(mesh: Mesh): void;
  111197. /**
  111198. * Force the stencil to the normal expected value for none glowing parts
  111199. */
  111200. private _defaultStencilReference;
  111201. /**
  111202. * Free any resources and references associated to a mesh.
  111203. * Internal use
  111204. * @param mesh The mesh to free.
  111205. * @hidden
  111206. */
  111207. _disposeMesh(mesh: Mesh): void;
  111208. /**
  111209. * Dispose the highlight layer and free resources.
  111210. */
  111211. dispose(): void;
  111212. /**
  111213. * Gets the class name of the effect layer
  111214. * @returns the string with the class name of the effect layer
  111215. */
  111216. getClassName(): string;
  111217. /**
  111218. * Serializes this Highlight layer
  111219. * @returns a serialized Highlight layer object
  111220. */
  111221. serialize(): any;
  111222. /**
  111223. * Creates a Highlight layer from parsed Highlight layer data
  111224. * @param parsedHightlightLayer defines the Highlight layer data
  111225. * @param scene defines the current scene
  111226. * @param rootUrl defines the root URL containing the Highlight layer information
  111227. * @returns a parsed Highlight layer
  111228. */
  111229. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  111230. }
  111231. }
  111232. declare module BABYLON {
  111233. interface AbstractScene {
  111234. /**
  111235. * The list of layers (background and foreground) of the scene
  111236. */
  111237. layers: Array<Layer>;
  111238. }
  111239. /**
  111240. * Defines the layer scene component responsible to manage any layers
  111241. * in a given scene.
  111242. */
  111243. export class LayerSceneComponent implements ISceneComponent {
  111244. /**
  111245. * The component name helpfull to identify the component in the list of scene components.
  111246. */
  111247. readonly name: string;
  111248. /**
  111249. * The scene the component belongs to.
  111250. */
  111251. scene: Scene;
  111252. private _engine;
  111253. /**
  111254. * Creates a new instance of the component for the given scene
  111255. * @param scene Defines the scene to register the component in
  111256. */
  111257. constructor(scene: Scene);
  111258. /**
  111259. * Registers the component in a given scene
  111260. */
  111261. register(): void;
  111262. /**
  111263. * Rebuilds the elements related to this component in case of
  111264. * context lost for instance.
  111265. */
  111266. rebuild(): void;
  111267. /**
  111268. * Disposes the component and the associated ressources.
  111269. */
  111270. dispose(): void;
  111271. private _draw;
  111272. private _drawCameraPredicate;
  111273. private _drawCameraBackground;
  111274. private _drawCameraForeground;
  111275. private _drawRenderTargetPredicate;
  111276. private _drawRenderTargetBackground;
  111277. private _drawRenderTargetForeground;
  111278. /**
  111279. * Adds all the elements from the container to the scene
  111280. * @param container the container holding the elements
  111281. */
  111282. addFromContainer(container: AbstractScene): void;
  111283. /**
  111284. * Removes all the elements in the container from the scene
  111285. * @param container contains the elements to remove
  111286. * @param dispose if the removed element should be disposed (default: false)
  111287. */
  111288. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111289. }
  111290. }
  111291. declare module BABYLON {
  111292. /** @hidden */
  111293. export var layerPixelShader: {
  111294. name: string;
  111295. shader: string;
  111296. };
  111297. }
  111298. declare module BABYLON {
  111299. /** @hidden */
  111300. export var layerVertexShader: {
  111301. name: string;
  111302. shader: string;
  111303. };
  111304. }
  111305. declare module BABYLON {
  111306. /**
  111307. * This represents a full screen 2d layer.
  111308. * This can be useful to display a picture in the background of your scene for instance.
  111309. * @see https://www.babylonjs-playground.com/#08A2BS#1
  111310. */
  111311. export class Layer {
  111312. /**
  111313. * Define the name of the layer.
  111314. */
  111315. name: string;
  111316. /**
  111317. * Define the texture the layer should display.
  111318. */
  111319. texture: Nullable<Texture>;
  111320. /**
  111321. * Is the layer in background or foreground.
  111322. */
  111323. isBackground: boolean;
  111324. /**
  111325. * Define the color of the layer (instead of texture).
  111326. */
  111327. color: Color4;
  111328. /**
  111329. * Define the scale of the layer in order to zoom in out of the texture.
  111330. */
  111331. scale: Vector2;
  111332. /**
  111333. * Define an offset for the layer in order to shift the texture.
  111334. */
  111335. offset: Vector2;
  111336. /**
  111337. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  111338. */
  111339. alphaBlendingMode: number;
  111340. /**
  111341. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  111342. * Alpha test will not mix with the background color in case of transparency.
  111343. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  111344. */
  111345. alphaTest: boolean;
  111346. /**
  111347. * Define a mask to restrict the layer to only some of the scene cameras.
  111348. */
  111349. layerMask: number;
  111350. /**
  111351. * Define the list of render target the layer is visible into.
  111352. */
  111353. renderTargetTextures: RenderTargetTexture[];
  111354. /**
  111355. * Define if the layer is only used in renderTarget or if it also
  111356. * renders in the main frame buffer of the canvas.
  111357. */
  111358. renderOnlyInRenderTargetTextures: boolean;
  111359. private _scene;
  111360. private _vertexBuffers;
  111361. private _indexBuffer;
  111362. private _effect;
  111363. private _alphaTestEffect;
  111364. /**
  111365. * An event triggered when the layer is disposed.
  111366. */
  111367. onDisposeObservable: Observable<Layer>;
  111368. private _onDisposeObserver;
  111369. /**
  111370. * Back compatibility with callback before the onDisposeObservable existed.
  111371. * The set callback will be triggered when the layer has been disposed.
  111372. */
  111373. onDispose: () => void;
  111374. /**
  111375. * An event triggered before rendering the scene
  111376. */
  111377. onBeforeRenderObservable: Observable<Layer>;
  111378. private _onBeforeRenderObserver;
  111379. /**
  111380. * Back compatibility with callback before the onBeforeRenderObservable existed.
  111381. * The set callback will be triggered just before rendering the layer.
  111382. */
  111383. onBeforeRender: () => void;
  111384. /**
  111385. * An event triggered after rendering the scene
  111386. */
  111387. onAfterRenderObservable: Observable<Layer>;
  111388. private _onAfterRenderObserver;
  111389. /**
  111390. * Back compatibility with callback before the onAfterRenderObservable existed.
  111391. * The set callback will be triggered just after rendering the layer.
  111392. */
  111393. onAfterRender: () => void;
  111394. /**
  111395. * Instantiates a new layer.
  111396. * This represents a full screen 2d layer.
  111397. * This can be useful to display a picture in the background of your scene for instance.
  111398. * @see https://www.babylonjs-playground.com/#08A2BS#1
  111399. * @param name Define the name of the layer in the scene
  111400. * @param imgUrl Define the url of the texture to display in the layer
  111401. * @param scene Define the scene the layer belongs to
  111402. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  111403. * @param color Defines a color for the layer
  111404. */
  111405. constructor(
  111406. /**
  111407. * Define the name of the layer.
  111408. */
  111409. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  111410. private _createIndexBuffer;
  111411. /** @hidden */
  111412. _rebuild(): void;
  111413. /**
  111414. * Renders the layer in the scene.
  111415. */
  111416. render(): void;
  111417. /**
  111418. * Disposes and releases the associated ressources.
  111419. */
  111420. dispose(): void;
  111421. }
  111422. }
  111423. declare module BABYLON {
  111424. /** @hidden */
  111425. export var lensFlarePixelShader: {
  111426. name: string;
  111427. shader: string;
  111428. };
  111429. }
  111430. declare module BABYLON {
  111431. /** @hidden */
  111432. export var lensFlareVertexShader: {
  111433. name: string;
  111434. shader: string;
  111435. };
  111436. }
  111437. declare module BABYLON {
  111438. /**
  111439. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  111440. * It is usually composed of several `lensFlare`.
  111441. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111442. */
  111443. export class LensFlareSystem {
  111444. /**
  111445. * Define the name of the lens flare system
  111446. */
  111447. name: string;
  111448. /**
  111449. * List of lens flares used in this system.
  111450. */
  111451. lensFlares: LensFlare[];
  111452. /**
  111453. * Define a limit from the border the lens flare can be visible.
  111454. */
  111455. borderLimit: number;
  111456. /**
  111457. * Define a viewport border we do not want to see the lens flare in.
  111458. */
  111459. viewportBorder: number;
  111460. /**
  111461. * Define a predicate which could limit the list of meshes able to occlude the effect.
  111462. */
  111463. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  111464. /**
  111465. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  111466. */
  111467. layerMask: number;
  111468. /**
  111469. * Define the id of the lens flare system in the scene.
  111470. * (equal to name by default)
  111471. */
  111472. id: string;
  111473. private _scene;
  111474. private _emitter;
  111475. private _vertexBuffers;
  111476. private _indexBuffer;
  111477. private _effect;
  111478. private _positionX;
  111479. private _positionY;
  111480. private _isEnabled;
  111481. /** @hidden */
  111482. static _SceneComponentInitialization: (scene: Scene) => void;
  111483. /**
  111484. * Instantiates a lens flare system.
  111485. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  111486. * It is usually composed of several `lensFlare`.
  111487. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111488. * @param name Define the name of the lens flare system in the scene
  111489. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  111490. * @param scene Define the scene the lens flare system belongs to
  111491. */
  111492. constructor(
  111493. /**
  111494. * Define the name of the lens flare system
  111495. */
  111496. name: string, emitter: any, scene: Scene);
  111497. /**
  111498. * Define if the lens flare system is enabled.
  111499. */
  111500. isEnabled: boolean;
  111501. /**
  111502. * Get the scene the effects belongs to.
  111503. * @returns the scene holding the lens flare system
  111504. */
  111505. getScene(): Scene;
  111506. /**
  111507. * Get the emitter of the lens flare system.
  111508. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  111509. * @returns the emitter of the lens flare system
  111510. */
  111511. getEmitter(): any;
  111512. /**
  111513. * Set the emitter of the lens flare system.
  111514. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  111515. * @param newEmitter Define the new emitter of the system
  111516. */
  111517. setEmitter(newEmitter: any): void;
  111518. /**
  111519. * Get the lens flare system emitter position.
  111520. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  111521. * @returns the position
  111522. */
  111523. getEmitterPosition(): Vector3;
  111524. /**
  111525. * @hidden
  111526. */
  111527. computeEffectivePosition(globalViewport: Viewport): boolean;
  111528. /** @hidden */
  111529. _isVisible(): boolean;
  111530. /**
  111531. * @hidden
  111532. */
  111533. render(): boolean;
  111534. /**
  111535. * Dispose and release the lens flare with its associated resources.
  111536. */
  111537. dispose(): void;
  111538. /**
  111539. * Parse a lens flare system from a JSON repressentation
  111540. * @param parsedLensFlareSystem Define the JSON to parse
  111541. * @param scene Define the scene the parsed system should be instantiated in
  111542. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  111543. * @returns the parsed system
  111544. */
  111545. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  111546. /**
  111547. * Serialize the current Lens Flare System into a JSON representation.
  111548. * @returns the serialized JSON
  111549. */
  111550. serialize(): any;
  111551. }
  111552. }
  111553. declare module BABYLON {
  111554. /**
  111555. * This represents one of the lens effect in a `lensFlareSystem`.
  111556. * It controls one of the indiviual texture used in the effect.
  111557. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111558. */
  111559. export class LensFlare {
  111560. /**
  111561. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  111562. */
  111563. size: number;
  111564. /**
  111565. * 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.
  111566. */
  111567. position: number;
  111568. /**
  111569. * Define the lens color.
  111570. */
  111571. color: Color3;
  111572. /**
  111573. * Define the lens texture.
  111574. */
  111575. texture: Nullable<Texture>;
  111576. /**
  111577. * Define the alpha mode to render this particular lens.
  111578. */
  111579. alphaMode: number;
  111580. private _system;
  111581. /**
  111582. * Creates a new Lens Flare.
  111583. * This represents one of the lens effect in a `lensFlareSystem`.
  111584. * It controls one of the indiviual texture used in the effect.
  111585. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111586. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  111587. * @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.
  111588. * @param color Define the lens color
  111589. * @param imgUrl Define the lens texture url
  111590. * @param system Define the `lensFlareSystem` this flare is part of
  111591. * @returns The newly created Lens Flare
  111592. */
  111593. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  111594. /**
  111595. * Instantiates a new Lens Flare.
  111596. * This represents one of the lens effect in a `lensFlareSystem`.
  111597. * It controls one of the indiviual texture used in the effect.
  111598. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111599. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  111600. * @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.
  111601. * @param color Define the lens color
  111602. * @param imgUrl Define the lens texture url
  111603. * @param system Define the `lensFlareSystem` this flare is part of
  111604. */
  111605. constructor(
  111606. /**
  111607. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  111608. */
  111609. size: number,
  111610. /**
  111611. * 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.
  111612. */
  111613. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  111614. /**
  111615. * Dispose and release the lens flare with its associated resources.
  111616. */
  111617. dispose(): void;
  111618. }
  111619. }
  111620. declare module BABYLON {
  111621. interface AbstractScene {
  111622. /**
  111623. * The list of lens flare system added to the scene
  111624. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111625. */
  111626. lensFlareSystems: Array<LensFlareSystem>;
  111627. /**
  111628. * Removes the given lens flare system from this scene.
  111629. * @param toRemove The lens flare system to remove
  111630. * @returns The index of the removed lens flare system
  111631. */
  111632. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  111633. /**
  111634. * Adds the given lens flare system to this scene
  111635. * @param newLensFlareSystem The lens flare system to add
  111636. */
  111637. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  111638. /**
  111639. * Gets a lens flare system using its name
  111640. * @param name defines the name to look for
  111641. * @returns the lens flare system or null if not found
  111642. */
  111643. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  111644. /**
  111645. * Gets a lens flare system using its id
  111646. * @param id defines the id to look for
  111647. * @returns the lens flare system or null if not found
  111648. */
  111649. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  111650. }
  111651. /**
  111652. * Defines the lens flare scene component responsible to manage any lens flares
  111653. * in a given scene.
  111654. */
  111655. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  111656. /**
  111657. * The component name helpfull to identify the component in the list of scene components.
  111658. */
  111659. readonly name: string;
  111660. /**
  111661. * The scene the component belongs to.
  111662. */
  111663. scene: Scene;
  111664. /**
  111665. * Creates a new instance of the component for the given scene
  111666. * @param scene Defines the scene to register the component in
  111667. */
  111668. constructor(scene: Scene);
  111669. /**
  111670. * Registers the component in a given scene
  111671. */
  111672. register(): void;
  111673. /**
  111674. * Rebuilds the elements related to this component in case of
  111675. * context lost for instance.
  111676. */
  111677. rebuild(): void;
  111678. /**
  111679. * Adds all the elements from the container to the scene
  111680. * @param container the container holding the elements
  111681. */
  111682. addFromContainer(container: AbstractScene): void;
  111683. /**
  111684. * Removes all the elements in the container from the scene
  111685. * @param container contains the elements to remove
  111686. * @param dispose if the removed element should be disposed (default: false)
  111687. */
  111688. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111689. /**
  111690. * Serializes the component data to the specified json object
  111691. * @param serializationObject The object to serialize to
  111692. */
  111693. serialize(serializationObject: any): void;
  111694. /**
  111695. * Disposes the component and the associated ressources.
  111696. */
  111697. dispose(): void;
  111698. private _draw;
  111699. }
  111700. }
  111701. declare module BABYLON {
  111702. /**
  111703. * Defines the shadow generator component responsible to manage any shadow generators
  111704. * in a given scene.
  111705. */
  111706. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  111707. /**
  111708. * The component name helpfull to identify the component in the list of scene components.
  111709. */
  111710. readonly name: string;
  111711. /**
  111712. * The scene the component belongs to.
  111713. */
  111714. scene: Scene;
  111715. /**
  111716. * Creates a new instance of the component for the given scene
  111717. * @param scene Defines the scene to register the component in
  111718. */
  111719. constructor(scene: Scene);
  111720. /**
  111721. * Registers the component in a given scene
  111722. */
  111723. register(): void;
  111724. /**
  111725. * Rebuilds the elements related to this component in case of
  111726. * context lost for instance.
  111727. */
  111728. rebuild(): void;
  111729. /**
  111730. * Serializes the component data to the specified json object
  111731. * @param serializationObject The object to serialize to
  111732. */
  111733. serialize(serializationObject: any): void;
  111734. /**
  111735. * Adds all the elements from the container to the scene
  111736. * @param container the container holding the elements
  111737. */
  111738. addFromContainer(container: AbstractScene): void;
  111739. /**
  111740. * Removes all the elements in the container from the scene
  111741. * @param container contains the elements to remove
  111742. * @param dispose if the removed element should be disposed (default: false)
  111743. */
  111744. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111745. /**
  111746. * Rebuilds the elements related to this component in case of
  111747. * context lost for instance.
  111748. */
  111749. dispose(): void;
  111750. private _gatherRenderTargets;
  111751. }
  111752. }
  111753. declare module BABYLON {
  111754. /**
  111755. * A point light is a light defined by an unique point in world space.
  111756. * The light is emitted in every direction from this point.
  111757. * A good example of a point light is a standard light bulb.
  111758. * Documentation: https://doc.babylonjs.com/babylon101/lights
  111759. */
  111760. export class PointLight extends ShadowLight {
  111761. private _shadowAngle;
  111762. /**
  111763. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111764. * This specifies what angle the shadow will use to be created.
  111765. *
  111766. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  111767. */
  111768. /**
  111769. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111770. * This specifies what angle the shadow will use to be created.
  111771. *
  111772. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  111773. */
  111774. shadowAngle: number;
  111775. /**
  111776. * Gets the direction if it has been set.
  111777. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111778. */
  111779. /**
  111780. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111781. */
  111782. direction: Vector3;
  111783. /**
  111784. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  111785. * A PointLight emits the light in every direction.
  111786. * It can cast shadows.
  111787. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  111788. * ```javascript
  111789. * var pointLight = new PointLight("pl", camera.position, scene);
  111790. * ```
  111791. * Documentation : https://doc.babylonjs.com/babylon101/lights
  111792. * @param name The light friendly name
  111793. * @param position The position of the point light in the scene
  111794. * @param scene The scene the lights belongs to
  111795. */
  111796. constructor(name: string, position: Vector3, scene: Scene);
  111797. /**
  111798. * Returns the string "PointLight"
  111799. * @returns the class name
  111800. */
  111801. getClassName(): string;
  111802. /**
  111803. * Returns the integer 0.
  111804. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  111805. */
  111806. getTypeID(): number;
  111807. /**
  111808. * Specifies wether or not the shadowmap should be a cube texture.
  111809. * @returns true if the shadowmap needs to be a cube texture.
  111810. */
  111811. needCube(): boolean;
  111812. /**
  111813. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  111814. * @param faceIndex The index of the face we are computed the direction to generate shadow
  111815. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  111816. */
  111817. getShadowDirection(faceIndex?: number): Vector3;
  111818. /**
  111819. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  111820. * - fov = PI / 2
  111821. * - aspect ratio : 1.0
  111822. * - z-near and far equal to the active camera minZ and maxZ.
  111823. * Returns the PointLight.
  111824. */
  111825. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  111826. protected _buildUniformLayout(): void;
  111827. /**
  111828. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  111829. * @param effect The effect to update
  111830. * @param lightIndex The index of the light in the effect to update
  111831. * @returns The point light
  111832. */
  111833. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  111834. /**
  111835. * Prepares the list of defines specific to the light type.
  111836. * @param defines the list of defines
  111837. * @param lightIndex defines the index of the light for the effect
  111838. */
  111839. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  111840. }
  111841. }
  111842. declare module BABYLON {
  111843. /**
  111844. * Header information of HDR texture files.
  111845. */
  111846. export interface HDRInfo {
  111847. /**
  111848. * The height of the texture in pixels.
  111849. */
  111850. height: number;
  111851. /**
  111852. * The width of the texture in pixels.
  111853. */
  111854. width: number;
  111855. /**
  111856. * The index of the beginning of the data in the binary file.
  111857. */
  111858. dataPosition: number;
  111859. }
  111860. /**
  111861. * This groups tools to convert HDR texture to native colors array.
  111862. */
  111863. export class HDRTools {
  111864. private static Ldexp;
  111865. private static Rgbe2float;
  111866. private static readStringLine;
  111867. /**
  111868. * Reads header information from an RGBE texture stored in a native array.
  111869. * More information on this format are available here:
  111870. * https://en.wikipedia.org/wiki/RGBE_image_format
  111871. *
  111872. * @param uint8array The binary file stored in native array.
  111873. * @return The header information.
  111874. */
  111875. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  111876. /**
  111877. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  111878. * This RGBE texture needs to store the information as a panorama.
  111879. *
  111880. * More information on this format are available here:
  111881. * https://en.wikipedia.org/wiki/RGBE_image_format
  111882. *
  111883. * @param buffer The binary file stored in an array buffer.
  111884. * @param size The expected size of the extracted cubemap.
  111885. * @return The Cube Map information.
  111886. */
  111887. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  111888. /**
  111889. * Returns the pixels data extracted from an RGBE texture.
  111890. * This pixels will be stored left to right up to down in the R G B order in one array.
  111891. *
  111892. * More information on this format are available here:
  111893. * https://en.wikipedia.org/wiki/RGBE_image_format
  111894. *
  111895. * @param uint8array The binary file stored in an array buffer.
  111896. * @param hdrInfo The header information of the file.
  111897. * @return The pixels data in RGB right to left up to down order.
  111898. */
  111899. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  111900. private static RGBE_ReadPixels_RLE;
  111901. }
  111902. }
  111903. declare module BABYLON {
  111904. /**
  111905. * This represents a texture coming from an HDR input.
  111906. *
  111907. * The only supported format is currently panorama picture stored in RGBE format.
  111908. * Example of such files can be found on HDRLib: http://hdrlib.com/
  111909. */
  111910. export class HDRCubeTexture extends BaseTexture {
  111911. private static _facesMapping;
  111912. private _generateHarmonics;
  111913. private _noMipmap;
  111914. private _textureMatrix;
  111915. private _size;
  111916. private _onLoad;
  111917. private _onError;
  111918. /**
  111919. * The texture URL.
  111920. */
  111921. url: string;
  111922. /**
  111923. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  111924. */
  111925. coordinatesMode: number;
  111926. protected _isBlocking: boolean;
  111927. /**
  111928. * Sets wether or not the texture is blocking during loading.
  111929. */
  111930. /**
  111931. * Gets wether or not the texture is blocking during loading.
  111932. */
  111933. isBlocking: boolean;
  111934. protected _rotationY: number;
  111935. /**
  111936. * Sets texture matrix rotation angle around Y axis in radians.
  111937. */
  111938. /**
  111939. * Gets texture matrix rotation angle around Y axis radians.
  111940. */
  111941. rotationY: number;
  111942. /**
  111943. * Gets or sets the center of the bounding box associated with the cube texture
  111944. * It must define where the camera used to render the texture was set
  111945. */
  111946. boundingBoxPosition: Vector3;
  111947. private _boundingBoxSize;
  111948. /**
  111949. * Gets or sets the size of the bounding box associated with the cube texture
  111950. * When defined, the cubemap will switch to local mode
  111951. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  111952. * @example https://www.babylonjs-playground.com/#RNASML
  111953. */
  111954. boundingBoxSize: Vector3;
  111955. /**
  111956. * Instantiates an HDRTexture from the following parameters.
  111957. *
  111958. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  111959. * @param scene The scene the texture will be used in
  111960. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  111961. * @param noMipmap Forces to not generate the mipmap if true
  111962. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  111963. * @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)
  111964. * @param reserved Reserved flag for internal use.
  111965. */
  111966. 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>);
  111967. /**
  111968. * Get the current class name of the texture useful for serialization or dynamic coding.
  111969. * @returns "HDRCubeTexture"
  111970. */
  111971. getClassName(): string;
  111972. /**
  111973. * Occurs when the file is raw .hdr file.
  111974. */
  111975. private loadTexture;
  111976. clone(): HDRCubeTexture;
  111977. delayLoad(): void;
  111978. /**
  111979. * Get the texture reflection matrix used to rotate/transform the reflection.
  111980. * @returns the reflection matrix
  111981. */
  111982. getReflectionTextureMatrix(): Matrix;
  111983. /**
  111984. * Set the texture reflection matrix used to rotate/transform the reflection.
  111985. * @param value Define the reflection matrix to set
  111986. */
  111987. setReflectionTextureMatrix(value: Matrix): void;
  111988. /**
  111989. * Parses a JSON representation of an HDR Texture in order to create the texture
  111990. * @param parsedTexture Define the JSON representation
  111991. * @param scene Define the scene the texture should be created in
  111992. * @param rootUrl Define the root url in case we need to load relative dependencies
  111993. * @returns the newly created texture after parsing
  111994. */
  111995. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  111996. serialize(): any;
  111997. }
  111998. }
  111999. declare module BABYLON {
  112000. /**
  112001. * Class used to control physics engine
  112002. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  112003. */
  112004. export class PhysicsEngine implements IPhysicsEngine {
  112005. private _physicsPlugin;
  112006. /**
  112007. * Global value used to control the smallest number supported by the simulation
  112008. */
  112009. static Epsilon: number;
  112010. private _impostors;
  112011. private _joints;
  112012. /**
  112013. * Gets the gravity vector used by the simulation
  112014. */
  112015. gravity: Vector3;
  112016. /**
  112017. * Factory used to create the default physics plugin.
  112018. * @returns The default physics plugin
  112019. */
  112020. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  112021. /**
  112022. * Creates a new Physics Engine
  112023. * @param gravity defines the gravity vector used by the simulation
  112024. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  112025. */
  112026. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  112027. /**
  112028. * Sets the gravity vector used by the simulation
  112029. * @param gravity defines the gravity vector to use
  112030. */
  112031. setGravity(gravity: Vector3): void;
  112032. /**
  112033. * Set the time step of the physics engine.
  112034. * Default is 1/60.
  112035. * To slow it down, enter 1/600 for example.
  112036. * To speed it up, 1/30
  112037. * @param newTimeStep defines the new timestep to apply to this world.
  112038. */
  112039. setTimeStep(newTimeStep?: number): void;
  112040. /**
  112041. * Get the time step of the physics engine.
  112042. * @returns the current time step
  112043. */
  112044. getTimeStep(): number;
  112045. /**
  112046. * Release all resources
  112047. */
  112048. dispose(): void;
  112049. /**
  112050. * Gets the name of the current physics plugin
  112051. * @returns the name of the plugin
  112052. */
  112053. getPhysicsPluginName(): string;
  112054. /**
  112055. * Adding a new impostor for the impostor tracking.
  112056. * This will be done by the impostor itself.
  112057. * @param impostor the impostor to add
  112058. */
  112059. addImpostor(impostor: PhysicsImpostor): void;
  112060. /**
  112061. * Remove an impostor from the engine.
  112062. * This impostor and its mesh will not longer be updated by the physics engine.
  112063. * @param impostor the impostor to remove
  112064. */
  112065. removeImpostor(impostor: PhysicsImpostor): void;
  112066. /**
  112067. * Add a joint to the physics engine
  112068. * @param mainImpostor defines the main impostor to which the joint is added.
  112069. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  112070. * @param joint defines the joint that will connect both impostors.
  112071. */
  112072. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  112073. /**
  112074. * Removes a joint from the simulation
  112075. * @param mainImpostor defines the impostor used with the joint
  112076. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  112077. * @param joint defines the joint to remove
  112078. */
  112079. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  112080. /**
  112081. * Called by the scene. No need to call it.
  112082. * @param delta defines the timespam between frames
  112083. */
  112084. _step(delta: number): void;
  112085. /**
  112086. * Gets the current plugin used to run the simulation
  112087. * @returns current plugin
  112088. */
  112089. getPhysicsPlugin(): IPhysicsEnginePlugin;
  112090. /**
  112091. * Gets the list of physic impostors
  112092. * @returns an array of PhysicsImpostor
  112093. */
  112094. getImpostors(): Array<PhysicsImpostor>;
  112095. /**
  112096. * Gets the impostor for a physics enabled object
  112097. * @param object defines the object impersonated by the impostor
  112098. * @returns the PhysicsImpostor or null if not found
  112099. */
  112100. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  112101. /**
  112102. * Gets the impostor for a physics body object
  112103. * @param body defines physics body used by the impostor
  112104. * @returns the PhysicsImpostor or null if not found
  112105. */
  112106. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  112107. /**
  112108. * Does a raycast in the physics world
  112109. * @param from when should the ray start?
  112110. * @param to when should the ray end?
  112111. * @returns PhysicsRaycastResult
  112112. */
  112113. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112114. }
  112115. }
  112116. declare module BABYLON {
  112117. /** @hidden */
  112118. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  112119. private _useDeltaForWorldStep;
  112120. world: any;
  112121. name: string;
  112122. private _physicsMaterials;
  112123. private _fixedTimeStep;
  112124. private _cannonRaycastResult;
  112125. private _raycastResult;
  112126. private _physicsBodysToRemoveAfterStep;
  112127. BJSCANNON: any;
  112128. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  112129. setGravity(gravity: Vector3): void;
  112130. setTimeStep(timeStep: number): void;
  112131. getTimeStep(): number;
  112132. executeStep(delta: number): void;
  112133. private _removeMarkedPhysicsBodiesFromWorld;
  112134. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112135. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112136. generatePhysicsBody(impostor: PhysicsImpostor): void;
  112137. private _processChildMeshes;
  112138. removePhysicsBody(impostor: PhysicsImpostor): void;
  112139. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  112140. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  112141. private _addMaterial;
  112142. private _checkWithEpsilon;
  112143. private _createShape;
  112144. private _createHeightmap;
  112145. private _minus90X;
  112146. private _plus90X;
  112147. private _tmpPosition;
  112148. private _tmpDeltaPosition;
  112149. private _tmpUnityRotation;
  112150. private _updatePhysicsBodyTransformation;
  112151. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  112152. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  112153. isSupported(): boolean;
  112154. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112155. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112156. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112157. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112158. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  112159. getBodyMass(impostor: PhysicsImpostor): number;
  112160. getBodyFriction(impostor: PhysicsImpostor): number;
  112161. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112162. getBodyRestitution(impostor: PhysicsImpostor): number;
  112163. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112164. sleepBody(impostor: PhysicsImpostor): void;
  112165. wakeUpBody(impostor: PhysicsImpostor): void;
  112166. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  112167. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  112168. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  112169. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112170. getRadius(impostor: PhysicsImpostor): number;
  112171. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112172. dispose(): void;
  112173. private _extendNamespace;
  112174. /**
  112175. * Does a raycast in the physics world
  112176. * @param from when should the ray start?
  112177. * @param to when should the ray end?
  112178. * @returns PhysicsRaycastResult
  112179. */
  112180. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112181. }
  112182. }
  112183. declare module BABYLON {
  112184. /** @hidden */
  112185. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  112186. world: any;
  112187. name: string;
  112188. BJSOIMO: any;
  112189. private _raycastResult;
  112190. constructor(iterations?: number, oimoInjection?: any);
  112191. setGravity(gravity: Vector3): void;
  112192. setTimeStep(timeStep: number): void;
  112193. getTimeStep(): number;
  112194. private _tmpImpostorsArray;
  112195. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  112196. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112197. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112198. generatePhysicsBody(impostor: PhysicsImpostor): void;
  112199. private _tmpPositionVector;
  112200. removePhysicsBody(impostor: PhysicsImpostor): void;
  112201. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  112202. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  112203. isSupported(): boolean;
  112204. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  112205. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  112206. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112207. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112208. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112209. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112210. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  112211. getBodyMass(impostor: PhysicsImpostor): number;
  112212. getBodyFriction(impostor: PhysicsImpostor): number;
  112213. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112214. getBodyRestitution(impostor: PhysicsImpostor): number;
  112215. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112216. sleepBody(impostor: PhysicsImpostor): void;
  112217. wakeUpBody(impostor: PhysicsImpostor): void;
  112218. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  112219. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  112220. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112221. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112222. getRadius(impostor: PhysicsImpostor): number;
  112223. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112224. dispose(): void;
  112225. /**
  112226. * Does a raycast in the physics world
  112227. * @param from when should the ray start?
  112228. * @param to when should the ray end?
  112229. * @returns PhysicsRaycastResult
  112230. */
  112231. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112232. }
  112233. }
  112234. declare module BABYLON {
  112235. /**
  112236. * Class containing static functions to help procedurally build meshes
  112237. */
  112238. export class RibbonBuilder {
  112239. /**
  112240. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  112241. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  112242. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  112243. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  112244. * * 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
  112245. * * 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
  112246. * * 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
  112247. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112248. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112249. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  112250. * * 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
  112251. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  112252. * * 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
  112253. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  112254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112255. * @param name defines the name of the mesh
  112256. * @param options defines the options used to create the mesh
  112257. * @param scene defines the hosting scene
  112258. * @returns the ribbon mesh
  112259. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  112260. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  112261. */
  112262. static CreateRibbon(name: string, options: {
  112263. pathArray: Vector3[][];
  112264. closeArray?: boolean;
  112265. closePath?: boolean;
  112266. offset?: number;
  112267. updatable?: boolean;
  112268. sideOrientation?: number;
  112269. frontUVs?: Vector4;
  112270. backUVs?: Vector4;
  112271. instance?: Mesh;
  112272. invertUV?: boolean;
  112273. uvs?: Vector2[];
  112274. colors?: Color4[];
  112275. }, scene?: Nullable<Scene>): Mesh;
  112276. }
  112277. }
  112278. declare module BABYLON {
  112279. /**
  112280. * Class containing static functions to help procedurally build meshes
  112281. */
  112282. export class ShapeBuilder {
  112283. /**
  112284. * 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.
  112285. * * 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.
  112286. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  112287. * * 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.
  112288. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  112289. * * 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
  112290. * * 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
  112291. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  112292. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112293. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112294. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  112295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112296. * @param name defines the name of the mesh
  112297. * @param options defines the options used to create the mesh
  112298. * @param scene defines the hosting scene
  112299. * @returns the extruded shape mesh
  112300. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  112301. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  112302. */
  112303. static ExtrudeShape(name: string, options: {
  112304. shape: Vector3[];
  112305. path: Vector3[];
  112306. scale?: number;
  112307. rotation?: number;
  112308. cap?: number;
  112309. updatable?: boolean;
  112310. sideOrientation?: number;
  112311. frontUVs?: Vector4;
  112312. backUVs?: Vector4;
  112313. instance?: Mesh;
  112314. invertUV?: boolean;
  112315. }, scene?: Nullable<Scene>): Mesh;
  112316. /**
  112317. * Creates an custom extruded shape mesh.
  112318. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  112319. * * 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.
  112320. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  112321. * * 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
  112322. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  112323. * * 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
  112324. * * It must returns a float value that will be the scale value applied to the shape on each path point
  112325. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  112326. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  112327. * * 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
  112328. * * 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
  112329. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  112330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112331. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112332. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  112333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112334. * @param name defines the name of the mesh
  112335. * @param options defines the options used to create the mesh
  112336. * @param scene defines the hosting scene
  112337. * @returns the custom extruded shape mesh
  112338. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  112339. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  112340. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  112341. */
  112342. static ExtrudeShapeCustom(name: string, options: {
  112343. shape: Vector3[];
  112344. path: Vector3[];
  112345. scaleFunction?: any;
  112346. rotationFunction?: any;
  112347. ribbonCloseArray?: boolean;
  112348. ribbonClosePath?: boolean;
  112349. cap?: number;
  112350. updatable?: boolean;
  112351. sideOrientation?: number;
  112352. frontUVs?: Vector4;
  112353. backUVs?: Vector4;
  112354. instance?: Mesh;
  112355. invertUV?: boolean;
  112356. }, scene?: Nullable<Scene>): Mesh;
  112357. private static _ExtrudeShapeGeneric;
  112358. }
  112359. }
  112360. declare module BABYLON {
  112361. /**
  112362. * AmmoJS Physics plugin
  112363. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112364. * @see https://github.com/kripken/ammo.js/
  112365. */
  112366. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  112367. private _useDeltaForWorldStep;
  112368. /**
  112369. * Reference to the Ammo library
  112370. */
  112371. bjsAMMO: any;
  112372. /**
  112373. * Created ammoJS world which physics bodies are added to
  112374. */
  112375. world: any;
  112376. /**
  112377. * Name of the plugin
  112378. */
  112379. name: string;
  112380. private _timeStep;
  112381. private _fixedTimeStep;
  112382. private _maxSteps;
  112383. private _tmpQuaternion;
  112384. private _tmpAmmoTransform;
  112385. private _tmpAmmoQuaternion;
  112386. private _tmpAmmoConcreteContactResultCallback;
  112387. private _collisionConfiguration;
  112388. private _dispatcher;
  112389. private _overlappingPairCache;
  112390. private _solver;
  112391. private _softBodySolver;
  112392. private _tmpAmmoVectorA;
  112393. private _tmpAmmoVectorB;
  112394. private _tmpAmmoVectorC;
  112395. private _tmpAmmoVectorD;
  112396. private _tmpContactCallbackResult;
  112397. private _tmpAmmoVectorRCA;
  112398. private _tmpAmmoVectorRCB;
  112399. private _raycastResult;
  112400. private static readonly DISABLE_COLLISION_FLAG;
  112401. private static readonly KINEMATIC_FLAG;
  112402. private static readonly DISABLE_DEACTIVATION_FLAG;
  112403. /**
  112404. * Initializes the ammoJS plugin
  112405. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  112406. * @param ammoInjection can be used to inject your own ammo reference
  112407. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  112408. */
  112409. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  112410. /**
  112411. * Sets the gravity of the physics world (m/(s^2))
  112412. * @param gravity Gravity to set
  112413. */
  112414. setGravity(gravity: Vector3): void;
  112415. /**
  112416. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  112417. * @param timeStep timestep to use in seconds
  112418. */
  112419. setTimeStep(timeStep: number): void;
  112420. /**
  112421. * 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)
  112422. * @param fixedTimeStep fixedTimeStep to use in seconds
  112423. */
  112424. setFixedTimeStep(fixedTimeStep: number): void;
  112425. /**
  112426. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  112427. * @param maxSteps the maximum number of steps by the physics engine per frame
  112428. */
  112429. setMaxSteps(maxSteps: number): void;
  112430. /**
  112431. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  112432. * @returns the current timestep in seconds
  112433. */
  112434. getTimeStep(): number;
  112435. private _isImpostorInContact;
  112436. private _isImpostorPairInContact;
  112437. private _stepSimulation;
  112438. /**
  112439. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  112440. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  112441. * After the step the babylon meshes are set to the position of the physics imposters
  112442. * @param delta amount of time to step forward
  112443. * @param impostors array of imposters to update before/after the step
  112444. */
  112445. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  112446. /**
  112447. * Update babylon mesh to match physics world object
  112448. * @param impostor imposter to match
  112449. */
  112450. private _afterSoftStep;
  112451. /**
  112452. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  112453. * @param impostor imposter to match
  112454. */
  112455. private _ropeStep;
  112456. /**
  112457. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  112458. * @param impostor imposter to match
  112459. */
  112460. private _softbodyOrClothStep;
  112461. private _tmpVector;
  112462. private _tmpMatrix;
  112463. /**
  112464. * Applies an impulse on the imposter
  112465. * @param impostor imposter to apply impulse to
  112466. * @param force amount of force to be applied to the imposter
  112467. * @param contactPoint the location to apply the impulse on the imposter
  112468. */
  112469. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112470. /**
  112471. * Applies a force on the imposter
  112472. * @param impostor imposter to apply force
  112473. * @param force amount of force to be applied to the imposter
  112474. * @param contactPoint the location to apply the force on the imposter
  112475. */
  112476. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112477. /**
  112478. * Creates a physics body using the plugin
  112479. * @param impostor the imposter to create the physics body on
  112480. */
  112481. generatePhysicsBody(impostor: PhysicsImpostor): void;
  112482. /**
  112483. * Removes the physics body from the imposter and disposes of the body's memory
  112484. * @param impostor imposter to remove the physics body from
  112485. */
  112486. removePhysicsBody(impostor: PhysicsImpostor): void;
  112487. /**
  112488. * Generates a joint
  112489. * @param impostorJoint the imposter joint to create the joint with
  112490. */
  112491. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  112492. /**
  112493. * Removes a joint
  112494. * @param impostorJoint the imposter joint to remove the joint from
  112495. */
  112496. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  112497. private _addMeshVerts;
  112498. /**
  112499. * Initialise the soft body vertices to match its object's (mesh) vertices
  112500. * Softbody vertices (nodes) are in world space and to match this
  112501. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  112502. * @param impostor to create the softbody for
  112503. */
  112504. private _softVertexData;
  112505. /**
  112506. * Create an impostor's soft body
  112507. * @param impostor to create the softbody for
  112508. */
  112509. private _createSoftbody;
  112510. /**
  112511. * Create cloth for an impostor
  112512. * @param impostor to create the softbody for
  112513. */
  112514. private _createCloth;
  112515. /**
  112516. * Create rope for an impostor
  112517. * @param impostor to create the softbody for
  112518. */
  112519. private _createRope;
  112520. private _addHullVerts;
  112521. private _createShape;
  112522. /**
  112523. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  112524. * @param impostor imposter containing the physics body and babylon object
  112525. */
  112526. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  112527. /**
  112528. * Sets the babylon object's position/rotation from the physics body's position/rotation
  112529. * @param impostor imposter containing the physics body and babylon object
  112530. * @param newPosition new position
  112531. * @param newRotation new rotation
  112532. */
  112533. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  112534. /**
  112535. * If this plugin is supported
  112536. * @returns true if its supported
  112537. */
  112538. isSupported(): boolean;
  112539. /**
  112540. * Sets the linear velocity of the physics body
  112541. * @param impostor imposter to set the velocity on
  112542. * @param velocity velocity to set
  112543. */
  112544. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112545. /**
  112546. * Sets the angular velocity of the physics body
  112547. * @param impostor imposter to set the velocity on
  112548. * @param velocity velocity to set
  112549. */
  112550. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112551. /**
  112552. * gets the linear velocity
  112553. * @param impostor imposter to get linear velocity from
  112554. * @returns linear velocity
  112555. */
  112556. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112557. /**
  112558. * gets the angular velocity
  112559. * @param impostor imposter to get angular velocity from
  112560. * @returns angular velocity
  112561. */
  112562. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112563. /**
  112564. * Sets the mass of physics body
  112565. * @param impostor imposter to set the mass on
  112566. * @param mass mass to set
  112567. */
  112568. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  112569. /**
  112570. * Gets the mass of the physics body
  112571. * @param impostor imposter to get the mass from
  112572. * @returns mass
  112573. */
  112574. getBodyMass(impostor: PhysicsImpostor): number;
  112575. /**
  112576. * Gets friction of the impostor
  112577. * @param impostor impostor to get friction from
  112578. * @returns friction value
  112579. */
  112580. getBodyFriction(impostor: PhysicsImpostor): number;
  112581. /**
  112582. * Sets friction of the impostor
  112583. * @param impostor impostor to set friction on
  112584. * @param friction friction value
  112585. */
  112586. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112587. /**
  112588. * Gets restitution of the impostor
  112589. * @param impostor impostor to get restitution from
  112590. * @returns restitution value
  112591. */
  112592. getBodyRestitution(impostor: PhysicsImpostor): number;
  112593. /**
  112594. * Sets resitution of the impostor
  112595. * @param impostor impostor to set resitution on
  112596. * @param restitution resitution value
  112597. */
  112598. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112599. /**
  112600. * Gets pressure inside the impostor
  112601. * @param impostor impostor to get pressure from
  112602. * @returns pressure value
  112603. */
  112604. getBodyPressure(impostor: PhysicsImpostor): number;
  112605. /**
  112606. * Sets pressure inside a soft body impostor
  112607. * Cloth and rope must remain 0 pressure
  112608. * @param impostor impostor to set pressure on
  112609. * @param pressure pressure value
  112610. */
  112611. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  112612. /**
  112613. * Gets stiffness of the impostor
  112614. * @param impostor impostor to get stiffness from
  112615. * @returns pressure value
  112616. */
  112617. getBodyStiffness(impostor: PhysicsImpostor): number;
  112618. /**
  112619. * Sets stiffness of the impostor
  112620. * @param impostor impostor to set stiffness on
  112621. * @param stiffness stiffness value from 0 to 1
  112622. */
  112623. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  112624. /**
  112625. * Gets velocityIterations of the impostor
  112626. * @param impostor impostor to get velocity iterations from
  112627. * @returns velocityIterations value
  112628. */
  112629. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  112630. /**
  112631. * Sets velocityIterations of the impostor
  112632. * @param impostor impostor to set velocity iterations on
  112633. * @param velocityIterations velocityIterations value
  112634. */
  112635. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  112636. /**
  112637. * Gets positionIterations of the impostor
  112638. * @param impostor impostor to get position iterations from
  112639. * @returns positionIterations value
  112640. */
  112641. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  112642. /**
  112643. * Sets positionIterations of the impostor
  112644. * @param impostor impostor to set position on
  112645. * @param positionIterations positionIterations value
  112646. */
  112647. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  112648. /**
  112649. * Append an anchor to a cloth object
  112650. * @param impostor is the cloth impostor to add anchor to
  112651. * @param otherImpostor is the rigid impostor to anchor to
  112652. * @param width ratio across width from 0 to 1
  112653. * @param height ratio up height from 0 to 1
  112654. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  112655. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  112656. */
  112657. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  112658. /**
  112659. * Append an hook to a rope object
  112660. * @param impostor is the rope impostor to add hook to
  112661. * @param otherImpostor is the rigid impostor to hook to
  112662. * @param length ratio along the rope from 0 to 1
  112663. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  112664. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  112665. */
  112666. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  112667. /**
  112668. * Sleeps the physics body and stops it from being active
  112669. * @param impostor impostor to sleep
  112670. */
  112671. sleepBody(impostor: PhysicsImpostor): void;
  112672. /**
  112673. * Activates the physics body
  112674. * @param impostor impostor to activate
  112675. */
  112676. wakeUpBody(impostor: PhysicsImpostor): void;
  112677. /**
  112678. * Updates the distance parameters of the joint
  112679. * @param joint joint to update
  112680. * @param maxDistance maximum distance of the joint
  112681. * @param minDistance minimum distance of the joint
  112682. */
  112683. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  112684. /**
  112685. * Sets a motor on the joint
  112686. * @param joint joint to set motor on
  112687. * @param speed speed of the motor
  112688. * @param maxForce maximum force of the motor
  112689. * @param motorIndex index of the motor
  112690. */
  112691. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  112692. /**
  112693. * Sets the motors limit
  112694. * @param joint joint to set limit on
  112695. * @param upperLimit upper limit
  112696. * @param lowerLimit lower limit
  112697. */
  112698. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  112699. /**
  112700. * Syncs the position and rotation of a mesh with the impostor
  112701. * @param mesh mesh to sync
  112702. * @param impostor impostor to update the mesh with
  112703. */
  112704. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112705. /**
  112706. * Gets the radius of the impostor
  112707. * @param impostor impostor to get radius from
  112708. * @returns the radius
  112709. */
  112710. getRadius(impostor: PhysicsImpostor): number;
  112711. /**
  112712. * Gets the box size of the impostor
  112713. * @param impostor impostor to get box size from
  112714. * @param result the resulting box size
  112715. */
  112716. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112717. /**
  112718. * Disposes of the impostor
  112719. */
  112720. dispose(): void;
  112721. /**
  112722. * Does a raycast in the physics world
  112723. * @param from when should the ray start?
  112724. * @param to when should the ray end?
  112725. * @returns PhysicsRaycastResult
  112726. */
  112727. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112728. }
  112729. }
  112730. declare module BABYLON {
  112731. interface AbstractScene {
  112732. /**
  112733. * The list of reflection probes added to the scene
  112734. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  112735. */
  112736. reflectionProbes: Array<ReflectionProbe>;
  112737. /**
  112738. * Removes the given reflection probe from this scene.
  112739. * @param toRemove The reflection probe to remove
  112740. * @returns The index of the removed reflection probe
  112741. */
  112742. removeReflectionProbe(toRemove: ReflectionProbe): number;
  112743. /**
  112744. * Adds the given reflection probe to this scene.
  112745. * @param newReflectionProbe The reflection probe to add
  112746. */
  112747. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  112748. }
  112749. /**
  112750. * Class used to generate realtime reflection / refraction cube textures
  112751. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  112752. */
  112753. export class ReflectionProbe {
  112754. /** defines the name of the probe */
  112755. name: string;
  112756. private _scene;
  112757. private _renderTargetTexture;
  112758. private _projectionMatrix;
  112759. private _viewMatrix;
  112760. private _target;
  112761. private _add;
  112762. private _attachedMesh;
  112763. private _invertYAxis;
  112764. /** Gets or sets probe position (center of the cube map) */
  112765. position: Vector3;
  112766. /**
  112767. * Creates a new reflection probe
  112768. * @param name defines the name of the probe
  112769. * @param size defines the texture resolution (for each face)
  112770. * @param scene defines the hosting scene
  112771. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  112772. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  112773. */
  112774. constructor(
  112775. /** defines the name of the probe */
  112776. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  112777. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  112778. samples: number;
  112779. /** Gets or sets the refresh rate to use (on every frame by default) */
  112780. refreshRate: number;
  112781. /**
  112782. * Gets the hosting scene
  112783. * @returns a Scene
  112784. */
  112785. getScene(): Scene;
  112786. /** Gets the internal CubeTexture used to render to */
  112787. readonly cubeTexture: RenderTargetTexture;
  112788. /** Gets the list of meshes to render */
  112789. readonly renderList: Nullable<AbstractMesh[]>;
  112790. /**
  112791. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  112792. * @param mesh defines the mesh to attach to
  112793. */
  112794. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  112795. /**
  112796. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  112797. * @param renderingGroupId The rendering group id corresponding to its index
  112798. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  112799. */
  112800. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  112801. /**
  112802. * Clean all associated resources
  112803. */
  112804. dispose(): void;
  112805. /**
  112806. * Converts the reflection probe information to a readable string for debug purpose.
  112807. * @param fullDetails Supports for multiple levels of logging within scene loading
  112808. * @returns the human readable reflection probe info
  112809. */
  112810. toString(fullDetails?: boolean): string;
  112811. /**
  112812. * Get the class name of the relfection probe.
  112813. * @returns "ReflectionProbe"
  112814. */
  112815. getClassName(): string;
  112816. /**
  112817. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  112818. * @returns The JSON representation of the texture
  112819. */
  112820. serialize(): any;
  112821. /**
  112822. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  112823. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  112824. * @param scene Define the scene the parsed reflection probe should be instantiated in
  112825. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  112826. * @returns The parsed reflection probe if successful
  112827. */
  112828. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  112829. }
  112830. }
  112831. declare module BABYLON {
  112832. /** @hidden */
  112833. export var _BabylonLoaderRegistered: boolean;
  112834. }
  112835. declare module BABYLON {
  112836. /**
  112837. * The Physically based simple base material of BJS.
  112838. *
  112839. * This enables better naming and convention enforcements on top of the pbrMaterial.
  112840. * It is used as the base class for both the specGloss and metalRough conventions.
  112841. */
  112842. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  112843. /**
  112844. * Number of Simultaneous lights allowed on the material.
  112845. */
  112846. maxSimultaneousLights: number;
  112847. /**
  112848. * If sets to true, disables all the lights affecting the material.
  112849. */
  112850. disableLighting: boolean;
  112851. /**
  112852. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  112853. */
  112854. environmentTexture: BaseTexture;
  112855. /**
  112856. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  112857. */
  112858. invertNormalMapX: boolean;
  112859. /**
  112860. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  112861. */
  112862. invertNormalMapY: boolean;
  112863. /**
  112864. * Normal map used in the model.
  112865. */
  112866. normalTexture: BaseTexture;
  112867. /**
  112868. * Emissivie color used to self-illuminate the model.
  112869. */
  112870. emissiveColor: Color3;
  112871. /**
  112872. * Emissivie texture used to self-illuminate the model.
  112873. */
  112874. emissiveTexture: BaseTexture;
  112875. /**
  112876. * Occlusion Channel Strenght.
  112877. */
  112878. occlusionStrength: number;
  112879. /**
  112880. * Occlusion Texture of the material (adding extra occlusion effects).
  112881. */
  112882. occlusionTexture: BaseTexture;
  112883. /**
  112884. * Defines the alpha limits in alpha test mode.
  112885. */
  112886. alphaCutOff: number;
  112887. /**
  112888. * Gets the current double sided mode.
  112889. */
  112890. /**
  112891. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  112892. */
  112893. doubleSided: boolean;
  112894. /**
  112895. * Stores the pre-calculated light information of a mesh in a texture.
  112896. */
  112897. lightmapTexture: BaseTexture;
  112898. /**
  112899. * If true, the light map contains occlusion information instead of lighting info.
  112900. */
  112901. useLightmapAsShadowmap: boolean;
  112902. /**
  112903. * Instantiates a new PBRMaterial instance.
  112904. *
  112905. * @param name The material name
  112906. * @param scene The scene the material will be use in.
  112907. */
  112908. constructor(name: string, scene: Scene);
  112909. getClassName(): string;
  112910. }
  112911. }
  112912. declare module BABYLON {
  112913. /**
  112914. * The PBR material of BJS following the metal roughness convention.
  112915. *
  112916. * This fits to the PBR convention in the GLTF definition:
  112917. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  112918. */
  112919. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  112920. /**
  112921. * The base color has two different interpretations depending on the value of metalness.
  112922. * When the material is a metal, the base color is the specific measured reflectance value
  112923. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  112924. * of the material.
  112925. */
  112926. baseColor: Color3;
  112927. /**
  112928. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  112929. * well as opacity information in the alpha channel.
  112930. */
  112931. baseTexture: BaseTexture;
  112932. /**
  112933. * Specifies the metallic scalar value of the material.
  112934. * Can also be used to scale the metalness values of the metallic texture.
  112935. */
  112936. metallic: number;
  112937. /**
  112938. * Specifies the roughness scalar value of the material.
  112939. * Can also be used to scale the roughness values of the metallic texture.
  112940. */
  112941. roughness: number;
  112942. /**
  112943. * Texture containing both the metallic value in the B channel and the
  112944. * roughness value in the G channel to keep better precision.
  112945. */
  112946. metallicRoughnessTexture: BaseTexture;
  112947. /**
  112948. * Instantiates a new PBRMetalRoughnessMaterial instance.
  112949. *
  112950. * @param name The material name
  112951. * @param scene The scene the material will be use in.
  112952. */
  112953. constructor(name: string, scene: Scene);
  112954. /**
  112955. * Return the currrent class name of the material.
  112956. */
  112957. getClassName(): string;
  112958. /**
  112959. * Makes a duplicate of the current material.
  112960. * @param name - name to use for the new material.
  112961. */
  112962. clone(name: string): PBRMetallicRoughnessMaterial;
  112963. /**
  112964. * Serialize the material to a parsable JSON object.
  112965. */
  112966. serialize(): any;
  112967. /**
  112968. * Parses a JSON object correponding to the serialize function.
  112969. */
  112970. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  112971. }
  112972. }
  112973. declare module BABYLON {
  112974. /**
  112975. * The PBR material of BJS following the specular glossiness convention.
  112976. *
  112977. * This fits to the PBR convention in the GLTF definition:
  112978. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  112979. */
  112980. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  112981. /**
  112982. * Specifies the diffuse color of the material.
  112983. */
  112984. diffuseColor: Color3;
  112985. /**
  112986. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  112987. * channel.
  112988. */
  112989. diffuseTexture: BaseTexture;
  112990. /**
  112991. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  112992. */
  112993. specularColor: Color3;
  112994. /**
  112995. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  112996. */
  112997. glossiness: number;
  112998. /**
  112999. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  113000. */
  113001. specularGlossinessTexture: BaseTexture;
  113002. /**
  113003. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  113004. *
  113005. * @param name The material name
  113006. * @param scene The scene the material will be use in.
  113007. */
  113008. constructor(name: string, scene: Scene);
  113009. /**
  113010. * Return the currrent class name of the material.
  113011. */
  113012. getClassName(): string;
  113013. /**
  113014. * Makes a duplicate of the current material.
  113015. * @param name - name to use for the new material.
  113016. */
  113017. clone(name: string): PBRSpecularGlossinessMaterial;
  113018. /**
  113019. * Serialize the material to a parsable JSON object.
  113020. */
  113021. serialize(): any;
  113022. /**
  113023. * Parses a JSON object correponding to the serialize function.
  113024. */
  113025. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  113026. }
  113027. }
  113028. declare module BABYLON {
  113029. /**
  113030. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  113031. * It can help converting any input color in a desired output one. This can then be used to create effects
  113032. * from sepia, black and white to sixties or futuristic rendering...
  113033. *
  113034. * The only supported format is currently 3dl.
  113035. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  113036. */
  113037. export class ColorGradingTexture extends BaseTexture {
  113038. /**
  113039. * The current texture matrix. (will always be identity in color grading texture)
  113040. */
  113041. private _textureMatrix;
  113042. /**
  113043. * The texture URL.
  113044. */
  113045. url: string;
  113046. /**
  113047. * Empty line regex stored for GC.
  113048. */
  113049. private static _noneEmptyLineRegex;
  113050. private _engine;
  113051. /**
  113052. * Instantiates a ColorGradingTexture from the following parameters.
  113053. *
  113054. * @param url The location of the color gradind data (currently only supporting 3dl)
  113055. * @param scene The scene the texture will be used in
  113056. */
  113057. constructor(url: string, scene: Scene);
  113058. /**
  113059. * Returns the texture matrix used in most of the material.
  113060. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  113061. */
  113062. getTextureMatrix(): Matrix;
  113063. /**
  113064. * Occurs when the file being loaded is a .3dl LUT file.
  113065. */
  113066. private load3dlTexture;
  113067. /**
  113068. * Starts the loading process of the texture.
  113069. */
  113070. private loadTexture;
  113071. /**
  113072. * Clones the color gradind texture.
  113073. */
  113074. clone(): ColorGradingTexture;
  113075. /**
  113076. * Called during delayed load for textures.
  113077. */
  113078. delayLoad(): void;
  113079. /**
  113080. * Parses a color grading texture serialized by Babylon.
  113081. * @param parsedTexture The texture information being parsedTexture
  113082. * @param scene The scene to load the texture in
  113083. * @param rootUrl The root url of the data assets to load
  113084. * @return A color gradind texture
  113085. */
  113086. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  113087. /**
  113088. * Serializes the LUT texture to json format.
  113089. */
  113090. serialize(): any;
  113091. }
  113092. }
  113093. declare module BABYLON {
  113094. /**
  113095. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  113096. */
  113097. export class EquiRectangularCubeTexture extends BaseTexture {
  113098. /** The six faces of the cube. */
  113099. private static _FacesMapping;
  113100. private _noMipmap;
  113101. private _onLoad;
  113102. private _onError;
  113103. /** The size of the cubemap. */
  113104. private _size;
  113105. /** The buffer of the image. */
  113106. private _buffer;
  113107. /** The width of the input image. */
  113108. private _width;
  113109. /** The height of the input image. */
  113110. private _height;
  113111. /** The URL to the image. */
  113112. url: string;
  113113. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  113114. coordinatesMode: number;
  113115. /**
  113116. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  113117. * @param url The location of the image
  113118. * @param scene The scene the texture will be used in
  113119. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  113120. * @param noMipmap Forces to not generate the mipmap if true
  113121. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  113122. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  113123. * @param onLoad — defines a callback called when texture is loaded
  113124. * @param onError — defines a callback called if there is an error
  113125. */
  113126. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  113127. /**
  113128. * Load the image data, by putting the image on a canvas and extracting its buffer.
  113129. */
  113130. private loadImage;
  113131. /**
  113132. * Convert the image buffer into a cubemap and create a CubeTexture.
  113133. */
  113134. private loadTexture;
  113135. /**
  113136. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  113137. * @param buffer The ArrayBuffer that should be converted.
  113138. * @returns The buffer as Float32Array.
  113139. */
  113140. private getFloat32ArrayFromArrayBuffer;
  113141. /**
  113142. * Get the current class name of the texture useful for serialization or dynamic coding.
  113143. * @returns "EquiRectangularCubeTexture"
  113144. */
  113145. getClassName(): string;
  113146. /**
  113147. * Create a clone of the current EquiRectangularCubeTexture and return it.
  113148. * @returns A clone of the current EquiRectangularCubeTexture.
  113149. */
  113150. clone(): EquiRectangularCubeTexture;
  113151. }
  113152. }
  113153. declare module BABYLON {
  113154. /**
  113155. * Based on jsTGALoader - Javascript loader for TGA file
  113156. * By Vincent Thibault
  113157. * @see http://blog.robrowser.com/javascript-tga-loader.html
  113158. */
  113159. export class TGATools {
  113160. private static _TYPE_INDEXED;
  113161. private static _TYPE_RGB;
  113162. private static _TYPE_GREY;
  113163. private static _TYPE_RLE_INDEXED;
  113164. private static _TYPE_RLE_RGB;
  113165. private static _TYPE_RLE_GREY;
  113166. private static _ORIGIN_MASK;
  113167. private static _ORIGIN_SHIFT;
  113168. private static _ORIGIN_BL;
  113169. private static _ORIGIN_BR;
  113170. private static _ORIGIN_UL;
  113171. private static _ORIGIN_UR;
  113172. /**
  113173. * Gets the header of a TGA file
  113174. * @param data defines the TGA data
  113175. * @returns the header
  113176. */
  113177. static GetTGAHeader(data: Uint8Array): any;
  113178. /**
  113179. * Uploads TGA content to a Babylon Texture
  113180. * @hidden
  113181. */
  113182. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  113183. /** @hidden */
  113184. 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;
  113185. /** @hidden */
  113186. 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;
  113187. /** @hidden */
  113188. 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;
  113189. /** @hidden */
  113190. 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;
  113191. /** @hidden */
  113192. 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;
  113193. /** @hidden */
  113194. 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;
  113195. }
  113196. }
  113197. declare module BABYLON {
  113198. /**
  113199. * Implementation of the TGA Texture Loader.
  113200. * @hidden
  113201. */
  113202. export class _TGATextureLoader implements IInternalTextureLoader {
  113203. /**
  113204. * Defines wether the loader supports cascade loading the different faces.
  113205. */
  113206. readonly supportCascades: boolean;
  113207. /**
  113208. * This returns if the loader support the current file information.
  113209. * @param extension defines the file extension of the file being loaded
  113210. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113211. * @param fallback defines the fallback internal texture if any
  113212. * @param isBase64 defines whether the texture is encoded as a base64
  113213. * @param isBuffer defines whether the texture data are stored as a buffer
  113214. * @returns true if the loader can load the specified file
  113215. */
  113216. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113217. /**
  113218. * Transform the url before loading if required.
  113219. * @param rootUrl the url of the texture
  113220. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113221. * @returns the transformed texture
  113222. */
  113223. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113224. /**
  113225. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113226. * @param rootUrl the url of the texture
  113227. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113228. * @returns the fallback texture
  113229. */
  113230. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113231. /**
  113232. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  113233. * @param data contains the texture data
  113234. * @param texture defines the BabylonJS internal texture
  113235. * @param createPolynomials will be true if polynomials have been requested
  113236. * @param onLoad defines the callback to trigger once the texture is ready
  113237. * @param onError defines the callback to trigger in case of error
  113238. */
  113239. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113240. /**
  113241. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113242. * @param data contains the texture data
  113243. * @param texture defines the BabylonJS internal texture
  113244. * @param callback defines the method to call once ready to upload
  113245. */
  113246. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  113247. }
  113248. }
  113249. declare module BABYLON {
  113250. /**
  113251. * Info about the .basis files
  113252. */
  113253. class BasisFileInfo {
  113254. /**
  113255. * If the file has alpha
  113256. */
  113257. hasAlpha: boolean;
  113258. /**
  113259. * Info about each image of the basis file
  113260. */
  113261. images: Array<{
  113262. levels: Array<{
  113263. width: number;
  113264. height: number;
  113265. transcodedPixels: ArrayBufferView;
  113266. }>;
  113267. }>;
  113268. }
  113269. /**
  113270. * Result of transcoding a basis file
  113271. */
  113272. class TranscodeResult {
  113273. /**
  113274. * Info about the .basis file
  113275. */
  113276. fileInfo: BasisFileInfo;
  113277. /**
  113278. * Format to use when loading the file
  113279. */
  113280. format: number;
  113281. }
  113282. /**
  113283. * Configuration options for the Basis transcoder
  113284. */
  113285. export class BasisTranscodeConfiguration {
  113286. /**
  113287. * Supported compression formats used to determine the supported output format of the transcoder
  113288. */
  113289. supportedCompressionFormats?: {
  113290. /**
  113291. * etc1 compression format
  113292. */
  113293. etc1?: boolean;
  113294. /**
  113295. * s3tc compression format
  113296. */
  113297. s3tc?: boolean;
  113298. /**
  113299. * pvrtc compression format
  113300. */
  113301. pvrtc?: boolean;
  113302. /**
  113303. * etc2 compression format
  113304. */
  113305. etc2?: boolean;
  113306. };
  113307. /**
  113308. * If mipmap levels should be loaded for transcoded images (Default: true)
  113309. */
  113310. loadMipmapLevels?: boolean;
  113311. /**
  113312. * Index of a single image to load (Default: all images)
  113313. */
  113314. loadSingleImage?: number;
  113315. }
  113316. /**
  113317. * Used to load .Basis files
  113318. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  113319. */
  113320. export class BasisTools {
  113321. private static _IgnoreSupportedFormats;
  113322. /**
  113323. * URL to use when loading the basis transcoder
  113324. */
  113325. static JSModuleURL: string;
  113326. /**
  113327. * URL to use when loading the wasm module for the transcoder
  113328. */
  113329. static WasmModuleURL: string;
  113330. /**
  113331. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  113332. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  113333. * @returns internal format corresponding to the Basis format
  113334. */
  113335. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  113336. private static _WorkerPromise;
  113337. private static _Worker;
  113338. private static _actionId;
  113339. private static _CreateWorkerAsync;
  113340. /**
  113341. * Transcodes a loaded image file to compressed pixel data
  113342. * @param imageData image data to transcode
  113343. * @param config configuration options for the transcoding
  113344. * @returns a promise resulting in the transcoded image
  113345. */
  113346. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  113347. /**
  113348. * Loads a texture from the transcode result
  113349. * @param texture texture load to
  113350. * @param transcodeResult the result of transcoding the basis file to load from
  113351. */
  113352. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  113353. }
  113354. }
  113355. declare module BABYLON {
  113356. /**
  113357. * Loader for .basis file format
  113358. */
  113359. export class _BasisTextureLoader implements IInternalTextureLoader {
  113360. /**
  113361. * Defines whether the loader supports cascade loading the different faces.
  113362. */
  113363. readonly supportCascades: boolean;
  113364. /**
  113365. * This returns if the loader support the current file information.
  113366. * @param extension defines the file extension of the file being loaded
  113367. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113368. * @param fallback defines the fallback internal texture if any
  113369. * @param isBase64 defines whether the texture is encoded as a base64
  113370. * @param isBuffer defines whether the texture data are stored as a buffer
  113371. * @returns true if the loader can load the specified file
  113372. */
  113373. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113374. /**
  113375. * Transform the url before loading if required.
  113376. * @param rootUrl the url of the texture
  113377. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113378. * @returns the transformed texture
  113379. */
  113380. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113381. /**
  113382. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113383. * @param rootUrl the url of the texture
  113384. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113385. * @returns the fallback texture
  113386. */
  113387. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113388. /**
  113389. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  113390. * @param data contains the texture data
  113391. * @param texture defines the BabylonJS internal texture
  113392. * @param createPolynomials will be true if polynomials have been requested
  113393. * @param onLoad defines the callback to trigger once the texture is ready
  113394. * @param onError defines the callback to trigger in case of error
  113395. */
  113396. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113397. /**
  113398. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113399. * @param data contains the texture data
  113400. * @param texture defines the BabylonJS internal texture
  113401. * @param callback defines the method to call once ready to upload
  113402. */
  113403. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  113404. }
  113405. }
  113406. declare module BABYLON {
  113407. /**
  113408. * 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.
  113409. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  113410. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  113411. */
  113412. export class CustomProceduralTexture extends ProceduralTexture {
  113413. private _animate;
  113414. private _time;
  113415. private _config;
  113416. private _texturePath;
  113417. /**
  113418. * Instantiates a new Custom Procedural Texture.
  113419. * 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.
  113420. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  113421. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  113422. * @param name Define the name of the texture
  113423. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  113424. * @param size Define the size of the texture to create
  113425. * @param scene Define the scene the texture belongs to
  113426. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  113427. * @param generateMipMaps Define if the texture should creates mip maps or not
  113428. */
  113429. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  113430. private _loadJson;
  113431. /**
  113432. * Is the texture ready to be used ? (rendered at least once)
  113433. * @returns true if ready, otherwise, false.
  113434. */
  113435. isReady(): boolean;
  113436. /**
  113437. * Render the texture to its associated render target.
  113438. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  113439. */
  113440. render(useCameraPostProcess?: boolean): void;
  113441. /**
  113442. * Update the list of dependant textures samplers in the shader.
  113443. */
  113444. updateTextures(): void;
  113445. /**
  113446. * Update the uniform values of the procedural texture in the shader.
  113447. */
  113448. updateShaderUniforms(): void;
  113449. /**
  113450. * Define if the texture animates or not.
  113451. */
  113452. animate: boolean;
  113453. }
  113454. }
  113455. declare module BABYLON {
  113456. /** @hidden */
  113457. export var noisePixelShader: {
  113458. name: string;
  113459. shader: string;
  113460. };
  113461. }
  113462. declare module BABYLON {
  113463. /**
  113464. * Class used to generate noise procedural textures
  113465. */
  113466. export class NoiseProceduralTexture extends ProceduralTexture {
  113467. private _time;
  113468. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  113469. brightness: number;
  113470. /** Defines the number of octaves to process */
  113471. octaves: number;
  113472. /** Defines the level of persistence (0.8 by default) */
  113473. persistence: number;
  113474. /** Gets or sets animation speed factor (default is 1) */
  113475. animationSpeedFactor: number;
  113476. /**
  113477. * Creates a new NoiseProceduralTexture
  113478. * @param name defines the name fo the texture
  113479. * @param size defines the size of the texture (default is 256)
  113480. * @param scene defines the hosting scene
  113481. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  113482. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  113483. */
  113484. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  113485. private _updateShaderUniforms;
  113486. protected _getDefines(): string;
  113487. /** Generate the current state of the procedural texture */
  113488. render(useCameraPostProcess?: boolean): void;
  113489. /**
  113490. * Serializes this noise procedural texture
  113491. * @returns a serialized noise procedural texture object
  113492. */
  113493. serialize(): any;
  113494. /**
  113495. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  113496. * @param parsedTexture defines parsed texture data
  113497. * @param scene defines the current scene
  113498. * @param rootUrl defines the root URL containing noise procedural texture information
  113499. * @returns a parsed NoiseProceduralTexture
  113500. */
  113501. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  113502. }
  113503. }
  113504. declare module BABYLON {
  113505. /**
  113506. * Raw cube texture where the raw buffers are passed in
  113507. */
  113508. export class RawCubeTexture extends CubeTexture {
  113509. /**
  113510. * Creates a cube texture where the raw buffers are passed in.
  113511. * @param scene defines the scene the texture is attached to
  113512. * @param data defines the array of data to use to create each face
  113513. * @param size defines the size of the textures
  113514. * @param format defines the format of the data
  113515. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  113516. * @param generateMipMaps defines if the engine should generate the mip levels
  113517. * @param invertY defines if data must be stored with Y axis inverted
  113518. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  113519. * @param compression defines the compression used (null by default)
  113520. */
  113521. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  113522. /**
  113523. * Updates the raw cube texture.
  113524. * @param data defines the data to store
  113525. * @param format defines the data format
  113526. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  113527. * @param invertY defines if data must be stored with Y axis inverted
  113528. * @param compression defines the compression used (null by default)
  113529. * @param level defines which level of the texture to update
  113530. */
  113531. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  113532. /**
  113533. * Updates a raw cube texture with RGBD encoded data.
  113534. * @param data defines the array of data [mipmap][face] to use to create each face
  113535. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  113536. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  113537. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  113538. * @returns a promsie that resolves when the operation is complete
  113539. */
  113540. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  113541. /**
  113542. * Clones the raw cube texture.
  113543. * @return a new cube texture
  113544. */
  113545. clone(): CubeTexture;
  113546. /** @hidden */
  113547. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  113548. }
  113549. }
  113550. declare module BABYLON {
  113551. /**
  113552. * Class used to store 3D textures containing user data
  113553. */
  113554. export class RawTexture3D extends Texture {
  113555. /** Gets or sets the texture format to use */
  113556. format: number;
  113557. private _engine;
  113558. /**
  113559. * Create a new RawTexture3D
  113560. * @param data defines the data of the texture
  113561. * @param width defines the width of the texture
  113562. * @param height defines the height of the texture
  113563. * @param depth defines the depth of the texture
  113564. * @param format defines the texture format to use
  113565. * @param scene defines the hosting scene
  113566. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  113567. * @param invertY defines if texture must be stored with Y axis inverted
  113568. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  113569. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  113570. */
  113571. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  113572. /** Gets or sets the texture format to use */
  113573. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  113574. /**
  113575. * Update the texture with new data
  113576. * @param data defines the data to store in the texture
  113577. */
  113578. update(data: ArrayBufferView): void;
  113579. }
  113580. }
  113581. declare module BABYLON {
  113582. /**
  113583. * Creates a refraction texture used by refraction channel of the standard material.
  113584. * It is like a mirror but to see through a material.
  113585. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  113586. */
  113587. export class RefractionTexture extends RenderTargetTexture {
  113588. /**
  113589. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  113590. * 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.
  113591. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  113592. */
  113593. refractionPlane: Plane;
  113594. /**
  113595. * Define how deep under the surface we should see.
  113596. */
  113597. depth: number;
  113598. /**
  113599. * Creates a refraction texture used by refraction channel of the standard material.
  113600. * It is like a mirror but to see through a material.
  113601. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  113602. * @param name Define the texture name
  113603. * @param size Define the size of the underlying texture
  113604. * @param scene Define the scene the refraction belongs to
  113605. * @param generateMipMaps Define if we need to generate mips level for the refraction
  113606. */
  113607. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  113608. /**
  113609. * Clone the refraction texture.
  113610. * @returns the cloned texture
  113611. */
  113612. clone(): RefractionTexture;
  113613. /**
  113614. * Serialize the texture to a JSON representation you could use in Parse later on
  113615. * @returns the serialized JSON representation
  113616. */
  113617. serialize(): any;
  113618. }
  113619. }
  113620. declare module BABYLON {
  113621. /**
  113622. * Defines the options related to the creation of an HtmlElementTexture
  113623. */
  113624. export interface IHtmlElementTextureOptions {
  113625. /**
  113626. * Defines wether mip maps should be created or not.
  113627. */
  113628. generateMipMaps?: boolean;
  113629. /**
  113630. * Defines the sampling mode of the texture.
  113631. */
  113632. samplingMode?: number;
  113633. /**
  113634. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  113635. */
  113636. engine: Nullable<Engine>;
  113637. /**
  113638. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  113639. */
  113640. scene: Nullable<Scene>;
  113641. }
  113642. /**
  113643. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  113644. * To be as efficient as possible depending on your constraints nothing aside the first upload
  113645. * is automatically managed.
  113646. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  113647. * in your application.
  113648. *
  113649. * As the update is not automatic, you need to call them manually.
  113650. */
  113651. export class HtmlElementTexture extends BaseTexture {
  113652. /**
  113653. * The texture URL.
  113654. */
  113655. element: HTMLVideoElement | HTMLCanvasElement;
  113656. private static readonly DefaultOptions;
  113657. private _textureMatrix;
  113658. private _engine;
  113659. private _isVideo;
  113660. private _generateMipMaps;
  113661. private _samplingMode;
  113662. /**
  113663. * Instantiates a HtmlElementTexture from the following parameters.
  113664. *
  113665. * @param name Defines the name of the texture
  113666. * @param element Defines the video or canvas the texture is filled with
  113667. * @param options Defines the other none mandatory texture creation options
  113668. */
  113669. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  113670. private _createInternalTexture;
  113671. /**
  113672. * Returns the texture matrix used in most of the material.
  113673. */
  113674. getTextureMatrix(): Matrix;
  113675. /**
  113676. * Updates the content of the texture.
  113677. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  113678. */
  113679. update(invertY?: Nullable<boolean>): void;
  113680. }
  113681. }
  113682. declare module BABYLON {
  113683. /**
  113684. * Enum used to define the target of a block
  113685. */
  113686. export enum NodeMaterialBlockTargets {
  113687. /** Vertex shader */
  113688. Vertex = 1,
  113689. /** Fragment shader */
  113690. Fragment = 2,
  113691. /** Vertex and Fragment */
  113692. VertexAndFragment = 3
  113693. }
  113694. }
  113695. declare module BABYLON {
  113696. /**
  113697. * Defines the kind of connection point for node based material
  113698. */
  113699. export enum NodeMaterialBlockConnectionPointTypes {
  113700. /** Float */
  113701. Float = 1,
  113702. /** Int */
  113703. Int = 2,
  113704. /** Vector2 */
  113705. Vector2 = 4,
  113706. /** Vector3 */
  113707. Vector3 = 8,
  113708. /** Vector4 */
  113709. Vector4 = 16,
  113710. /** Color3 */
  113711. Color3 = 32,
  113712. /** Color4 */
  113713. Color4 = 64,
  113714. /** Matrix */
  113715. Matrix = 128,
  113716. /** Texture */
  113717. Texture = 256,
  113718. /** Texture3D */
  113719. Texture3D = 512,
  113720. /** Vector3 or Color3 */
  113721. Vector3OrColor3 = 40,
  113722. /** Vector3 or Vector4 */
  113723. Vector3OrVector4 = 24,
  113724. /** Vector4 or Color4 */
  113725. Vector4OrColor4 = 80,
  113726. /** Color3 or Color4 */
  113727. Color3OrColor4 = 96,
  113728. /** Vector3 or Color3 */
  113729. Vector3OrColor3OrVector4OrColor4 = 120,
  113730. /** Detect type based on connection */
  113731. AutoDetect = 1024,
  113732. /** Output type that will be defined by input type */
  113733. BasedOnInput = 2048,
  113734. /** Light */
  113735. Light = 4096
  113736. }
  113737. }
  113738. declare module BABYLON {
  113739. /**
  113740. * Enum used to define well known values e.g. values automatically provided by the system
  113741. */
  113742. export enum NodeMaterialWellKnownValues {
  113743. /** World */
  113744. World = 1,
  113745. /** View */
  113746. View = 2,
  113747. /** Projection */
  113748. Projection = 3,
  113749. /** ViewProjection */
  113750. ViewProjection = 4,
  113751. /** WorldView */
  113752. WorldView = 5,
  113753. /** WorldViewProjection */
  113754. WorldViewProjection = 6,
  113755. /** CameraPosition */
  113756. CameraPosition = 7,
  113757. /** Will be filled by the block itself */
  113758. Automatic = 8
  113759. }
  113760. }
  113761. declare module BABYLON {
  113762. /**
  113763. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  113764. */
  113765. export enum NodeMaterialBlockConnectionPointMode {
  113766. /** Value is an uniform */
  113767. Uniform = 0,
  113768. /** Value is a mesh attribute */
  113769. Attribute = 1,
  113770. /** Value is a varying between vertex and fragment shaders */
  113771. Varying = 2,
  113772. /** Mode is undefined */
  113773. Undefined = 3
  113774. }
  113775. }
  113776. declare module BABYLON {
  113777. /**
  113778. * Class used to store shared data between 2 NodeMaterialBuildState
  113779. */
  113780. export class NodeMaterialBuildStateSharedData {
  113781. /**
  113782. * Gets the list of emitted varyings
  113783. */
  113784. varyings: string[];
  113785. /**
  113786. * Gets the varying declaration string
  113787. */
  113788. varyingDeclaration: string;
  113789. /**
  113790. * Uniform connection points
  113791. */
  113792. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  113793. /**
  113794. * Bindable blocks (Blocks that need to set data to the effect)
  113795. */
  113796. bindableBlocks: NodeMaterialBlock[];
  113797. /**
  113798. * List of blocks that can provide a compilation fallback
  113799. */
  113800. blocksWithFallbacks: NodeMaterialBlock[];
  113801. /**
  113802. * List of blocks that can provide a define update
  113803. */
  113804. blocksWithDefines: NodeMaterialBlock[];
  113805. /**
  113806. * List of blocks that can provide a repeatable content
  113807. */
  113808. repeatableContentBlocks: NodeMaterialBlock[];
  113809. /**
  113810. * List of blocks that can provide a dynamic list of uniforms
  113811. */
  113812. dynamicUniformBlocks: NodeMaterialBlock[];
  113813. /**
  113814. * List of blocks that can block the isReady function for the material
  113815. */
  113816. blockingBlocks: NodeMaterialBlock[];
  113817. /**
  113818. * Build Id used to avoid multiple recompilations
  113819. */
  113820. buildId: number;
  113821. /** List of emitted variables */
  113822. variableNames: {
  113823. [key: string]: number;
  113824. };
  113825. /** List of emitted defines */
  113826. defineNames: {
  113827. [key: string]: number;
  113828. };
  113829. /** Should emit comments? */
  113830. emitComments: boolean;
  113831. /** Emit build activity */
  113832. verbose: boolean;
  113833. /**
  113834. * Gets the compilation hints emitted at compilation time
  113835. */
  113836. hints: {
  113837. needWorldViewMatrix: boolean;
  113838. needWorldViewProjectionMatrix: boolean;
  113839. needAlphaBlending: boolean;
  113840. needAlphaTesting: boolean;
  113841. };
  113842. /**
  113843. * List of compilation checks
  113844. */
  113845. checks: {
  113846. emitVertex: boolean;
  113847. emitFragment: boolean;
  113848. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  113849. };
  113850. /** Creates a new shared data */
  113851. constructor();
  113852. /**
  113853. * Emits console errors and exceptions if there is a failing check
  113854. */
  113855. emitErrors(): void;
  113856. }
  113857. }
  113858. declare module BABYLON {
  113859. /**
  113860. * Class used to store node based material build state
  113861. */
  113862. export class NodeMaterialBuildState {
  113863. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  113864. supportUniformBuffers: boolean;
  113865. /**
  113866. * Gets the list of emitted attributes
  113867. */
  113868. attributes: string[];
  113869. /**
  113870. * Gets the list of emitted uniforms
  113871. */
  113872. uniforms: string[];
  113873. /**
  113874. * Gets the list of emitted uniform buffers
  113875. */
  113876. uniformBuffers: string[];
  113877. /**
  113878. * Gets the list of emitted samplers
  113879. */
  113880. samplers: string[];
  113881. /**
  113882. * Gets the list of emitted functions
  113883. */
  113884. functions: {
  113885. [key: string]: string;
  113886. };
  113887. /**
  113888. * Gets the target of the compilation state
  113889. */
  113890. target: NodeMaterialBlockTargets;
  113891. /**
  113892. * Gets the list of emitted counters
  113893. */
  113894. counters: {
  113895. [key: string]: number;
  113896. };
  113897. /**
  113898. * Shared data between multiple NodeMaterialBuildState instances
  113899. */
  113900. sharedData: NodeMaterialBuildStateSharedData;
  113901. /** @hidden */
  113902. _vertexState: NodeMaterialBuildState;
  113903. private _attributeDeclaration;
  113904. private _uniformDeclaration;
  113905. private _samplerDeclaration;
  113906. private _varyingTransfer;
  113907. private _repeatableContentAnchorIndex;
  113908. /** @hidden */
  113909. _builtCompilationString: string;
  113910. /**
  113911. * Gets the emitted compilation strings
  113912. */
  113913. compilationString: string;
  113914. /**
  113915. * Finalize the compilation strings
  113916. * @param state defines the current compilation state
  113917. */
  113918. finalize(state: NodeMaterialBuildState): void;
  113919. /** @hidden */
  113920. readonly _repeatableContentAnchor: string;
  113921. /** @hidden */
  113922. _getFreeVariableName(prefix: string): string;
  113923. /** @hidden */
  113924. _getFreeDefineName(prefix: string): string;
  113925. /** @hidden */
  113926. _excludeVariableName(name: string): void;
  113927. /** @hidden */
  113928. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  113929. /** @hidden */
  113930. _emitFunction(name: string, code: string, comments: string): void;
  113931. /** @hidden */
  113932. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  113933. replaceStrings?: {
  113934. search: RegExp;
  113935. replace: string;
  113936. }[];
  113937. repeatKey?: string;
  113938. }): string;
  113939. /** @hidden */
  113940. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  113941. repeatKey?: string;
  113942. removeAttributes?: boolean;
  113943. removeUniforms?: boolean;
  113944. removeVaryings?: boolean;
  113945. removeIfDef?: boolean;
  113946. replaceStrings?: {
  113947. search: RegExp;
  113948. replace: string;
  113949. }[];
  113950. }, storeKey?: string): void;
  113951. /** @hidden */
  113952. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string, type?: Nullable<NodeMaterialBlockConnectionPointTypes>): void;
  113953. private _emitDefine;
  113954. /** @hidden */
  113955. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  113956. }
  113957. }
  113958. declare module BABYLON {
  113959. /**
  113960. * Root class for all node material optimizers
  113961. */
  113962. export class NodeMaterialOptimizer {
  113963. /**
  113964. * Function used to optimize a NodeMaterial graph
  113965. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  113966. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  113967. */
  113968. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  113969. }
  113970. }
  113971. declare module BABYLON {
  113972. /**
  113973. * Block used to transform a vector4 with a matrix
  113974. */
  113975. export class Vector4TransformBlock extends NodeMaterialBlock {
  113976. /**
  113977. * Defines the value to use to complement Vector3 to transform it to a Vector4
  113978. */
  113979. complementW: number;
  113980. /**
  113981. * Creates a new Vector4TransformBlock
  113982. * @param name defines the block name
  113983. */
  113984. constructor(name: string);
  113985. /**
  113986. * Gets the current class name
  113987. * @returns the class name
  113988. */
  113989. getClassName(): string;
  113990. /**
  113991. * Gets the vector input
  113992. */
  113993. readonly vector: NodeMaterialConnectionPoint;
  113994. /**
  113995. * Gets the output component
  113996. */
  113997. readonly output: NodeMaterialConnectionPoint;
  113998. /**
  113999. * Gets the matrix transform input
  114000. */
  114001. readonly transform: NodeMaterialConnectionPoint;
  114002. protected _buildBlock(state: NodeMaterialBuildState): this;
  114003. }
  114004. }
  114005. declare module BABYLON {
  114006. /**
  114007. * Block used to output the vertex position
  114008. */
  114009. export class VertexOutputBlock extends NodeMaterialBlock {
  114010. /**
  114011. * Creates a new VertexOutputBlock
  114012. * @param name defines the block name
  114013. */
  114014. constructor(name: string);
  114015. /**
  114016. * Gets the current class name
  114017. * @returns the class name
  114018. */
  114019. getClassName(): string;
  114020. /**
  114021. * Gets the vector input component
  114022. */
  114023. readonly vector: NodeMaterialConnectionPoint;
  114024. protected _buildBlock(state: NodeMaterialBuildState): this;
  114025. }
  114026. }
  114027. declare module BABYLON {
  114028. /**
  114029. * Block used to output the final color
  114030. */
  114031. export class FragmentOutputBlock extends NodeMaterialBlock {
  114032. /**
  114033. * Gets or sets a boolean indicating if this block will output an alpha value
  114034. */
  114035. alphaBlendingEnabled: boolean;
  114036. /**
  114037. * Create a new FragmentOutputBlock
  114038. * @param name defines the block name
  114039. */
  114040. constructor(name: string);
  114041. /**
  114042. * Gets the current class name
  114043. * @returns the class name
  114044. */
  114045. getClassName(): string;
  114046. /**
  114047. * Gets the color input component
  114048. */
  114049. readonly color: NodeMaterialConnectionPoint;
  114050. protected _buildBlock(state: NodeMaterialBuildState): this;
  114051. }
  114052. }
  114053. declare module BABYLON {
  114054. /**
  114055. * Interface used to configure the node material editor
  114056. */
  114057. export interface INodeMaterialEditorOptions {
  114058. /** Define the URl to load node editor script */
  114059. editorURL?: string;
  114060. }
  114061. /** @hidden */
  114062. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  114063. /** BONES */
  114064. NUM_BONE_INFLUENCERS: number;
  114065. BonesPerMesh: number;
  114066. BONETEXTURE: boolean;
  114067. /** MORPH TARGETS */
  114068. MORPHTARGETS: boolean;
  114069. MORPHTARGETS_NORMAL: boolean;
  114070. MORPHTARGETS_TANGENT: boolean;
  114071. MORPHTARGETS_UV: boolean;
  114072. NUM_MORPH_INFLUENCERS: number;
  114073. /** IMAGE PROCESSING */
  114074. IMAGEPROCESSING: boolean;
  114075. VIGNETTE: boolean;
  114076. VIGNETTEBLENDMODEMULTIPLY: boolean;
  114077. VIGNETTEBLENDMODEOPAQUE: boolean;
  114078. TONEMAPPING: boolean;
  114079. TONEMAPPING_ACES: boolean;
  114080. CONTRAST: boolean;
  114081. EXPOSURE: boolean;
  114082. COLORCURVES: boolean;
  114083. COLORGRADING: boolean;
  114084. COLORGRADING3D: boolean;
  114085. SAMPLER3DGREENDEPTH: boolean;
  114086. SAMPLER3DBGRMAP: boolean;
  114087. IMAGEPROCESSINGPOSTPROCESS: boolean;
  114088. constructor();
  114089. setValue(name: string, value: boolean): void;
  114090. }
  114091. /**
  114092. * Class used to configure NodeMaterial
  114093. */
  114094. export interface INodeMaterialOptions {
  114095. /**
  114096. * Defines if blocks should emit comments
  114097. */
  114098. emitComments: boolean;
  114099. }
  114100. /**
  114101. * Class used to create a node based material built by assembling shader blocks
  114102. */
  114103. export class NodeMaterial extends PushMaterial {
  114104. private _options;
  114105. private _vertexCompilationState;
  114106. private _fragmentCompilationState;
  114107. private _sharedData;
  114108. private _buildId;
  114109. private _buildWasSuccessful;
  114110. private _cachedWorldViewMatrix;
  114111. private _cachedWorldViewProjectionMatrix;
  114112. private _textureConnectionPoints;
  114113. private _optimizers;
  114114. /** Define the URl to load node editor script */
  114115. static EditorURL: string;
  114116. private BJSNODEMATERIALEDITOR;
  114117. /** Get the inspector from bundle or global */
  114118. private _getGlobalNodeMaterialEditor;
  114119. /**
  114120. * Defines the maximum number of lights that can be used in the material
  114121. */
  114122. maxSimultaneousLights: number;
  114123. /**
  114124. * Observable raised when the material is built
  114125. */
  114126. onBuildObservable: Observable<NodeMaterial>;
  114127. /**
  114128. * Gets or sets the root nodes of the material vertex shader
  114129. */
  114130. _vertexOutputNodes: NodeMaterialBlock[];
  114131. /**
  114132. * Gets or sets the root nodes of the material fragment (pixel) shader
  114133. */
  114134. _fragmentOutputNodes: NodeMaterialBlock[];
  114135. /** Gets or sets options to control the node material overall behavior */
  114136. options: INodeMaterialOptions;
  114137. /**
  114138. * Default configuration related to image processing available in the standard Material.
  114139. */
  114140. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114141. /**
  114142. * Gets the image processing configuration used either in this material.
  114143. */
  114144. /**
  114145. * Sets the Default image processing configuration used either in the this material.
  114146. *
  114147. * If sets to null, the scene one is in use.
  114148. */
  114149. imageProcessingConfiguration: ImageProcessingConfiguration;
  114150. /**
  114151. * Create a new node based material
  114152. * @param name defines the material name
  114153. * @param scene defines the hosting scene
  114154. * @param options defines creation option
  114155. */
  114156. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  114157. /**
  114158. * Gets the current class name of the material e.g. "NodeMaterial"
  114159. * @returns the class name
  114160. */
  114161. getClassName(): string;
  114162. /**
  114163. * Keep track of the image processing observer to allow dispose and replace.
  114164. */
  114165. private _imageProcessingObserver;
  114166. /**
  114167. * Attaches a new image processing configuration to the Standard Material.
  114168. * @param configuration
  114169. */
  114170. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  114171. /**
  114172. * Adds a new optimizer to the list of optimizers
  114173. * @param optimizer defines the optimizers to add
  114174. * @returns the current material
  114175. */
  114176. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  114177. /**
  114178. * Remove an optimizer from the list of optimizers
  114179. * @param optimizer defines the optimizers to remove
  114180. * @returns the current material
  114181. */
  114182. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  114183. /**
  114184. * Add a new block to the list of output nodes
  114185. * @param node defines the node to add
  114186. * @returns the current material
  114187. */
  114188. addOutputNode(node: NodeMaterialBlock): this;
  114189. /**
  114190. * Remove a block from the list of root nodes
  114191. * @param node defines the node to remove
  114192. * @returns the current material
  114193. */
  114194. removeOutputNode(node: NodeMaterialBlock): this;
  114195. private _addVertexOutputNode;
  114196. private _removeVertexOutputNode;
  114197. private _addFragmentOutputNode;
  114198. private _removeFragmentOutputNode;
  114199. /**
  114200. * Specifies if the material will require alpha blending
  114201. * @returns a boolean specifying if alpha blending is needed
  114202. */
  114203. needAlphaBlending(): boolean;
  114204. /**
  114205. * Specifies if this material should be rendered in alpha test mode
  114206. * @returns a boolean specifying if an alpha test is needed.
  114207. */
  114208. needAlphaTesting(): boolean;
  114209. private _initializeBlock;
  114210. private _resetDualBlocks;
  114211. /**
  114212. * Build the material and generates the inner effect
  114213. * @param verbose defines if the build should log activity
  114214. */
  114215. build(verbose?: boolean): void;
  114216. /**
  114217. * Runs an otpimization phase to try to improve the shader code
  114218. */
  114219. optimize(): void;
  114220. private _prepareDefinesForAttributes;
  114221. /**
  114222. * Get if the submesh is ready to be used and all its information available.
  114223. * Child classes can use it to update shaders
  114224. * @param mesh defines the mesh to check
  114225. * @param subMesh defines which submesh to check
  114226. * @param useInstances specifies that instances should be used
  114227. * @returns a boolean indicating that the submesh is ready or not
  114228. */
  114229. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  114230. /**
  114231. * Binds the world matrix to the material
  114232. * @param world defines the world transformation matrix
  114233. */
  114234. bindOnlyWorldMatrix(world: Matrix): void;
  114235. /**
  114236. * Binds the submesh to this material by preparing the effect and shader to draw
  114237. * @param world defines the world transformation matrix
  114238. * @param mesh defines the mesh containing the submesh
  114239. * @param subMesh defines the submesh to bind the material to
  114240. */
  114241. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  114242. /**
  114243. * Gets the active textures from the material
  114244. * @returns an array of textures
  114245. */
  114246. getActiveTextures(): BaseTexture[];
  114247. /**
  114248. * Specifies if the material uses a texture
  114249. * @param texture defines the texture to check against the material
  114250. * @returns a boolean specifying if the material uses the texture
  114251. */
  114252. hasTexture(texture: BaseTexture): boolean;
  114253. /**
  114254. * Disposes the material
  114255. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  114256. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  114257. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  114258. */
  114259. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  114260. /** Creates the node editor window. */
  114261. private _createNodeEditor;
  114262. /**
  114263. * Launch the node material editor
  114264. * @param config Define the configuration of the editor
  114265. * @return a promise fulfilled when the node editor is visible
  114266. */
  114267. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  114268. /**
  114269. * Clear the current material
  114270. */
  114271. clear(): void;
  114272. /**
  114273. * Clear the current material and set it to a default state
  114274. */
  114275. setToDefault(): void;
  114276. }
  114277. }
  114278. declare module BABYLON {
  114279. /**
  114280. * Defines a block that can be used inside a node based material
  114281. */
  114282. export class NodeMaterialBlock {
  114283. private _buildId;
  114284. private _target;
  114285. private _isFinalMerger;
  114286. /** @hidden */
  114287. _inputs: NodeMaterialConnectionPoint[];
  114288. /** @hidden */
  114289. _outputs: NodeMaterialConnectionPoint[];
  114290. /**
  114291. * Gets or sets the name of the block
  114292. */
  114293. name: string;
  114294. /**
  114295. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  114296. */
  114297. readonly isFinalMerger: boolean;
  114298. /**
  114299. * Gets or sets the build Id
  114300. */
  114301. buildId: number;
  114302. /**
  114303. * Gets or sets the target of the block
  114304. */
  114305. target: NodeMaterialBlockTargets;
  114306. /**
  114307. * Gets the list of input points
  114308. */
  114309. readonly inputs: NodeMaterialConnectionPoint[];
  114310. /** Gets the list of output points */
  114311. readonly outputs: NodeMaterialConnectionPoint[];
  114312. /**
  114313. * Find an input by its name
  114314. * @param name defines the name of the input to look for
  114315. * @returns the input or null if not found
  114316. */
  114317. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  114318. /**
  114319. * Find an output by its name
  114320. * @param name defines the name of the outputto look for
  114321. * @returns the output or null if not found
  114322. */
  114323. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  114324. /**
  114325. * Creates a new NodeMaterialBlock
  114326. * @param name defines the block name
  114327. * @param target defines the target of that block (Vertex by default)
  114328. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  114329. */
  114330. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  114331. /**
  114332. * Initialize the block and prepare the context for build
  114333. * @param state defines the state that will be used for the build
  114334. */
  114335. initialize(state: NodeMaterialBuildState): void;
  114336. /**
  114337. * Bind data to effect. Will only be called for blocks with isBindable === true
  114338. * @param effect defines the effect to bind data to
  114339. * @param nodeMaterial defines the hosting NodeMaterial
  114340. * @param mesh defines the mesh that will be rendered
  114341. */
  114342. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114343. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  114344. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  114345. protected _writeFloat(value: number): string;
  114346. /**
  114347. * Gets the current class name e.g. "NodeMaterialBlock"
  114348. * @returns the class name
  114349. */
  114350. getClassName(): string;
  114351. /**
  114352. * Register a new input. Must be called inside a block constructor
  114353. * @param name defines the connection point name
  114354. * @param type defines the connection point type
  114355. * @param isOptional defines a boolean indicating that this input can be omitted
  114356. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  114357. * @returns the current block
  114358. */
  114359. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  114360. /**
  114361. * Register a new output. Must be called inside a block constructor
  114362. * @param name defines the connection point name
  114363. * @param type defines the connection point type
  114364. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  114365. * @returns the current block
  114366. */
  114367. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  114368. /**
  114369. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  114370. * @param forOutput defines an optional connection point to check compatibility with
  114371. * @returns the first available input or null
  114372. */
  114373. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  114374. /**
  114375. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  114376. * @param forBlock defines an optional block to check compatibility with
  114377. * @returns the first available input or null
  114378. */
  114379. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  114380. /**
  114381. * Connect current block with another block
  114382. * @param other defines the block to connect with
  114383. * @param options define the various options to help pick the right connections
  114384. * @returns the current block
  114385. */
  114386. connectTo(other: NodeMaterialBlock, options?: {
  114387. input?: string;
  114388. output?: string;
  114389. outputSwizzle?: string;
  114390. }): this | undefined;
  114391. protected _buildBlock(state: NodeMaterialBuildState): void;
  114392. /**
  114393. * Add uniforms, samplers and uniform buffers at compilation time
  114394. * @param state defines the state to update
  114395. * @param nodeMaterial defines the node material requesting the update
  114396. * @param defines defines the material defines to update
  114397. */
  114398. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114399. /**
  114400. * Add potential fallbacks if shader compilation fails
  114401. * @param mesh defines the mesh to be rendered
  114402. * @param fallbacks defines the current prioritized list of fallbacks
  114403. */
  114404. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  114405. /**
  114406. * Update defines for shader compilation
  114407. * @param mesh defines the mesh to be rendered
  114408. * @param nodeMaterial defines the node material requesting the update
  114409. * @param defines defines the material defines to update
  114410. * @param useInstances specifies that instances should be used
  114411. */
  114412. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  114413. /**
  114414. * Lets the block try to connect some inputs automatically
  114415. */
  114416. autoConfigure(): void;
  114417. /**
  114418. * Function called when a block is declared as repeatable content generator
  114419. * @param vertexShaderState defines the current compilation state for the vertex shader
  114420. * @param fragmentShaderState defines the current compilation state for the fragment shader
  114421. * @param mesh defines the mesh to be rendered
  114422. * @param defines defines the material defines to update
  114423. */
  114424. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  114425. /**
  114426. * Checks if the block is ready
  114427. * @param mesh defines the mesh to be rendered
  114428. * @param nodeMaterial defines the node material requesting the update
  114429. * @param defines defines the material defines to update
  114430. * @param useInstances specifies that instances should be used
  114431. * @returns true if the block is ready
  114432. */
  114433. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  114434. /**
  114435. * Compile the current node and generate the shader code
  114436. * @param state defines the current compilation state (uniforms, samplers, current string)
  114437. * @returns the current block
  114438. */
  114439. build(state: NodeMaterialBuildState): this | undefined;
  114440. }
  114441. }
  114442. declare module BABYLON {
  114443. /**
  114444. * Defines a connection point for a block
  114445. */
  114446. export class NodeMaterialConnectionPoint {
  114447. /** @hidden */
  114448. _ownerBlock: NodeMaterialBlock;
  114449. /** @hidden */
  114450. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  114451. private _associatedVariableName;
  114452. private _endpoints;
  114453. private _storedValue;
  114454. private _valueCallback;
  114455. private _mode;
  114456. /** @hidden */
  114457. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  114458. /** @hidden */
  114459. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  114460. /** @hidden */
  114461. _needToEmitVarying: boolean;
  114462. /** @hidden */
  114463. _forceUniformInVertexShaderOnly: boolean;
  114464. private _type;
  114465. /**
  114466. * Gets or sets the connection point type (default is float)
  114467. */
  114468. type: NodeMaterialBlockConnectionPointTypes;
  114469. /**
  114470. * Gets or sets the connection point name
  114471. */
  114472. name: string;
  114473. /**
  114474. * Gets or sets the swizzle to apply to this connection point when reading or writing
  114475. */
  114476. swizzle: string;
  114477. /**
  114478. * Gets or sets a boolean indicating that this connection point can be omitted
  114479. */
  114480. isOptional: boolean;
  114481. /**
  114482. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  114483. */
  114484. define: string;
  114485. /** Gets or sets the target of that connection point */
  114486. target: NodeMaterialBlockTargets;
  114487. /**
  114488. * Gets or sets the value of that point.
  114489. * Please note that this value will be ignored if valueCallback is defined
  114490. */
  114491. value: any;
  114492. /**
  114493. * Gets or sets a callback used to get the value of that point.
  114494. * Please note that setting this value will force the connection point to ignore the value property
  114495. */
  114496. valueCallback: () => any;
  114497. /**
  114498. * Gets or sets the associated variable name in the shader
  114499. */
  114500. associatedVariableName: string;
  114501. /**
  114502. * Gets a boolean indicating that this connection point not defined yet
  114503. */
  114504. readonly isUndefined: boolean;
  114505. /**
  114506. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  114507. * In this case the connection point name must be the name of the uniform to use.
  114508. * Can only be set on inputs
  114509. */
  114510. isUniform: boolean;
  114511. /**
  114512. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  114513. * In this case the connection point name must be the name of the attribute to use
  114514. * Can only be set on inputs
  114515. */
  114516. isAttribute: boolean;
  114517. /**
  114518. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  114519. * Can only be set on exit points
  114520. */
  114521. isVarying: boolean;
  114522. /** Get the other side of the connection (if any) */
  114523. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  114524. /** Get the block that owns this connection point */
  114525. readonly ownerBlock: NodeMaterialBlock;
  114526. /** Get the block connected on the other side of this connection (if any) */
  114527. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  114528. /** Get the block connected on the endpoints of this connection (if any) */
  114529. readonly connectedBlocks: Array<NodeMaterialBlock>;
  114530. /**
  114531. * Creates a new connection point
  114532. * @param name defines the connection point name
  114533. * @param ownerBlock defines the block hosting this connection point
  114534. */
  114535. constructor(name: string, ownerBlock: NodeMaterialBlock);
  114536. /**
  114537. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  114538. * @returns the class name
  114539. */
  114540. getClassName(): string;
  114541. /**
  114542. * Set the source of this connection point to a vertex attribute
  114543. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  114544. * @returns the current connection point
  114545. */
  114546. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  114547. /**
  114548. * Set the source of this connection point to a well known value
  114549. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  114550. * @returns the current connection point
  114551. */
  114552. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  114553. /**
  114554. * Gets a boolean indicating that the current connection point is a well known value
  114555. */
  114556. readonly isWellKnownValue: boolean;
  114557. /**
  114558. * Gets or sets the current well known value or null if not defined as well know value
  114559. */
  114560. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  114561. private _getTypeLength;
  114562. /**
  114563. * Gets an boolean indicating if the current point can be connected to another point
  114564. * @param connectionPoint defines the other connection point
  114565. * @returns true if the connection is possible
  114566. */
  114567. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  114568. /**
  114569. * Connect this point to another connection point
  114570. * @param connectionPoint defines the other connection point
  114571. * @returns the current connection point
  114572. */
  114573. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  114574. /**
  114575. * Disconnect this point from one of his endpoint
  114576. * @param endpoint defines the other connection point
  114577. * @returns the current connection point
  114578. */
  114579. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  114580. /**
  114581. * When connection point is an uniform, this function will send its value to the effect
  114582. * @param effect defines the effect to transmit value to
  114583. * @param world defines the world matrix
  114584. * @param worldView defines the worldxview matrix
  114585. * @param worldViewProjection defines the worldxviewxprojection matrix
  114586. */
  114587. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  114588. /**
  114589. * When connection point is an uniform, this function will send its value to the effect
  114590. * @param effect defines the effect to transmit value to
  114591. * @param scene defines the hosting scene
  114592. */
  114593. transmit(effect: Effect, scene: Scene): void;
  114594. }
  114595. }
  114596. declare module BABYLON {
  114597. /**
  114598. * Block used to add support for vertex skinning (bones)
  114599. */
  114600. export class BonesBlock extends NodeMaterialBlock {
  114601. /**
  114602. * Creates a new BonesBlock
  114603. * @param name defines the block name
  114604. */
  114605. constructor(name: string);
  114606. /**
  114607. * Initialize the block and prepare the context for build
  114608. * @param state defines the state that will be used for the build
  114609. */
  114610. initialize(state: NodeMaterialBuildState): void;
  114611. /**
  114612. * Gets the current class name
  114613. * @returns the class name
  114614. */
  114615. getClassName(): string;
  114616. /**
  114617. * Gets the matrix indices input component
  114618. */
  114619. readonly matricesIndices: NodeMaterialConnectionPoint;
  114620. /**
  114621. * Gets the matrix weights input component
  114622. */
  114623. readonly matricesWeights: NodeMaterialConnectionPoint;
  114624. /**
  114625. * Gets the extra matrix indices input component
  114626. */
  114627. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  114628. /**
  114629. * Gets the extra matrix weights input component
  114630. */
  114631. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  114632. /**
  114633. * Gets the world input component
  114634. */
  114635. readonly world: NodeMaterialConnectionPoint;
  114636. /**
  114637. * Gets the output component
  114638. */
  114639. readonly output: NodeMaterialConnectionPoint;
  114640. autoConfigure(): void;
  114641. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  114642. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114643. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114644. protected _buildBlock(state: NodeMaterialBuildState): this;
  114645. }
  114646. }
  114647. declare module BABYLON {
  114648. /**
  114649. * Block used to add support for instances
  114650. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  114651. */
  114652. export class InstancesBlock extends NodeMaterialBlock {
  114653. /**
  114654. * Creates a new InstancesBlock
  114655. * @param name defines the block name
  114656. */
  114657. constructor(name: string);
  114658. /**
  114659. * Gets the current class name
  114660. * @returns the class name
  114661. */
  114662. getClassName(): string;
  114663. /**
  114664. * Gets the first world row input component
  114665. */
  114666. readonly world0: NodeMaterialConnectionPoint;
  114667. /**
  114668. * Gets the second world row input component
  114669. */
  114670. readonly world1: NodeMaterialConnectionPoint;
  114671. /**
  114672. * Gets the third world row input component
  114673. */
  114674. readonly world2: NodeMaterialConnectionPoint;
  114675. /**
  114676. * Gets the forth world row input component
  114677. */
  114678. readonly world3: NodeMaterialConnectionPoint;
  114679. /**
  114680. * Gets the world input component
  114681. */
  114682. readonly world: NodeMaterialConnectionPoint;
  114683. /**
  114684. * Gets the output component
  114685. */
  114686. readonly output: NodeMaterialConnectionPoint;
  114687. autoConfigure(): void;
  114688. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  114689. protected _buildBlock(state: NodeMaterialBuildState): this;
  114690. }
  114691. }
  114692. declare module BABYLON {
  114693. /**
  114694. * Block used to add morph targets support to vertex shader
  114695. */
  114696. export class MorphTargetsBlock extends NodeMaterialBlock {
  114697. private _repeatableContentAnchor;
  114698. private _repeatebleContentGenerated;
  114699. /**
  114700. * Create a new MorphTargetsBlock
  114701. * @param name defines the block name
  114702. */
  114703. constructor(name: string);
  114704. /**
  114705. * Gets the current class name
  114706. * @returns the class name
  114707. */
  114708. getClassName(): string;
  114709. /**
  114710. * Gets the position input component
  114711. */
  114712. readonly position: NodeMaterialConnectionPoint;
  114713. /**
  114714. * Gets the normal input component
  114715. */
  114716. readonly normal: NodeMaterialConnectionPoint;
  114717. /**
  114718. * Gets the tangent input component
  114719. */
  114720. readonly tangent: NodeMaterialConnectionPoint;
  114721. /**
  114722. * Gets the tangent input component
  114723. */
  114724. readonly uv: NodeMaterialConnectionPoint;
  114725. /**
  114726. * Gets the position output component
  114727. */
  114728. readonly positionOutput: NodeMaterialConnectionPoint;
  114729. /**
  114730. * Gets the normal output component
  114731. */
  114732. readonly normalOutput: NodeMaterialConnectionPoint;
  114733. /**
  114734. * Gets the tangent output component
  114735. */
  114736. readonly tangentOutput: NodeMaterialConnectionPoint;
  114737. /**
  114738. * Gets the tangent output component
  114739. */
  114740. readonly uvOutput: NodeMaterialConnectionPoint;
  114741. initialize(state: NodeMaterialBuildState): void;
  114742. autoConfigure(): void;
  114743. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114744. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114745. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  114746. protected _buildBlock(state: NodeMaterialBuildState): this;
  114747. }
  114748. }
  114749. declare module BABYLON {
  114750. /**
  114751. * Block used to add an alpha test in the fragment shader
  114752. */
  114753. export class AlphaTestBlock extends NodeMaterialBlock {
  114754. /**
  114755. * Gets or sets the alpha value where alpha testing happens
  114756. */
  114757. alphaCutOff: number;
  114758. /**
  114759. * Create a new AlphaTestBlock
  114760. * @param name defines the block name
  114761. */
  114762. constructor(name: string);
  114763. /**
  114764. * Gets the current class name
  114765. * @returns the class name
  114766. */
  114767. getClassName(): string;
  114768. /**
  114769. * Gets the color input component
  114770. */
  114771. readonly color: NodeMaterialConnectionPoint;
  114772. protected _buildBlock(state: NodeMaterialBuildState): this;
  114773. }
  114774. }
  114775. declare module BABYLON {
  114776. /**
  114777. * Block used to create a Color4 out of 4 inputs (one for each component)
  114778. */
  114779. export class RGBAMergerBlock extends NodeMaterialBlock {
  114780. /**
  114781. * Create a new RGBAMergerBlock
  114782. * @param name defines the block name
  114783. */
  114784. constructor(name: string);
  114785. /**
  114786. * Gets the current class name
  114787. * @returns the class name
  114788. */
  114789. getClassName(): string;
  114790. /**
  114791. * Gets the R input component
  114792. */
  114793. readonly r: NodeMaterialConnectionPoint;
  114794. /**
  114795. * Gets the G input component
  114796. */
  114797. readonly g: NodeMaterialConnectionPoint;
  114798. /**
  114799. * Gets the B input component
  114800. */
  114801. readonly b: NodeMaterialConnectionPoint;
  114802. /**
  114803. * Gets the RGB input component
  114804. */
  114805. readonly rgb: NodeMaterialConnectionPoint;
  114806. /**
  114807. * Gets the R input component
  114808. */
  114809. readonly a: NodeMaterialConnectionPoint;
  114810. /**
  114811. * Gets the output component
  114812. */
  114813. readonly output: NodeMaterialConnectionPoint;
  114814. protected _buildBlock(state: NodeMaterialBuildState): this;
  114815. }
  114816. }
  114817. declare module BABYLON {
  114818. /**
  114819. * Block used to create a Color3 out of 3 inputs (one for each component)
  114820. */
  114821. export class RGBMergerBlock extends NodeMaterialBlock {
  114822. /**
  114823. * Create a new RGBMergerBlock
  114824. * @param name defines the block name
  114825. */
  114826. constructor(name: string);
  114827. /**
  114828. * Gets the current class name
  114829. * @returns the class name
  114830. */
  114831. getClassName(): string;
  114832. /**
  114833. * Gets the R component input
  114834. */
  114835. readonly r: NodeMaterialConnectionPoint;
  114836. /**
  114837. * Gets the G component input
  114838. */
  114839. readonly g: NodeMaterialConnectionPoint;
  114840. /**
  114841. * Gets the B component input
  114842. */
  114843. readonly b: NodeMaterialConnectionPoint;
  114844. /**
  114845. * Gets the output component
  114846. */
  114847. readonly output: NodeMaterialConnectionPoint;
  114848. protected _buildBlock(state: NodeMaterialBuildState): this;
  114849. }
  114850. }
  114851. declare module BABYLON {
  114852. /**
  114853. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  114854. */
  114855. export class RGBASplitterBlock extends NodeMaterialBlock {
  114856. /**
  114857. * Create a new RGBASplitterBlock
  114858. * @param name defines the block name
  114859. */
  114860. constructor(name: string);
  114861. /**
  114862. * Gets the current class name
  114863. * @returns the class name
  114864. */
  114865. getClassName(): string;
  114866. /**
  114867. * Gets the input component
  114868. */
  114869. readonly input: NodeMaterialConnectionPoint;
  114870. protected _buildBlock(state: NodeMaterialBuildState): this;
  114871. }
  114872. }
  114873. declare module BABYLON {
  114874. /**
  114875. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  114876. */
  114877. export class RGBSplitterBlock extends NodeMaterialBlock {
  114878. /**
  114879. * Create a new RGBSplitterBlock
  114880. * @param name defines the block name
  114881. */
  114882. constructor(name: string);
  114883. /**
  114884. * Gets the current class name
  114885. * @returns the class name
  114886. */
  114887. getClassName(): string;
  114888. /**
  114889. * Gets the input component
  114890. */
  114891. readonly input: NodeMaterialConnectionPoint;
  114892. protected _buildBlock(state: NodeMaterialBuildState): this;
  114893. }
  114894. }
  114895. declare module BABYLON {
  114896. /**
  114897. * Block used to read a texture from a sampler
  114898. */
  114899. export class TextureBlock extends NodeMaterialBlock {
  114900. private _defineName;
  114901. /**
  114902. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  114903. */
  114904. autoConnectTextureMatrix: boolean;
  114905. /**
  114906. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  114907. */
  114908. autoSelectUV: boolean;
  114909. /**
  114910. * Create a new TextureBlock
  114911. * @param name defines the block name
  114912. */
  114913. constructor(name: string);
  114914. /**
  114915. * Gets the current class name
  114916. * @returns the class name
  114917. */
  114918. getClassName(): string;
  114919. /**
  114920. * Gets the uv input component
  114921. */
  114922. readonly uv: NodeMaterialConnectionPoint;
  114923. /**
  114924. * Gets the texture information input component
  114925. */
  114926. readonly textureInfo: NodeMaterialConnectionPoint;
  114927. /**
  114928. * Gets the transformed uv input component
  114929. */
  114930. readonly transformedUV: NodeMaterialConnectionPoint;
  114931. /**
  114932. * Gets the texture input component
  114933. */
  114934. readonly texture: NodeMaterialConnectionPoint;
  114935. /**
  114936. * Gets the texture transform input component
  114937. */
  114938. readonly textureTransform: NodeMaterialConnectionPoint;
  114939. /**
  114940. * Gets the output component
  114941. */
  114942. readonly output: NodeMaterialConnectionPoint;
  114943. autoConfigure(): void;
  114944. initialize(state: NodeMaterialBuildState): void;
  114945. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114946. isReady(): boolean;
  114947. private _injectVertexCode;
  114948. protected _buildBlock(state: NodeMaterialBuildState): this;
  114949. }
  114950. }
  114951. declare module BABYLON {
  114952. /**
  114953. * Block used to add image processing support to fragment shader
  114954. */
  114955. export class ImageProcessingBlock extends NodeMaterialBlock {
  114956. /**
  114957. * Create a new ImageProcessingBlock
  114958. * @param name defines the block name
  114959. */
  114960. constructor(name: string);
  114961. /**
  114962. * Gets the current class name
  114963. * @returns the class name
  114964. */
  114965. getClassName(): string;
  114966. /**
  114967. * Gets the color input component
  114968. */
  114969. readonly color: NodeMaterialConnectionPoint;
  114970. /**
  114971. * Gets the output component
  114972. */
  114973. readonly output: NodeMaterialConnectionPoint;
  114974. /**
  114975. * Initialize the block and prepare the context for build
  114976. * @param state defines the state that will be used for the build
  114977. */
  114978. initialize(state: NodeMaterialBuildState): void;
  114979. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  114980. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114981. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114982. protected _buildBlock(state: NodeMaterialBuildState): this;
  114983. }
  114984. }
  114985. declare module BABYLON {
  114986. /**
  114987. * Block used to add support for scene fog
  114988. */
  114989. export class FogBlock extends NodeMaterialBlock {
  114990. /**
  114991. * Create a new FogBlock
  114992. * @param name defines the block name
  114993. */
  114994. constructor(name: string);
  114995. /**
  114996. * Gets the current class name
  114997. * @returns the class name
  114998. */
  114999. getClassName(): string;
  115000. /**
  115001. * Gets the world position input component
  115002. */
  115003. readonly worldPosition: NodeMaterialConnectionPoint;
  115004. /**
  115005. * Gets the view input component
  115006. */
  115007. readonly view: NodeMaterialConnectionPoint;
  115008. /**
  115009. * Gets the color input component
  115010. */
  115011. readonly color: NodeMaterialConnectionPoint;
  115012. /**
  115013. * Gets the fog color input component
  115014. */
  115015. readonly fogColor: NodeMaterialConnectionPoint;
  115016. /**
  115017. * Gets the for parameter input component
  115018. */
  115019. readonly fogParameters: NodeMaterialConnectionPoint;
  115020. /**
  115021. * Gets the output component
  115022. */
  115023. readonly output: NodeMaterialConnectionPoint;
  115024. autoConfigure(): void;
  115025. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  115026. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  115027. protected _buildBlock(state: NodeMaterialBuildState): this;
  115028. }
  115029. }
  115030. declare module BABYLON {
  115031. /**
  115032. * Block used to add light in the fragment shader
  115033. */
  115034. export class LightBlock extends NodeMaterialBlock {
  115035. private _lightId;
  115036. /**
  115037. * Create a new LightBlock
  115038. * @param name defines the block name
  115039. */
  115040. constructor(name: string);
  115041. /**
  115042. * Gets the current class name
  115043. * @returns the class name
  115044. */
  115045. getClassName(): string;
  115046. /**
  115047. * Gets the world position input component
  115048. */
  115049. readonly worldPosition: NodeMaterialConnectionPoint;
  115050. /**
  115051. * Gets the world normal input component
  115052. */
  115053. readonly worldNormal: NodeMaterialConnectionPoint;
  115054. /**
  115055. * Gets the light input component.
  115056. * If not defined, all lights will be considered
  115057. */
  115058. readonly light: NodeMaterialConnectionPoint;
  115059. /**
  115060. * Gets the camera (or eye) position component
  115061. */
  115062. readonly cameraPosition: NodeMaterialConnectionPoint;
  115063. /**
  115064. * Gets the diffuse output component
  115065. */
  115066. readonly diffuseOutput: NodeMaterialConnectionPoint;
  115067. /**
  115068. * Gets the specular output component
  115069. */
  115070. readonly specularOutput: NodeMaterialConnectionPoint;
  115071. autoConfigure(): void;
  115072. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  115073. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  115074. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  115075. private _injectVertexCode;
  115076. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  115077. }
  115078. }
  115079. declare module BABYLON {
  115080. /**
  115081. * Block used to multiply 2 vector4
  115082. */
  115083. export class MultiplyBlock extends NodeMaterialBlock {
  115084. /**
  115085. * Creates a new MultiplyBlock
  115086. * @param name defines the block name
  115087. */
  115088. constructor(name: string);
  115089. /**
  115090. * Gets the current class name
  115091. * @returns the class name
  115092. */
  115093. getClassName(): string;
  115094. /**
  115095. * Gets the left operand input component
  115096. */
  115097. readonly left: NodeMaterialConnectionPoint;
  115098. /**
  115099. * Gets the right operand input component
  115100. */
  115101. readonly right: NodeMaterialConnectionPoint;
  115102. /**
  115103. * Gets the output component
  115104. */
  115105. readonly output: NodeMaterialConnectionPoint;
  115106. protected _buildBlock(state: NodeMaterialBuildState): this;
  115107. }
  115108. }
  115109. declare module BABYLON {
  115110. /**
  115111. * Block used to add 2 vector4
  115112. */
  115113. export class AddBlock extends NodeMaterialBlock {
  115114. /**
  115115. * Creates a new AddBlock
  115116. * @param name defines the block name
  115117. */
  115118. constructor(name: string);
  115119. /**
  115120. * Gets the current class name
  115121. * @returns the class name
  115122. */
  115123. getClassName(): string;
  115124. /**
  115125. * Gets the left operand input component
  115126. */
  115127. readonly left: NodeMaterialConnectionPoint;
  115128. /**
  115129. * Gets the right operand input component
  115130. */
  115131. readonly right: NodeMaterialConnectionPoint;
  115132. /**
  115133. * Gets the output component
  115134. */
  115135. readonly output: NodeMaterialConnectionPoint;
  115136. protected _buildBlock(state: NodeMaterialBuildState): this;
  115137. }
  115138. }
  115139. declare module BABYLON {
  115140. /**
  115141. * Block used to clamp a float
  115142. */
  115143. export class ClampBlock extends NodeMaterialBlock {
  115144. /** Gets or sets the minimum range */
  115145. minimum: number;
  115146. /** Gets or sets the maximum range */
  115147. maximum: number;
  115148. /**
  115149. * Creates a new ClampBlock
  115150. * @param name defines the block name
  115151. */
  115152. constructor(name: string);
  115153. /**
  115154. * Gets the current class name
  115155. * @returns the class name
  115156. */
  115157. getClassName(): string;
  115158. /**
  115159. * Gets the value input component
  115160. */
  115161. readonly value: NodeMaterialConnectionPoint;
  115162. /**
  115163. * Gets the output component
  115164. */
  115165. readonly output: NodeMaterialConnectionPoint;
  115166. protected _buildBlock(state: NodeMaterialBuildState): this;
  115167. }
  115168. }
  115169. declare module BABYLON {
  115170. /**
  115171. * Block used to scale a value
  115172. */
  115173. export class ScaleBlock extends NodeMaterialBlock {
  115174. /**
  115175. * Creates a new ScaleBlock
  115176. * @param name defines the block name
  115177. */
  115178. constructor(name: string);
  115179. /**
  115180. * Gets the current class name
  115181. * @returns the class name
  115182. */
  115183. getClassName(): string;
  115184. /**
  115185. * Gets the value operand input component
  115186. */
  115187. readonly value: NodeMaterialConnectionPoint;
  115188. /**
  115189. * Gets the scale operand input component
  115190. */
  115191. readonly scale: NodeMaterialConnectionPoint;
  115192. /**
  115193. * Gets the output component
  115194. */
  115195. readonly output: NodeMaterialConnectionPoint;
  115196. protected _buildBlock(state: NodeMaterialBuildState): this;
  115197. }
  115198. }
  115199. declare module BABYLON {
  115200. /**
  115201. * Block used to transform a vector2 with a matrix
  115202. */
  115203. export class Vector2TransformBlock extends NodeMaterialBlock {
  115204. /**
  115205. * Defines the value to use to complement Vector2 to transform it to a Vector4
  115206. */
  115207. complementZ: number;
  115208. /**
  115209. * Defines the value to use to complement Vector2 to transform it to a Vector4
  115210. */
  115211. complementW: number;
  115212. /**
  115213. * Creates a new Vector2TransformBlock
  115214. * @param name defines the block name
  115215. */
  115216. constructor(name: string);
  115217. /**
  115218. * Gets the vector input
  115219. */
  115220. readonly vector: NodeMaterialConnectionPoint;
  115221. /**
  115222. * Gets the matrix transform input
  115223. */
  115224. readonly transform: NodeMaterialConnectionPoint;
  115225. /**
  115226. * Gets the output component
  115227. */
  115228. readonly output: NodeMaterialConnectionPoint;
  115229. /**
  115230. * Gets the current class name
  115231. * @returns the class name
  115232. */
  115233. getClassName(): string;
  115234. protected _buildBlock(state: NodeMaterialBuildState): this;
  115235. }
  115236. }
  115237. declare module BABYLON {
  115238. /**
  115239. * Block used to transform a vector3 with a matrix
  115240. */
  115241. export class Vector3TransformBlock extends NodeMaterialBlock {
  115242. /**
  115243. * Defines the value to use to complement Vector3 to transform it to a Vector4
  115244. */
  115245. complement: number;
  115246. /**
  115247. * Creates a new Vector3TransformBlock
  115248. * @param name defines the block name
  115249. */
  115250. constructor(name: string);
  115251. /**
  115252. * Gets the vector input
  115253. */
  115254. readonly vector: NodeMaterialConnectionPoint;
  115255. /**
  115256. * Gets the matrix transform input
  115257. */
  115258. readonly transform: NodeMaterialConnectionPoint;
  115259. /**
  115260. * Gets the output component
  115261. */
  115262. readonly output: NodeMaterialConnectionPoint;
  115263. /**
  115264. * Gets the current class name
  115265. * @returns the class name
  115266. */
  115267. getClassName(): string;
  115268. protected _buildBlock(state: NodeMaterialBuildState): this;
  115269. }
  115270. }
  115271. declare module BABYLON {
  115272. /**
  115273. * Block used to multiply two matrices
  115274. */
  115275. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  115276. /**
  115277. * Creates a new MatrixMultiplicationBlock
  115278. * @param name defines the block name
  115279. */
  115280. constructor(name: string);
  115281. /**
  115282. * Gets the left operand
  115283. */
  115284. readonly left: NodeMaterialConnectionPoint;
  115285. /**
  115286. * Gets the right operand
  115287. */
  115288. readonly right: NodeMaterialConnectionPoint;
  115289. /**
  115290. * Gets the output component
  115291. */
  115292. readonly output: NodeMaterialConnectionPoint;
  115293. /**
  115294. * Gets the current class name
  115295. * @returns the class name
  115296. */
  115297. getClassName(): string;
  115298. protected _buildBlock(state: NodeMaterialBuildState): this;
  115299. }
  115300. }
  115301. declare module BABYLON {
  115302. /**
  115303. * Helper class to push actions to a pool of workers.
  115304. */
  115305. export class WorkerPool implements IDisposable {
  115306. private _workerInfos;
  115307. private _pendingActions;
  115308. /**
  115309. * Constructor
  115310. * @param workers Array of workers to use for actions
  115311. */
  115312. constructor(workers: Array<Worker>);
  115313. /**
  115314. * Terminates all workers and clears any pending actions.
  115315. */
  115316. dispose(): void;
  115317. /**
  115318. * Pushes an action to the worker pool. If all the workers are active, the action will be
  115319. * pended until a worker has completed its action.
  115320. * @param action The action to perform. Call onComplete when the action is complete.
  115321. */
  115322. push(action: (worker: Worker, onComplete: () => void) => void): void;
  115323. private _execute;
  115324. }
  115325. }
  115326. declare module BABYLON {
  115327. /**
  115328. * Configuration for Draco compression
  115329. */
  115330. export interface IDracoCompressionConfiguration {
  115331. /**
  115332. * Configuration for the decoder.
  115333. */
  115334. decoder: {
  115335. /**
  115336. * The url to the WebAssembly module.
  115337. */
  115338. wasmUrl?: string;
  115339. /**
  115340. * The url to the WebAssembly binary.
  115341. */
  115342. wasmBinaryUrl?: string;
  115343. /**
  115344. * The url to the fallback JavaScript module.
  115345. */
  115346. fallbackUrl?: string;
  115347. };
  115348. }
  115349. /**
  115350. * Draco compression (https://google.github.io/draco/)
  115351. *
  115352. * This class wraps the Draco module.
  115353. *
  115354. * **Encoder**
  115355. *
  115356. * The encoder is not currently implemented.
  115357. *
  115358. * **Decoder**
  115359. *
  115360. * 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.
  115361. *
  115362. * To update the configuration, use the following code:
  115363. * ```javascript
  115364. * DracoCompression.Configuration = {
  115365. * decoder: {
  115366. * wasmUrl: "<url to the WebAssembly library>",
  115367. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  115368. * fallbackUrl: "<url to the fallback JavaScript library>",
  115369. * }
  115370. * };
  115371. * ```
  115372. *
  115373. * 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.
  115374. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  115375. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  115376. *
  115377. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  115378. * ```javascript
  115379. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  115380. * ```
  115381. *
  115382. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  115383. */
  115384. export class DracoCompression implements IDisposable {
  115385. private _workerPoolPromise?;
  115386. private _decoderModulePromise?;
  115387. /**
  115388. * The configuration. Defaults to the following urls:
  115389. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  115390. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  115391. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  115392. */
  115393. static Configuration: IDracoCompressionConfiguration;
  115394. /**
  115395. * Returns true if the decoder configuration is available.
  115396. */
  115397. static readonly DecoderAvailable: boolean;
  115398. /**
  115399. * Default number of workers to create when creating the draco compression object.
  115400. */
  115401. static DefaultNumWorkers: number;
  115402. private static GetDefaultNumWorkers;
  115403. private static _Default;
  115404. /**
  115405. * Default instance for the draco compression object.
  115406. */
  115407. static readonly Default: DracoCompression;
  115408. /**
  115409. * Constructor
  115410. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  115411. */
  115412. constructor(numWorkers?: number);
  115413. /**
  115414. * Stop all async operations and release resources.
  115415. */
  115416. dispose(): void;
  115417. /**
  115418. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  115419. * @returns a promise that resolves when ready
  115420. */
  115421. whenReadyAsync(): Promise<void>;
  115422. /**
  115423. * Decode Draco compressed mesh data to vertex data.
  115424. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  115425. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  115426. * @returns A promise that resolves with the decoded vertex data
  115427. */
  115428. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  115429. [kind: string]: number;
  115430. }): Promise<VertexData>;
  115431. }
  115432. }
  115433. declare module BABYLON {
  115434. /**
  115435. * Class for building Constructive Solid Geometry
  115436. */
  115437. export class CSG {
  115438. private polygons;
  115439. /**
  115440. * The world matrix
  115441. */
  115442. matrix: Matrix;
  115443. /**
  115444. * Stores the position
  115445. */
  115446. position: Vector3;
  115447. /**
  115448. * Stores the rotation
  115449. */
  115450. rotation: Vector3;
  115451. /**
  115452. * Stores the rotation quaternion
  115453. */
  115454. rotationQuaternion: Nullable<Quaternion>;
  115455. /**
  115456. * Stores the scaling vector
  115457. */
  115458. scaling: Vector3;
  115459. /**
  115460. * Convert the Mesh to CSG
  115461. * @param mesh The Mesh to convert to CSG
  115462. * @returns A new CSG from the Mesh
  115463. */
  115464. static FromMesh(mesh: Mesh): CSG;
  115465. /**
  115466. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  115467. * @param polygons Polygons used to construct a CSG solid
  115468. */
  115469. private static FromPolygons;
  115470. /**
  115471. * Clones, or makes a deep copy, of the CSG
  115472. * @returns A new CSG
  115473. */
  115474. clone(): CSG;
  115475. /**
  115476. * Unions this CSG with another CSG
  115477. * @param csg The CSG to union against this CSG
  115478. * @returns The unioned CSG
  115479. */
  115480. union(csg: CSG): CSG;
  115481. /**
  115482. * Unions this CSG with another CSG in place
  115483. * @param csg The CSG to union against this CSG
  115484. */
  115485. unionInPlace(csg: CSG): void;
  115486. /**
  115487. * Subtracts this CSG with another CSG
  115488. * @param csg The CSG to subtract against this CSG
  115489. * @returns A new CSG
  115490. */
  115491. subtract(csg: CSG): CSG;
  115492. /**
  115493. * Subtracts this CSG with another CSG in place
  115494. * @param csg The CSG to subtact against this CSG
  115495. */
  115496. subtractInPlace(csg: CSG): void;
  115497. /**
  115498. * Intersect this CSG with another CSG
  115499. * @param csg The CSG to intersect against this CSG
  115500. * @returns A new CSG
  115501. */
  115502. intersect(csg: CSG): CSG;
  115503. /**
  115504. * Intersects this CSG with another CSG in place
  115505. * @param csg The CSG to intersect against this CSG
  115506. */
  115507. intersectInPlace(csg: CSG): void;
  115508. /**
  115509. * Return a new CSG solid with solid and empty space switched. This solid is
  115510. * not modified.
  115511. * @returns A new CSG solid with solid and empty space switched
  115512. */
  115513. inverse(): CSG;
  115514. /**
  115515. * Inverses the CSG in place
  115516. */
  115517. inverseInPlace(): void;
  115518. /**
  115519. * This is used to keep meshes transformations so they can be restored
  115520. * when we build back a Babylon Mesh
  115521. * NB : All CSG operations are performed in world coordinates
  115522. * @param csg The CSG to copy the transform attributes from
  115523. * @returns This CSG
  115524. */
  115525. copyTransformAttributes(csg: CSG): CSG;
  115526. /**
  115527. * Build Raw mesh from CSG
  115528. * Coordinates here are in world space
  115529. * @param name The name of the mesh geometry
  115530. * @param scene The Scene
  115531. * @param keepSubMeshes Specifies if the submeshes should be kept
  115532. * @returns A new Mesh
  115533. */
  115534. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  115535. /**
  115536. * Build Mesh from CSG taking material and transforms into account
  115537. * @param name The name of the Mesh
  115538. * @param material The material of the Mesh
  115539. * @param scene The Scene
  115540. * @param keepSubMeshes Specifies if submeshes should be kept
  115541. * @returns The new Mesh
  115542. */
  115543. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  115544. }
  115545. }
  115546. declare module BABYLON {
  115547. /**
  115548. * Class used to create a trail following a mesh
  115549. */
  115550. export class TrailMesh extends Mesh {
  115551. private _generator;
  115552. private _autoStart;
  115553. private _running;
  115554. private _diameter;
  115555. private _length;
  115556. private _sectionPolygonPointsCount;
  115557. private _sectionVectors;
  115558. private _sectionNormalVectors;
  115559. private _beforeRenderObserver;
  115560. /**
  115561. * @constructor
  115562. * @param name The value used by scene.getMeshByName() to do a lookup.
  115563. * @param generator The mesh to generate a trail.
  115564. * @param scene The scene to add this mesh to.
  115565. * @param diameter Diameter of trailing mesh. Default is 1.
  115566. * @param length Length of trailing mesh. Default is 60.
  115567. * @param autoStart Automatically start trailing mesh. Default true.
  115568. */
  115569. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  115570. /**
  115571. * "TrailMesh"
  115572. * @returns "TrailMesh"
  115573. */
  115574. getClassName(): string;
  115575. private _createMesh;
  115576. /**
  115577. * Start trailing mesh.
  115578. */
  115579. start(): void;
  115580. /**
  115581. * Stop trailing mesh.
  115582. */
  115583. stop(): void;
  115584. /**
  115585. * Update trailing mesh geometry.
  115586. */
  115587. update(): void;
  115588. /**
  115589. * Returns a new TrailMesh object.
  115590. * @param name is a string, the name given to the new mesh
  115591. * @param newGenerator use new generator object for cloned trail mesh
  115592. * @returns a new mesh
  115593. */
  115594. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  115595. /**
  115596. * Serializes this trail mesh
  115597. * @param serializationObject object to write serialization to
  115598. */
  115599. serialize(serializationObject: any): void;
  115600. /**
  115601. * Parses a serialized trail mesh
  115602. * @param parsedMesh the serialized mesh
  115603. * @param scene the scene to create the trail mesh in
  115604. * @returns the created trail mesh
  115605. */
  115606. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  115607. }
  115608. }
  115609. declare module BABYLON {
  115610. /**
  115611. * Class containing static functions to help procedurally build meshes
  115612. */
  115613. export class TiledBoxBuilder {
  115614. /**
  115615. * Creates a box mesh
  115616. * 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)
  115617. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115618. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115619. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115620. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115621. * @param name defines the name of the mesh
  115622. * @param options defines the options used to create the mesh
  115623. * @param scene defines the hosting scene
  115624. * @returns the box mesh
  115625. */
  115626. static CreateTiledBox(name: string, options: {
  115627. pattern?: number;
  115628. width?: number;
  115629. height?: number;
  115630. depth?: number;
  115631. tileSize?: number;
  115632. tileWidth?: number;
  115633. tileHeight?: number;
  115634. alignHorizontal?: number;
  115635. alignVertical?: number;
  115636. faceUV?: Vector4[];
  115637. faceColors?: Color4[];
  115638. sideOrientation?: number;
  115639. updatable?: boolean;
  115640. }, scene?: Nullable<Scene>): Mesh;
  115641. }
  115642. }
  115643. declare module BABYLON {
  115644. /**
  115645. * Class containing static functions to help procedurally build meshes
  115646. */
  115647. export class TorusKnotBuilder {
  115648. /**
  115649. * Creates a torus knot mesh
  115650. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  115651. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  115652. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  115653. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  115654. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115655. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115657. * @param name defines the name of the mesh
  115658. * @param options defines the options used to create the mesh
  115659. * @param scene defines the hosting scene
  115660. * @returns the torus knot mesh
  115661. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  115662. */
  115663. static CreateTorusKnot(name: string, options: {
  115664. radius?: number;
  115665. tube?: number;
  115666. radialSegments?: number;
  115667. tubularSegments?: number;
  115668. p?: number;
  115669. q?: number;
  115670. updatable?: boolean;
  115671. sideOrientation?: number;
  115672. frontUVs?: Vector4;
  115673. backUVs?: Vector4;
  115674. }, scene: any): Mesh;
  115675. }
  115676. }
  115677. declare module BABYLON {
  115678. /**
  115679. * Polygon
  115680. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  115681. */
  115682. export class Polygon {
  115683. /**
  115684. * Creates a rectangle
  115685. * @param xmin bottom X coord
  115686. * @param ymin bottom Y coord
  115687. * @param xmax top X coord
  115688. * @param ymax top Y coord
  115689. * @returns points that make the resulting rectation
  115690. */
  115691. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  115692. /**
  115693. * Creates a circle
  115694. * @param radius radius of circle
  115695. * @param cx scale in x
  115696. * @param cy scale in y
  115697. * @param numberOfSides number of sides that make up the circle
  115698. * @returns points that make the resulting circle
  115699. */
  115700. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  115701. /**
  115702. * Creates a polygon from input string
  115703. * @param input Input polygon data
  115704. * @returns the parsed points
  115705. */
  115706. static Parse(input: string): Vector2[];
  115707. /**
  115708. * Starts building a polygon from x and y coordinates
  115709. * @param x x coordinate
  115710. * @param y y coordinate
  115711. * @returns the started path2
  115712. */
  115713. static StartingAt(x: number, y: number): Path2;
  115714. }
  115715. /**
  115716. * Builds a polygon
  115717. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  115718. */
  115719. export class PolygonMeshBuilder {
  115720. private _points;
  115721. private _outlinepoints;
  115722. private _holes;
  115723. private _name;
  115724. private _scene;
  115725. private _epoints;
  115726. private _eholes;
  115727. private _addToepoint;
  115728. /**
  115729. * Babylon reference to the earcut plugin.
  115730. */
  115731. bjsEarcut: any;
  115732. /**
  115733. * Creates a PolygonMeshBuilder
  115734. * @param name name of the builder
  115735. * @param contours Path of the polygon
  115736. * @param scene scene to add to when creating the mesh
  115737. * @param earcutInjection can be used to inject your own earcut reference
  115738. */
  115739. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  115740. /**
  115741. * Adds a whole within the polygon
  115742. * @param hole Array of points defining the hole
  115743. * @returns this
  115744. */
  115745. addHole(hole: Vector2[]): PolygonMeshBuilder;
  115746. /**
  115747. * Creates the polygon
  115748. * @param updatable If the mesh should be updatable
  115749. * @param depth The depth of the mesh created
  115750. * @returns the created mesh
  115751. */
  115752. build(updatable?: boolean, depth?: number): Mesh;
  115753. /**
  115754. * Creates the polygon
  115755. * @param depth The depth of the mesh created
  115756. * @returns the created VertexData
  115757. */
  115758. buildVertexData(depth?: number): VertexData;
  115759. /**
  115760. * Adds a side to the polygon
  115761. * @param positions points that make the polygon
  115762. * @param normals normals of the polygon
  115763. * @param uvs uvs of the polygon
  115764. * @param indices indices of the polygon
  115765. * @param bounds bounds of the polygon
  115766. * @param points points of the polygon
  115767. * @param depth depth of the polygon
  115768. * @param flip flip of the polygon
  115769. */
  115770. private addSide;
  115771. }
  115772. }
  115773. declare module BABYLON {
  115774. /**
  115775. * Class containing static functions to help procedurally build meshes
  115776. */
  115777. export class PolygonBuilder {
  115778. /**
  115779. * Creates a polygon mesh
  115780. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  115781. * * 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
  115782. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  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. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  115785. * * Remember you can only change the shape positions, not their number when updating a polygon
  115786. * @param name defines the name of the mesh
  115787. * @param options defines the options used to create the mesh
  115788. * @param scene defines the hosting scene
  115789. * @param earcutInjection can be used to inject your own earcut reference
  115790. * @returns the polygon mesh
  115791. */
  115792. static CreatePolygon(name: string, options: {
  115793. shape: Vector3[];
  115794. holes?: Vector3[][];
  115795. depth?: number;
  115796. faceUV?: Vector4[];
  115797. faceColors?: Color4[];
  115798. updatable?: boolean;
  115799. sideOrientation?: number;
  115800. frontUVs?: Vector4;
  115801. backUVs?: Vector4;
  115802. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115803. /**
  115804. * Creates an extruded polygon mesh, with depth in the Y direction.
  115805. * * 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)
  115806. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115807. * @param name defines the name of the mesh
  115808. * @param options defines the options used to create the mesh
  115809. * @param scene defines the hosting scene
  115810. * @param earcutInjection can be used to inject your own earcut reference
  115811. * @returns the polygon mesh
  115812. */
  115813. static ExtrudePolygon(name: string, options: {
  115814. shape: Vector3[];
  115815. holes?: Vector3[][];
  115816. depth?: number;
  115817. faceUV?: Vector4[];
  115818. faceColors?: Color4[];
  115819. updatable?: boolean;
  115820. sideOrientation?: number;
  115821. frontUVs?: Vector4;
  115822. backUVs?: Vector4;
  115823. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115824. }
  115825. }
  115826. declare module BABYLON {
  115827. /**
  115828. * Class containing static functions to help procedurally build meshes
  115829. */
  115830. export class LatheBuilder {
  115831. /**
  115832. * Creates lathe mesh.
  115833. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  115834. * * 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
  115835. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  115836. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  115837. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  115838. * * 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
  115839. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  115840. * * 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
  115841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115842. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115843. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115844. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115845. * @param name defines the name of the mesh
  115846. * @param options defines the options used to create the mesh
  115847. * @param scene defines the hosting scene
  115848. * @returns the lathe mesh
  115849. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  115850. */
  115851. static CreateLathe(name: string, options: {
  115852. shape: Vector3[];
  115853. radius?: number;
  115854. tessellation?: number;
  115855. clip?: number;
  115856. arc?: number;
  115857. closed?: boolean;
  115858. updatable?: boolean;
  115859. sideOrientation?: number;
  115860. frontUVs?: Vector4;
  115861. backUVs?: Vector4;
  115862. cap?: number;
  115863. invertUV?: boolean;
  115864. }, scene?: Nullable<Scene>): Mesh;
  115865. }
  115866. }
  115867. declare module BABYLON {
  115868. /**
  115869. * Class containing static functions to help procedurally build meshes
  115870. */
  115871. export class TiledPlaneBuilder {
  115872. /**
  115873. * Creates a tiled plane mesh
  115874. * * The parameter `pattern` will, depending on value, do nothing or
  115875. * * * flip (reflect about central vertical) alternate tiles across and up
  115876. * * * flip every tile on alternate rows
  115877. * * * rotate (180 degs) alternate tiles across and up
  115878. * * * rotate every tile on alternate rows
  115879. * * * flip and rotate alternate tiles across and up
  115880. * * * flip and rotate every tile on alternate rows
  115881. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  115882. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  115883. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115884. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115885. * * 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)
  115886. * * 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)
  115887. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  115888. * @param name defines the name of the mesh
  115889. * @param options defines the options used to create the mesh
  115890. * @param scene defines the hosting scene
  115891. * @returns the box mesh
  115892. */
  115893. static CreateTiledPlane(name: string, options: {
  115894. pattern?: number;
  115895. tileSize?: number;
  115896. tileWidth?: number;
  115897. tileHeight?: number;
  115898. size?: number;
  115899. width?: number;
  115900. height?: number;
  115901. alignHorizontal?: number;
  115902. alignVertical?: number;
  115903. sideOrientation?: number;
  115904. frontUVs?: Vector4;
  115905. backUVs?: Vector4;
  115906. updatable?: boolean;
  115907. }, scene?: Nullable<Scene>): Mesh;
  115908. }
  115909. }
  115910. declare module BABYLON {
  115911. /**
  115912. * Class containing static functions to help procedurally build meshes
  115913. */
  115914. export class TubeBuilder {
  115915. /**
  115916. * Creates a tube mesh.
  115917. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  115918. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  115919. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  115920. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  115921. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  115922. * * 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)
  115923. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  115924. * * 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
  115925. * * 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
  115926. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115927. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115928. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115930. * @param name defines the name of the mesh
  115931. * @param options defines the options used to create the mesh
  115932. * @param scene defines the hosting scene
  115933. * @returns the tube mesh
  115934. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115935. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  115936. */
  115937. static CreateTube(name: string, options: {
  115938. path: Vector3[];
  115939. radius?: number;
  115940. tessellation?: number;
  115941. radiusFunction?: {
  115942. (i: number, distance: number): number;
  115943. };
  115944. cap?: number;
  115945. arc?: number;
  115946. updatable?: boolean;
  115947. sideOrientation?: number;
  115948. frontUVs?: Vector4;
  115949. backUVs?: Vector4;
  115950. instance?: Mesh;
  115951. invertUV?: boolean;
  115952. }, scene?: Nullable<Scene>): Mesh;
  115953. }
  115954. }
  115955. declare module BABYLON {
  115956. /**
  115957. * Class containing static functions to help procedurally build meshes
  115958. */
  115959. export class IcoSphereBuilder {
  115960. /**
  115961. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  115962. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  115963. * * 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`)
  115964. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  115965. * * 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
  115966. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115967. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115969. * @param name defines the name of the mesh
  115970. * @param options defines the options used to create the mesh
  115971. * @param scene defines the hosting scene
  115972. * @returns the icosahedron mesh
  115973. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  115974. */
  115975. static CreateIcoSphere(name: string, options: {
  115976. radius?: number;
  115977. radiusX?: number;
  115978. radiusY?: number;
  115979. radiusZ?: number;
  115980. flat?: boolean;
  115981. subdivisions?: number;
  115982. sideOrientation?: number;
  115983. frontUVs?: Vector4;
  115984. backUVs?: Vector4;
  115985. updatable?: boolean;
  115986. }, scene?: Nullable<Scene>): Mesh;
  115987. }
  115988. }
  115989. declare module BABYLON {
  115990. /**
  115991. * Class containing static functions to help procedurally build meshes
  115992. */
  115993. export class DecalBuilder {
  115994. /**
  115995. * Creates a decal mesh.
  115996. * 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
  115997. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  115998. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  115999. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  116000. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  116001. * @param name defines the name of the mesh
  116002. * @param sourceMesh defines the mesh where the decal must be applied
  116003. * @param options defines the options used to create the mesh
  116004. * @param scene defines the hosting scene
  116005. * @returns the decal mesh
  116006. * @see https://doc.babylonjs.com/how_to/decals
  116007. */
  116008. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  116009. position?: Vector3;
  116010. normal?: Vector3;
  116011. size?: Vector3;
  116012. angle?: number;
  116013. }): Mesh;
  116014. }
  116015. }
  116016. declare module BABYLON {
  116017. /**
  116018. * Class containing static functions to help procedurally build meshes
  116019. */
  116020. export class MeshBuilder {
  116021. /**
  116022. * Creates a box mesh
  116023. * * The parameter `size` sets the size (float) of each box side (default 1)
  116024. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  116025. * * 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)
  116026. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  116027. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116028. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116029. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116030. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  116031. * @param name defines the name of the mesh
  116032. * @param options defines the options used to create the mesh
  116033. * @param scene defines the hosting scene
  116034. * @returns the box mesh
  116035. */
  116036. static CreateBox(name: string, options: {
  116037. size?: number;
  116038. width?: number;
  116039. height?: number;
  116040. depth?: number;
  116041. faceUV?: Vector4[];
  116042. faceColors?: Color4[];
  116043. sideOrientation?: number;
  116044. frontUVs?: Vector4;
  116045. backUVs?: Vector4;
  116046. updatable?: boolean;
  116047. }, scene?: Nullable<Scene>): Mesh;
  116048. /**
  116049. * Creates a tiled box mesh
  116050. * * faceTiles sets the pattern, tile size and number of tiles for a face
  116051. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116052. * @param name defines the name of the mesh
  116053. * @param options defines the options used to create the mesh
  116054. * @param scene defines the hosting scene
  116055. * @returns the tiled box mesh
  116056. */
  116057. static CreateTiledBox(name: string, options: {
  116058. pattern?: number;
  116059. size?: number;
  116060. width?: number;
  116061. height?: number;
  116062. depth: number;
  116063. tileSize?: number;
  116064. tileWidth?: number;
  116065. tileHeight?: number;
  116066. faceUV?: Vector4[];
  116067. faceColors?: Color4[];
  116068. alignHorizontal?: number;
  116069. alignVertical?: number;
  116070. sideOrientation?: number;
  116071. updatable?: boolean;
  116072. }, scene?: Nullable<Scene>): Mesh;
  116073. /**
  116074. * Creates a sphere mesh
  116075. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  116076. * * 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`)
  116077. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  116078. * * 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
  116079. * * 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)
  116080. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116081. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116083. * @param name defines the name of the mesh
  116084. * @param options defines the options used to create the mesh
  116085. * @param scene defines the hosting scene
  116086. * @returns the sphere mesh
  116087. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  116088. */
  116089. static CreateSphere(name: string, options: {
  116090. segments?: number;
  116091. diameter?: number;
  116092. diameterX?: number;
  116093. diameterY?: number;
  116094. diameterZ?: number;
  116095. arc?: number;
  116096. slice?: number;
  116097. sideOrientation?: number;
  116098. frontUVs?: Vector4;
  116099. backUVs?: Vector4;
  116100. updatable?: boolean;
  116101. }, scene?: Nullable<Scene>): Mesh;
  116102. /**
  116103. * Creates a plane polygonal mesh. By default, this is a disc
  116104. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  116105. * * 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
  116106. * * 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
  116107. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116108. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116110. * @param name defines the name of the mesh
  116111. * @param options defines the options used to create the mesh
  116112. * @param scene defines the hosting scene
  116113. * @returns the plane polygonal mesh
  116114. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  116115. */
  116116. static CreateDisc(name: string, options: {
  116117. radius?: number;
  116118. tessellation?: number;
  116119. arc?: number;
  116120. updatable?: boolean;
  116121. sideOrientation?: number;
  116122. frontUVs?: Vector4;
  116123. backUVs?: Vector4;
  116124. }, scene?: Nullable<Scene>): Mesh;
  116125. /**
  116126. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  116127. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  116128. * * 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`)
  116129. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  116130. * * 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
  116131. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116132. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116134. * @param name defines the name of the mesh
  116135. * @param options defines the options used to create the mesh
  116136. * @param scene defines the hosting scene
  116137. * @returns the icosahedron mesh
  116138. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  116139. */
  116140. static CreateIcoSphere(name: string, options: {
  116141. radius?: number;
  116142. radiusX?: number;
  116143. radiusY?: number;
  116144. radiusZ?: number;
  116145. flat?: boolean;
  116146. subdivisions?: number;
  116147. sideOrientation?: number;
  116148. frontUVs?: Vector4;
  116149. backUVs?: Vector4;
  116150. updatable?: boolean;
  116151. }, scene?: Nullable<Scene>): Mesh;
  116152. /**
  116153. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  116154. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  116155. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  116156. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  116157. * * 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
  116158. * * 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
  116159. * * 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
  116160. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116161. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116162. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116163. * * 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
  116164. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  116165. * * 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
  116166. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  116167. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116168. * @param name defines the name of the mesh
  116169. * @param options defines the options used to create the mesh
  116170. * @param scene defines the hosting scene
  116171. * @returns the ribbon mesh
  116172. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  116173. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116174. */
  116175. static CreateRibbon(name: string, options: {
  116176. pathArray: Vector3[][];
  116177. closeArray?: boolean;
  116178. closePath?: boolean;
  116179. offset?: number;
  116180. updatable?: boolean;
  116181. sideOrientation?: number;
  116182. frontUVs?: Vector4;
  116183. backUVs?: Vector4;
  116184. instance?: Mesh;
  116185. invertUV?: boolean;
  116186. uvs?: Vector2[];
  116187. colors?: Color4[];
  116188. }, scene?: Nullable<Scene>): Mesh;
  116189. /**
  116190. * Creates a cylinder or a cone mesh
  116191. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  116192. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  116193. * * 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.
  116194. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  116195. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  116196. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  116197. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  116198. * * 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).
  116199. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  116200. * * 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).
  116201. * * 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
  116202. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  116203. * * 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
  116204. * * 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.
  116205. * * If `enclose` is false, a ring surface is one element.
  116206. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  116207. * * 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
  116208. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116209. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116211. * @param name defines the name of the mesh
  116212. * @param options defines the options used to create the mesh
  116213. * @param scene defines the hosting scene
  116214. * @returns the cylinder mesh
  116215. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  116216. */
  116217. static CreateCylinder(name: string, options: {
  116218. height?: number;
  116219. diameterTop?: number;
  116220. diameterBottom?: number;
  116221. diameter?: number;
  116222. tessellation?: number;
  116223. subdivisions?: number;
  116224. arc?: number;
  116225. faceColors?: Color4[];
  116226. faceUV?: Vector4[];
  116227. updatable?: boolean;
  116228. hasRings?: boolean;
  116229. enclose?: boolean;
  116230. cap?: number;
  116231. sideOrientation?: number;
  116232. frontUVs?: Vector4;
  116233. backUVs?: Vector4;
  116234. }, scene?: Nullable<Scene>): Mesh;
  116235. /**
  116236. * Creates a torus mesh
  116237. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  116238. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  116239. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  116240. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116241. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116243. * @param name defines the name of the mesh
  116244. * @param options defines the options used to create the mesh
  116245. * @param scene defines the hosting scene
  116246. * @returns the torus mesh
  116247. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  116248. */
  116249. static CreateTorus(name: string, options: {
  116250. diameter?: number;
  116251. thickness?: number;
  116252. tessellation?: number;
  116253. updatable?: boolean;
  116254. sideOrientation?: number;
  116255. frontUVs?: Vector4;
  116256. backUVs?: Vector4;
  116257. }, scene?: Nullable<Scene>): Mesh;
  116258. /**
  116259. * Creates a torus knot mesh
  116260. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  116261. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  116262. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  116263. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  116264. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116265. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116267. * @param name defines the name of the mesh
  116268. * @param options defines the options used to create the mesh
  116269. * @param scene defines the hosting scene
  116270. * @returns the torus knot mesh
  116271. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  116272. */
  116273. static CreateTorusKnot(name: string, options: {
  116274. radius?: number;
  116275. tube?: number;
  116276. radialSegments?: number;
  116277. tubularSegments?: number;
  116278. p?: number;
  116279. q?: number;
  116280. updatable?: boolean;
  116281. sideOrientation?: number;
  116282. frontUVs?: Vector4;
  116283. backUVs?: Vector4;
  116284. }, scene?: Nullable<Scene>): Mesh;
  116285. /**
  116286. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  116287. * * 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
  116288. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  116289. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  116290. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  116291. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  116292. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  116293. * * 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
  116294. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  116295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116296. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  116297. * @param name defines the name of the new line system
  116298. * @param options defines the options used to create the line system
  116299. * @param scene defines the hosting scene
  116300. * @returns a new line system mesh
  116301. */
  116302. static CreateLineSystem(name: string, options: {
  116303. lines: Vector3[][];
  116304. updatable?: boolean;
  116305. instance?: Nullable<LinesMesh>;
  116306. colors?: Nullable<Color4[][]>;
  116307. useVertexAlpha?: boolean;
  116308. }, scene: Nullable<Scene>): LinesMesh;
  116309. /**
  116310. * Creates a line mesh
  116311. * 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
  116312. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116313. * * The parameter `points` is an array successive Vector3
  116314. * * 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
  116315. * * The optional parameter `colors` is an array of successive Color4, one per line point
  116316. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  116317. * * When updating an instance, remember that only point positions can change, not the number of points
  116318. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116319. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  116320. * @param name defines the name of the new line system
  116321. * @param options defines the options used to create the line system
  116322. * @param scene defines the hosting scene
  116323. * @returns a new line mesh
  116324. */
  116325. static CreateLines(name: string, options: {
  116326. points: Vector3[];
  116327. updatable?: boolean;
  116328. instance?: Nullable<LinesMesh>;
  116329. colors?: Color4[];
  116330. useVertexAlpha?: boolean;
  116331. }, scene?: Nullable<Scene>): LinesMesh;
  116332. /**
  116333. * Creates a dashed line mesh
  116334. * * 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
  116335. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116336. * * The parameter `points` is an array successive Vector3
  116337. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  116338. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  116339. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  116340. * * 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
  116341. * * When updating an instance, remember that only point positions can change, not the number of points
  116342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116343. * @param name defines the name of the mesh
  116344. * @param options defines the options used to create the mesh
  116345. * @param scene defines the hosting scene
  116346. * @returns the dashed line mesh
  116347. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  116348. */
  116349. static CreateDashedLines(name: string, options: {
  116350. points: Vector3[];
  116351. dashSize?: number;
  116352. gapSize?: number;
  116353. dashNb?: number;
  116354. updatable?: boolean;
  116355. instance?: LinesMesh;
  116356. }, scene?: Nullable<Scene>): LinesMesh;
  116357. /**
  116358. * 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.
  116359. * * 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.
  116360. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116361. * * 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.
  116362. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  116363. * * 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
  116364. * * 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
  116365. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  116366. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116367. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116368. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  116369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116370. * @param name defines the name of the mesh
  116371. * @param options defines the options used to create the mesh
  116372. * @param scene defines the hosting scene
  116373. * @returns the extruded shape mesh
  116374. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116375. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116376. */
  116377. static ExtrudeShape(name: string, options: {
  116378. shape: Vector3[];
  116379. path: Vector3[];
  116380. scale?: number;
  116381. rotation?: number;
  116382. cap?: number;
  116383. updatable?: boolean;
  116384. sideOrientation?: number;
  116385. frontUVs?: Vector4;
  116386. backUVs?: Vector4;
  116387. instance?: Mesh;
  116388. invertUV?: boolean;
  116389. }, scene?: Nullable<Scene>): Mesh;
  116390. /**
  116391. * Creates an custom extruded shape mesh.
  116392. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  116393. * * 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.
  116394. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116395. * * 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
  116396. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  116397. * * 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
  116398. * * It must returns a float value that will be the scale value applied to the shape on each path point
  116399. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  116400. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  116401. * * 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
  116402. * * 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
  116403. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  116404. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116405. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116406. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116408. * @param name defines the name of the mesh
  116409. * @param options defines the options used to create the mesh
  116410. * @param scene defines the hosting scene
  116411. * @returns the custom extruded shape mesh
  116412. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  116413. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116414. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116415. */
  116416. static ExtrudeShapeCustom(name: string, options: {
  116417. shape: Vector3[];
  116418. path: Vector3[];
  116419. scaleFunction?: any;
  116420. rotationFunction?: any;
  116421. ribbonCloseArray?: boolean;
  116422. ribbonClosePath?: boolean;
  116423. cap?: number;
  116424. updatable?: boolean;
  116425. sideOrientation?: number;
  116426. frontUVs?: Vector4;
  116427. backUVs?: Vector4;
  116428. instance?: Mesh;
  116429. invertUV?: boolean;
  116430. }, scene?: Nullable<Scene>): Mesh;
  116431. /**
  116432. * Creates lathe mesh.
  116433. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  116434. * * 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
  116435. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  116436. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  116437. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  116438. * * 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
  116439. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  116440. * * 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
  116441. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116442. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116443. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116445. * @param name defines the name of the mesh
  116446. * @param options defines the options used to create the mesh
  116447. * @param scene defines the hosting scene
  116448. * @returns the lathe mesh
  116449. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  116450. */
  116451. static CreateLathe(name: string, options: {
  116452. shape: Vector3[];
  116453. radius?: number;
  116454. tessellation?: number;
  116455. clip?: number;
  116456. arc?: number;
  116457. closed?: boolean;
  116458. updatable?: boolean;
  116459. sideOrientation?: number;
  116460. frontUVs?: Vector4;
  116461. backUVs?: Vector4;
  116462. cap?: number;
  116463. invertUV?: boolean;
  116464. }, scene?: Nullable<Scene>): Mesh;
  116465. /**
  116466. * Creates a tiled plane mesh
  116467. * * You can set a limited pattern arrangement with the tiles
  116468. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116469. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116471. * @param name defines the name of the mesh
  116472. * @param options defines the options used to create the mesh
  116473. * @param scene defines the hosting scene
  116474. * @returns the plane mesh
  116475. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  116476. */
  116477. static CreateTiledPlane(name: string, options: {
  116478. pattern?: number;
  116479. tileSize?: number;
  116480. tileWidth?: number;
  116481. tileHeight?: number;
  116482. size?: number;
  116483. width?: number;
  116484. height?: number;
  116485. alignHorizontal?: number;
  116486. alignVertical?: number;
  116487. sideOrientation?: number;
  116488. frontUVs?: Vector4;
  116489. backUVs?: Vector4;
  116490. updatable?: boolean;
  116491. }, scene?: Nullable<Scene>): Mesh;
  116492. /**
  116493. * Creates a plane mesh
  116494. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  116495. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  116496. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  116497. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116498. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116500. * @param name defines the name of the mesh
  116501. * @param options defines the options used to create the mesh
  116502. * @param scene defines the hosting scene
  116503. * @returns the plane mesh
  116504. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  116505. */
  116506. static CreatePlane(name: string, options: {
  116507. size?: number;
  116508. width?: number;
  116509. height?: number;
  116510. sideOrientation?: number;
  116511. frontUVs?: Vector4;
  116512. backUVs?: Vector4;
  116513. updatable?: boolean;
  116514. sourcePlane?: Plane;
  116515. }, scene?: Nullable<Scene>): Mesh;
  116516. /**
  116517. * Creates a ground mesh
  116518. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  116519. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  116520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116521. * @param name defines the name of the mesh
  116522. * @param options defines the options used to create the mesh
  116523. * @param scene defines the hosting scene
  116524. * @returns the ground mesh
  116525. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  116526. */
  116527. static CreateGround(name: string, options: {
  116528. width?: number;
  116529. height?: number;
  116530. subdivisions?: number;
  116531. subdivisionsX?: number;
  116532. subdivisionsY?: number;
  116533. updatable?: boolean;
  116534. }, scene?: Nullable<Scene>): Mesh;
  116535. /**
  116536. * Creates a tiled ground mesh
  116537. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  116538. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  116539. * * 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
  116540. * * 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
  116541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116542. * @param name defines the name of the mesh
  116543. * @param options defines the options used to create the mesh
  116544. * @param scene defines the hosting scene
  116545. * @returns the tiled ground mesh
  116546. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  116547. */
  116548. static CreateTiledGround(name: string, options: {
  116549. xmin: number;
  116550. zmin: number;
  116551. xmax: number;
  116552. zmax: number;
  116553. subdivisions?: {
  116554. w: number;
  116555. h: number;
  116556. };
  116557. precision?: {
  116558. w: number;
  116559. h: number;
  116560. };
  116561. updatable?: boolean;
  116562. }, scene?: Nullable<Scene>): Mesh;
  116563. /**
  116564. * Creates a ground mesh from a height map
  116565. * * The parameter `url` sets the URL of the height map image resource.
  116566. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  116567. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  116568. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  116569. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  116570. * * 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.
  116571. * * 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).
  116572. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  116573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116574. * @param name defines the name of the mesh
  116575. * @param url defines the url to the height map
  116576. * @param options defines the options used to create the mesh
  116577. * @param scene defines the hosting scene
  116578. * @returns the ground mesh
  116579. * @see https://doc.babylonjs.com/babylon101/height_map
  116580. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  116581. */
  116582. static CreateGroundFromHeightMap(name: string, url: string, options: {
  116583. width?: number;
  116584. height?: number;
  116585. subdivisions?: number;
  116586. minHeight?: number;
  116587. maxHeight?: number;
  116588. colorFilter?: Color3;
  116589. alphaFilter?: number;
  116590. updatable?: boolean;
  116591. onReady?: (mesh: GroundMesh) => void;
  116592. }, scene?: Nullable<Scene>): GroundMesh;
  116593. /**
  116594. * Creates a polygon mesh
  116595. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  116596. * * 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
  116597. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  116598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116599. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  116600. * * Remember you can only change the shape positions, not their number when updating a polygon
  116601. * @param name defines the name of the mesh
  116602. * @param options defines the options used to create the mesh
  116603. * @param scene defines the hosting scene
  116604. * @param earcutInjection can be used to inject your own earcut reference
  116605. * @returns the polygon mesh
  116606. */
  116607. static CreatePolygon(name: string, options: {
  116608. shape: Vector3[];
  116609. holes?: Vector3[][];
  116610. depth?: number;
  116611. faceUV?: Vector4[];
  116612. faceColors?: Color4[];
  116613. updatable?: boolean;
  116614. sideOrientation?: number;
  116615. frontUVs?: Vector4;
  116616. backUVs?: Vector4;
  116617. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  116618. /**
  116619. * Creates an extruded polygon mesh, with depth in the Y direction.
  116620. * * 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)
  116621. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  116622. * @param name defines the name of the mesh
  116623. * @param options defines the options used to create the mesh
  116624. * @param scene defines the hosting scene
  116625. * @param earcutInjection can be used to inject your own earcut reference
  116626. * @returns the polygon mesh
  116627. */
  116628. static ExtrudePolygon(name: string, options: {
  116629. shape: Vector3[];
  116630. holes?: Vector3[][];
  116631. depth?: number;
  116632. faceUV?: Vector4[];
  116633. faceColors?: Color4[];
  116634. updatable?: boolean;
  116635. sideOrientation?: number;
  116636. frontUVs?: Vector4;
  116637. backUVs?: Vector4;
  116638. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  116639. /**
  116640. * Creates a tube mesh.
  116641. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  116642. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  116643. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  116644. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  116645. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  116646. * * 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)
  116647. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  116648. * * 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
  116649. * * 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
  116650. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116651. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116652. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116653. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116654. * @param name defines the name of the mesh
  116655. * @param options defines the options used to create the mesh
  116656. * @param scene defines the hosting scene
  116657. * @returns the tube mesh
  116658. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116659. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  116660. */
  116661. static CreateTube(name: string, options: {
  116662. path: Vector3[];
  116663. radius?: number;
  116664. tessellation?: number;
  116665. radiusFunction?: {
  116666. (i: number, distance: number): number;
  116667. };
  116668. cap?: number;
  116669. arc?: number;
  116670. updatable?: boolean;
  116671. sideOrientation?: number;
  116672. frontUVs?: Vector4;
  116673. backUVs?: Vector4;
  116674. instance?: Mesh;
  116675. invertUV?: boolean;
  116676. }, scene?: Nullable<Scene>): Mesh;
  116677. /**
  116678. * Creates a polyhedron mesh
  116679. * * 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
  116680. * * The parameter `size` (positive float, default 1) sets the polygon size
  116681. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  116682. * * 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`
  116683. * * 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
  116684. * * 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)`)
  116685. * * 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
  116686. * * 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
  116687. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116688. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116690. * @param name defines the name of the mesh
  116691. * @param options defines the options used to create the mesh
  116692. * @param scene defines the hosting scene
  116693. * @returns the polyhedron mesh
  116694. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  116695. */
  116696. static CreatePolyhedron(name: string, options: {
  116697. type?: number;
  116698. size?: number;
  116699. sizeX?: number;
  116700. sizeY?: number;
  116701. sizeZ?: number;
  116702. custom?: any;
  116703. faceUV?: Vector4[];
  116704. faceColors?: Color4[];
  116705. flat?: boolean;
  116706. updatable?: boolean;
  116707. sideOrientation?: number;
  116708. frontUVs?: Vector4;
  116709. backUVs?: Vector4;
  116710. }, scene?: Nullable<Scene>): Mesh;
  116711. /**
  116712. * Creates a decal mesh.
  116713. * 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
  116714. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  116715. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  116716. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  116717. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  116718. * @param name defines the name of the mesh
  116719. * @param sourceMesh defines the mesh where the decal must be applied
  116720. * @param options defines the options used to create the mesh
  116721. * @param scene defines the hosting scene
  116722. * @returns the decal mesh
  116723. * @see https://doc.babylonjs.com/how_to/decals
  116724. */
  116725. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  116726. position?: Vector3;
  116727. normal?: Vector3;
  116728. size?: Vector3;
  116729. angle?: number;
  116730. }): Mesh;
  116731. }
  116732. }
  116733. declare module BABYLON {
  116734. /**
  116735. * A simplifier interface for future simplification implementations
  116736. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116737. */
  116738. export interface ISimplifier {
  116739. /**
  116740. * Simplification of a given mesh according to the given settings.
  116741. * Since this requires computation, it is assumed that the function runs async.
  116742. * @param settings The settings of the simplification, including quality and distance
  116743. * @param successCallback A callback that will be called after the mesh was simplified.
  116744. * @param errorCallback in case of an error, this callback will be called. optional.
  116745. */
  116746. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  116747. }
  116748. /**
  116749. * Expected simplification settings.
  116750. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  116751. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116752. */
  116753. export interface ISimplificationSettings {
  116754. /**
  116755. * Gets or sets the expected quality
  116756. */
  116757. quality: number;
  116758. /**
  116759. * Gets or sets the distance when this optimized version should be used
  116760. */
  116761. distance: number;
  116762. /**
  116763. * Gets an already optimized mesh
  116764. */
  116765. optimizeMesh?: boolean;
  116766. }
  116767. /**
  116768. * Class used to specify simplification options
  116769. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116770. */
  116771. export class SimplificationSettings implements ISimplificationSettings {
  116772. /** expected quality */
  116773. quality: number;
  116774. /** distance when this optimized version should be used */
  116775. distance: number;
  116776. /** already optimized mesh */
  116777. optimizeMesh?: boolean | undefined;
  116778. /**
  116779. * Creates a SimplificationSettings
  116780. * @param quality expected quality
  116781. * @param distance distance when this optimized version should be used
  116782. * @param optimizeMesh already optimized mesh
  116783. */
  116784. constructor(
  116785. /** expected quality */
  116786. quality: number,
  116787. /** distance when this optimized version should be used */
  116788. distance: number,
  116789. /** already optimized mesh */
  116790. optimizeMesh?: boolean | undefined);
  116791. }
  116792. /**
  116793. * Interface used to define a simplification task
  116794. */
  116795. export interface ISimplificationTask {
  116796. /**
  116797. * Array of settings
  116798. */
  116799. settings: Array<ISimplificationSettings>;
  116800. /**
  116801. * Simplification type
  116802. */
  116803. simplificationType: SimplificationType;
  116804. /**
  116805. * Mesh to simplify
  116806. */
  116807. mesh: Mesh;
  116808. /**
  116809. * Callback called on success
  116810. */
  116811. successCallback?: () => void;
  116812. /**
  116813. * Defines if parallel processing can be used
  116814. */
  116815. parallelProcessing: boolean;
  116816. }
  116817. /**
  116818. * Queue used to order the simplification tasks
  116819. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116820. */
  116821. export class SimplificationQueue {
  116822. private _simplificationArray;
  116823. /**
  116824. * Gets a boolean indicating that the process is still running
  116825. */
  116826. running: boolean;
  116827. /**
  116828. * Creates a new queue
  116829. */
  116830. constructor();
  116831. /**
  116832. * Adds a new simplification task
  116833. * @param task defines a task to add
  116834. */
  116835. addTask(task: ISimplificationTask): void;
  116836. /**
  116837. * Execute next task
  116838. */
  116839. executeNext(): void;
  116840. /**
  116841. * Execute a simplification task
  116842. * @param task defines the task to run
  116843. */
  116844. runSimplification(task: ISimplificationTask): void;
  116845. private getSimplifier;
  116846. }
  116847. /**
  116848. * The implemented types of simplification
  116849. * At the moment only Quadratic Error Decimation is implemented
  116850. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116851. */
  116852. export enum SimplificationType {
  116853. /** Quadratic error decimation */
  116854. QUADRATIC = 0
  116855. }
  116856. }
  116857. declare module BABYLON {
  116858. interface Scene {
  116859. /** @hidden (Backing field) */
  116860. _simplificationQueue: SimplificationQueue;
  116861. /**
  116862. * Gets or sets the simplification queue attached to the scene
  116863. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116864. */
  116865. simplificationQueue: SimplificationQueue;
  116866. }
  116867. interface Mesh {
  116868. /**
  116869. * Simplify the mesh according to the given array of settings.
  116870. * Function will return immediately and will simplify async
  116871. * @param settings a collection of simplification settings
  116872. * @param parallelProcessing should all levels calculate parallel or one after the other
  116873. * @param simplificationType the type of simplification to run
  116874. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  116875. * @returns the current mesh
  116876. */
  116877. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  116878. }
  116879. /**
  116880. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  116881. * created in a scene
  116882. */
  116883. export class SimplicationQueueSceneComponent implements ISceneComponent {
  116884. /**
  116885. * The component name helpfull to identify the component in the list of scene components.
  116886. */
  116887. readonly name: string;
  116888. /**
  116889. * The scene the component belongs to.
  116890. */
  116891. scene: Scene;
  116892. /**
  116893. * Creates a new instance of the component for the given scene
  116894. * @param scene Defines the scene to register the component in
  116895. */
  116896. constructor(scene: Scene);
  116897. /**
  116898. * Registers the component in a given scene
  116899. */
  116900. register(): void;
  116901. /**
  116902. * Rebuilds the elements related to this component in case of
  116903. * context lost for instance.
  116904. */
  116905. rebuild(): void;
  116906. /**
  116907. * Disposes the component and the associated ressources
  116908. */
  116909. dispose(): void;
  116910. private _beforeCameraUpdate;
  116911. }
  116912. }
  116913. declare module BABYLON {
  116914. /**
  116915. * Class used to enable access to IndexedDB
  116916. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  116917. */
  116918. export class Database implements IOfflineProvider {
  116919. private _callbackManifestChecked;
  116920. private _currentSceneUrl;
  116921. private _db;
  116922. private _enableSceneOffline;
  116923. private _enableTexturesOffline;
  116924. private _manifestVersionFound;
  116925. private _mustUpdateRessources;
  116926. private _hasReachedQuota;
  116927. private _isSupported;
  116928. private _idbFactory;
  116929. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  116930. private static IsUASupportingBlobStorage;
  116931. /**
  116932. * Gets a boolean indicating if Database storate is enabled (off by default)
  116933. */
  116934. static IDBStorageEnabled: boolean;
  116935. /**
  116936. * Gets a boolean indicating if scene must be saved in the database
  116937. */
  116938. readonly enableSceneOffline: boolean;
  116939. /**
  116940. * Gets a boolean indicating if textures must be saved in the database
  116941. */
  116942. readonly enableTexturesOffline: boolean;
  116943. /**
  116944. * Creates a new Database
  116945. * @param urlToScene defines the url to load the scene
  116946. * @param callbackManifestChecked defines the callback to use when manifest is checked
  116947. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  116948. */
  116949. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  116950. private static _ParseURL;
  116951. private static _ReturnFullUrlLocation;
  116952. private _checkManifestFile;
  116953. /**
  116954. * Open the database and make it available
  116955. * @param successCallback defines the callback to call on success
  116956. * @param errorCallback defines the callback to call on error
  116957. */
  116958. open(successCallback: () => void, errorCallback: () => void): void;
  116959. /**
  116960. * Loads an image from the database
  116961. * @param url defines the url to load from
  116962. * @param image defines the target DOM image
  116963. */
  116964. loadImage(url: string, image: HTMLImageElement): void;
  116965. private _loadImageFromDBAsync;
  116966. private _saveImageIntoDBAsync;
  116967. private _checkVersionFromDB;
  116968. private _loadVersionFromDBAsync;
  116969. private _saveVersionIntoDBAsync;
  116970. /**
  116971. * Loads a file from database
  116972. * @param url defines the URL to load from
  116973. * @param sceneLoaded defines a callback to call on success
  116974. * @param progressCallBack defines a callback to call when progress changed
  116975. * @param errorCallback defines a callback to call on error
  116976. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  116977. */
  116978. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  116979. private _loadFileAsync;
  116980. private _saveFileAsync;
  116981. /**
  116982. * Validates if xhr data is correct
  116983. * @param xhr defines the request to validate
  116984. * @param dataType defines the expected data type
  116985. * @returns true if data is correct
  116986. */
  116987. private static _ValidateXHRData;
  116988. }
  116989. }
  116990. declare module BABYLON {
  116991. /** @hidden */
  116992. export var gpuUpdateParticlesPixelShader: {
  116993. name: string;
  116994. shader: string;
  116995. };
  116996. }
  116997. declare module BABYLON {
  116998. /** @hidden */
  116999. export var gpuUpdateParticlesVertexShader: {
  117000. name: string;
  117001. shader: string;
  117002. };
  117003. }
  117004. declare module BABYLON {
  117005. /** @hidden */
  117006. export var clipPlaneFragmentDeclaration2: {
  117007. name: string;
  117008. shader: string;
  117009. };
  117010. }
  117011. declare module BABYLON {
  117012. /** @hidden */
  117013. export var gpuRenderParticlesPixelShader: {
  117014. name: string;
  117015. shader: string;
  117016. };
  117017. }
  117018. declare module BABYLON {
  117019. /** @hidden */
  117020. export var clipPlaneVertexDeclaration2: {
  117021. name: string;
  117022. shader: string;
  117023. };
  117024. }
  117025. declare module BABYLON {
  117026. /** @hidden */
  117027. export var gpuRenderParticlesVertexShader: {
  117028. name: string;
  117029. shader: string;
  117030. };
  117031. }
  117032. declare module BABYLON {
  117033. /**
  117034. * This represents a GPU particle system in Babylon
  117035. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  117036. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  117037. */
  117038. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  117039. /**
  117040. * The layer mask we are rendering the particles through.
  117041. */
  117042. layerMask: number;
  117043. private _capacity;
  117044. private _activeCount;
  117045. private _currentActiveCount;
  117046. private _accumulatedCount;
  117047. private _renderEffect;
  117048. private _updateEffect;
  117049. private _buffer0;
  117050. private _buffer1;
  117051. private _spriteBuffer;
  117052. private _updateVAO;
  117053. private _renderVAO;
  117054. private _targetIndex;
  117055. private _sourceBuffer;
  117056. private _targetBuffer;
  117057. private _engine;
  117058. private _currentRenderId;
  117059. private _started;
  117060. private _stopped;
  117061. private _timeDelta;
  117062. private _randomTexture;
  117063. private _randomTexture2;
  117064. private _attributesStrideSize;
  117065. private _updateEffectOptions;
  117066. private _randomTextureSize;
  117067. private _actualFrame;
  117068. private readonly _rawTextureWidth;
  117069. /**
  117070. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  117071. */
  117072. static readonly IsSupported: boolean;
  117073. /**
  117074. * An event triggered when the system is disposed.
  117075. */
  117076. onDisposeObservable: Observable<GPUParticleSystem>;
  117077. /**
  117078. * Gets the maximum number of particles active at the same time.
  117079. * @returns The max number of active particles.
  117080. */
  117081. getCapacity(): number;
  117082. /**
  117083. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  117084. * to override the particles.
  117085. */
  117086. forceDepthWrite: boolean;
  117087. /**
  117088. * Gets or set the number of active particles
  117089. */
  117090. activeParticleCount: number;
  117091. private _preWarmDone;
  117092. /**
  117093. * Is this system ready to be used/rendered
  117094. * @return true if the system is ready
  117095. */
  117096. isReady(): boolean;
  117097. /**
  117098. * Gets if the system has been started. (Note: this will still be true after stop is called)
  117099. * @returns True if it has been started, otherwise false.
  117100. */
  117101. isStarted(): boolean;
  117102. /**
  117103. * Starts the particle system and begins to emit
  117104. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  117105. */
  117106. start(delay?: number): void;
  117107. /**
  117108. * Stops the particle system.
  117109. */
  117110. stop(): void;
  117111. /**
  117112. * Remove all active particles
  117113. */
  117114. reset(): void;
  117115. /**
  117116. * Returns the string "GPUParticleSystem"
  117117. * @returns a string containing the class name
  117118. */
  117119. getClassName(): string;
  117120. private _colorGradientsTexture;
  117121. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  117122. /**
  117123. * Adds a new color gradient
  117124. * @param gradient defines the gradient to use (between 0 and 1)
  117125. * @param color1 defines the color to affect to the specified gradient
  117126. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  117127. * @returns the current particle system
  117128. */
  117129. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  117130. /**
  117131. * Remove a specific color gradient
  117132. * @param gradient defines the gradient to remove
  117133. * @returns the current particle system
  117134. */
  117135. removeColorGradient(gradient: number): GPUParticleSystem;
  117136. private _angularSpeedGradientsTexture;
  117137. private _sizeGradientsTexture;
  117138. private _velocityGradientsTexture;
  117139. private _limitVelocityGradientsTexture;
  117140. private _dragGradientsTexture;
  117141. private _addFactorGradient;
  117142. /**
  117143. * Adds a new size gradient
  117144. * @param gradient defines the gradient to use (between 0 and 1)
  117145. * @param factor defines the size factor to affect to the specified gradient
  117146. * @returns the current particle system
  117147. */
  117148. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  117149. /**
  117150. * Remove a specific size gradient
  117151. * @param gradient defines the gradient to remove
  117152. * @returns the current particle system
  117153. */
  117154. removeSizeGradient(gradient: number): GPUParticleSystem;
  117155. /**
  117156. * Adds a new angular speed gradient
  117157. * @param gradient defines the gradient to use (between 0 and 1)
  117158. * @param factor defines the angular speed to affect to the specified gradient
  117159. * @returns the current particle system
  117160. */
  117161. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  117162. /**
  117163. * Remove a specific angular speed gradient
  117164. * @param gradient defines the gradient to remove
  117165. * @returns the current particle system
  117166. */
  117167. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  117168. /**
  117169. * Adds a new velocity gradient
  117170. * @param gradient defines the gradient to use (between 0 and 1)
  117171. * @param factor defines the velocity to affect to the specified gradient
  117172. * @returns the current particle system
  117173. */
  117174. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  117175. /**
  117176. * Remove a specific velocity gradient
  117177. * @param gradient defines the gradient to remove
  117178. * @returns the current particle system
  117179. */
  117180. removeVelocityGradient(gradient: number): GPUParticleSystem;
  117181. /**
  117182. * Adds a new limit velocity gradient
  117183. * @param gradient defines the gradient to use (between 0 and 1)
  117184. * @param factor defines the limit velocity value to affect to the specified gradient
  117185. * @returns the current particle system
  117186. */
  117187. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  117188. /**
  117189. * Remove a specific limit velocity gradient
  117190. * @param gradient defines the gradient to remove
  117191. * @returns the current particle system
  117192. */
  117193. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  117194. /**
  117195. * Adds a new drag gradient
  117196. * @param gradient defines the gradient to use (between 0 and 1)
  117197. * @param factor defines the drag value to affect to the specified gradient
  117198. * @returns the current particle system
  117199. */
  117200. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  117201. /**
  117202. * Remove a specific drag gradient
  117203. * @param gradient defines the gradient to remove
  117204. * @returns the current particle system
  117205. */
  117206. removeDragGradient(gradient: number): GPUParticleSystem;
  117207. /**
  117208. * Not supported by GPUParticleSystem
  117209. * @param gradient defines the gradient to use (between 0 and 1)
  117210. * @param factor defines the emit rate value to affect to the specified gradient
  117211. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  117212. * @returns the current particle system
  117213. */
  117214. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  117215. /**
  117216. * Not supported by GPUParticleSystem
  117217. * @param gradient defines the gradient to remove
  117218. * @returns the current particle system
  117219. */
  117220. removeEmitRateGradient(gradient: number): IParticleSystem;
  117221. /**
  117222. * Not supported by GPUParticleSystem
  117223. * @param gradient defines the gradient to use (between 0 and 1)
  117224. * @param factor defines the start size value to affect to the specified gradient
  117225. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  117226. * @returns the current particle system
  117227. */
  117228. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  117229. /**
  117230. * Not supported by GPUParticleSystem
  117231. * @param gradient defines the gradient to remove
  117232. * @returns the current particle system
  117233. */
  117234. removeStartSizeGradient(gradient: number): IParticleSystem;
  117235. /**
  117236. * Not supported by GPUParticleSystem
  117237. * @param gradient defines the gradient to use (between 0 and 1)
  117238. * @param min defines the color remap minimal range
  117239. * @param max defines the color remap maximal range
  117240. * @returns the current particle system
  117241. */
  117242. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  117243. /**
  117244. * Not supported by GPUParticleSystem
  117245. * @param gradient defines the gradient to remove
  117246. * @returns the current particle system
  117247. */
  117248. removeColorRemapGradient(): IParticleSystem;
  117249. /**
  117250. * Not supported by GPUParticleSystem
  117251. * @param gradient defines the gradient to use (between 0 and 1)
  117252. * @param min defines the alpha remap minimal range
  117253. * @param max defines the alpha remap maximal range
  117254. * @returns the current particle system
  117255. */
  117256. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  117257. /**
  117258. * Not supported by GPUParticleSystem
  117259. * @param gradient defines the gradient to remove
  117260. * @returns the current particle system
  117261. */
  117262. removeAlphaRemapGradient(): IParticleSystem;
  117263. /**
  117264. * Not supported by GPUParticleSystem
  117265. * @param gradient defines the gradient to use (between 0 and 1)
  117266. * @param color defines the color to affect to the specified gradient
  117267. * @returns the current particle system
  117268. */
  117269. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  117270. /**
  117271. * Not supported by GPUParticleSystem
  117272. * @param gradient defines the gradient to remove
  117273. * @returns the current particle system
  117274. */
  117275. removeRampGradient(): IParticleSystem;
  117276. /**
  117277. * Not supported by GPUParticleSystem
  117278. * @returns the list of ramp gradients
  117279. */
  117280. getRampGradients(): Nullable<Array<Color3Gradient>>;
  117281. /**
  117282. * Not supported by GPUParticleSystem
  117283. * Gets or sets a boolean indicating that ramp gradients must be used
  117284. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  117285. */
  117286. useRampGradients: boolean;
  117287. /**
  117288. * Not supported by GPUParticleSystem
  117289. * @param gradient defines the gradient to use (between 0 and 1)
  117290. * @param factor defines the life time factor to affect to the specified gradient
  117291. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  117292. * @returns the current particle system
  117293. */
  117294. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  117295. /**
  117296. * Not supported by GPUParticleSystem
  117297. * @param gradient defines the gradient to remove
  117298. * @returns the current particle system
  117299. */
  117300. removeLifeTimeGradient(gradient: number): IParticleSystem;
  117301. /**
  117302. * Instantiates a GPU particle system.
  117303. * 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.
  117304. * @param name The name of the particle system
  117305. * @param options The options used to create the system
  117306. * @param scene The scene the particle system belongs to
  117307. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  117308. */
  117309. constructor(name: string, options: Partial<{
  117310. capacity: number;
  117311. randomTextureSize: number;
  117312. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  117313. protected _reset(): void;
  117314. private _createUpdateVAO;
  117315. private _createRenderVAO;
  117316. private _initialize;
  117317. /** @hidden */
  117318. _recreateUpdateEffect(): void;
  117319. /** @hidden */
  117320. _recreateRenderEffect(): void;
  117321. /**
  117322. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  117323. * @param preWarm defines if we are in the pre-warmimg phase
  117324. */
  117325. animate(preWarm?: boolean): void;
  117326. private _createFactorGradientTexture;
  117327. private _createSizeGradientTexture;
  117328. private _createAngularSpeedGradientTexture;
  117329. private _createVelocityGradientTexture;
  117330. private _createLimitVelocityGradientTexture;
  117331. private _createDragGradientTexture;
  117332. private _createColorGradientTexture;
  117333. /**
  117334. * Renders the particle system in its current state
  117335. * @param preWarm defines if the system should only update the particles but not render them
  117336. * @returns the current number of particles
  117337. */
  117338. render(preWarm?: boolean): number;
  117339. /**
  117340. * Rebuilds the particle system
  117341. */
  117342. rebuild(): void;
  117343. private _releaseBuffers;
  117344. private _releaseVAOs;
  117345. /**
  117346. * Disposes the particle system and free the associated resources
  117347. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  117348. */
  117349. dispose(disposeTexture?: boolean): void;
  117350. /**
  117351. * Clones the particle system.
  117352. * @param name The name of the cloned object
  117353. * @param newEmitter The new emitter to use
  117354. * @returns the cloned particle system
  117355. */
  117356. clone(name: string, newEmitter: any): GPUParticleSystem;
  117357. /**
  117358. * Serializes the particle system to a JSON object.
  117359. * @returns the JSON object
  117360. */
  117361. serialize(): any;
  117362. /**
  117363. * Parses a JSON object to create a GPU particle system.
  117364. * @param parsedParticleSystem The JSON object to parse
  117365. * @param scene The scene to create the particle system in
  117366. * @param rootUrl The root url to use to load external dependencies like texture
  117367. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  117368. * @returns the parsed GPU particle system
  117369. */
  117370. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  117371. }
  117372. }
  117373. declare module BABYLON {
  117374. /**
  117375. * Represents a set of particle systems working together to create a specific effect
  117376. */
  117377. export class ParticleSystemSet implements IDisposable {
  117378. private _emitterCreationOptions;
  117379. private _emitterNode;
  117380. /**
  117381. * Gets the particle system list
  117382. */
  117383. systems: IParticleSystem[];
  117384. /**
  117385. * Gets the emitter node used with this set
  117386. */
  117387. readonly emitterNode: Nullable<TransformNode>;
  117388. /**
  117389. * Creates a new emitter mesh as a sphere
  117390. * @param options defines the options used to create the sphere
  117391. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  117392. * @param scene defines the hosting scene
  117393. */
  117394. setEmitterAsSphere(options: {
  117395. diameter: number;
  117396. segments: number;
  117397. color: Color3;
  117398. }, renderingGroupId: number, scene: Scene): void;
  117399. /**
  117400. * Starts all particle systems of the set
  117401. * @param emitter defines an optional mesh to use as emitter for the particle systems
  117402. */
  117403. start(emitter?: AbstractMesh): void;
  117404. /**
  117405. * Release all associated resources
  117406. */
  117407. dispose(): void;
  117408. /**
  117409. * Serialize the set into a JSON compatible object
  117410. * @returns a JSON compatible representation of the set
  117411. */
  117412. serialize(): any;
  117413. /**
  117414. * Parse a new ParticleSystemSet from a serialized source
  117415. * @param data defines a JSON compatible representation of the set
  117416. * @param scene defines the hosting scene
  117417. * @param gpu defines if we want GPU particles or CPU particles
  117418. * @returns a new ParticleSystemSet
  117419. */
  117420. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  117421. }
  117422. }
  117423. declare module BABYLON {
  117424. /**
  117425. * This class is made for on one-liner static method to help creating particle system set.
  117426. */
  117427. export class ParticleHelper {
  117428. /**
  117429. * Gets or sets base Assets URL
  117430. */
  117431. static BaseAssetsUrl: string;
  117432. /**
  117433. * Create a default particle system that you can tweak
  117434. * @param emitter defines the emitter to use
  117435. * @param capacity defines the system capacity (default is 500 particles)
  117436. * @param scene defines the hosting scene
  117437. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  117438. * @returns the new Particle system
  117439. */
  117440. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  117441. /**
  117442. * This is the main static method (one-liner) of this helper to create different particle systems
  117443. * @param type This string represents the type to the particle system to create
  117444. * @param scene The scene where the particle system should live
  117445. * @param gpu If the system will use gpu
  117446. * @returns the ParticleSystemSet created
  117447. */
  117448. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  117449. /**
  117450. * Static function used to export a particle system to a ParticleSystemSet variable.
  117451. * Please note that the emitter shape is not exported
  117452. * @param systems defines the particle systems to export
  117453. * @returns the created particle system set
  117454. */
  117455. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  117456. }
  117457. }
  117458. declare module BABYLON {
  117459. interface Engine {
  117460. /**
  117461. * Create an effect to use with particle systems.
  117462. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  117463. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  117464. * @param uniformsNames defines a list of attribute names
  117465. * @param samplers defines an array of string used to represent textures
  117466. * @param defines defines the string containing the defines to use to compile the shaders
  117467. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  117468. * @param onCompiled defines a function to call when the effect creation is successful
  117469. * @param onError defines a function to call when the effect creation has failed
  117470. * @returns the new Effect
  117471. */
  117472. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  117473. }
  117474. interface Mesh {
  117475. /**
  117476. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  117477. * @returns an array of IParticleSystem
  117478. */
  117479. getEmittedParticleSystems(): IParticleSystem[];
  117480. /**
  117481. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  117482. * @returns an array of IParticleSystem
  117483. */
  117484. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  117485. }
  117486. /**
  117487. * @hidden
  117488. */
  117489. export var _IDoNeedToBeInTheBuild: number;
  117490. }
  117491. declare module BABYLON {
  117492. interface Scene {
  117493. /** @hidden (Backing field) */
  117494. _physicsEngine: Nullable<IPhysicsEngine>;
  117495. /**
  117496. * Gets the current physics engine
  117497. * @returns a IPhysicsEngine or null if none attached
  117498. */
  117499. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  117500. /**
  117501. * Enables physics to the current scene
  117502. * @param gravity defines the scene's gravity for the physics engine
  117503. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  117504. * @return a boolean indicating if the physics engine was initialized
  117505. */
  117506. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  117507. /**
  117508. * Disables and disposes the physics engine associated with the scene
  117509. */
  117510. disablePhysicsEngine(): void;
  117511. /**
  117512. * Gets a boolean indicating if there is an active physics engine
  117513. * @returns a boolean indicating if there is an active physics engine
  117514. */
  117515. isPhysicsEnabled(): boolean;
  117516. /**
  117517. * Deletes a physics compound impostor
  117518. * @param compound defines the compound to delete
  117519. */
  117520. deleteCompoundImpostor(compound: any): void;
  117521. /**
  117522. * An event triggered when physic simulation is about to be run
  117523. */
  117524. onBeforePhysicsObservable: Observable<Scene>;
  117525. /**
  117526. * An event triggered when physic simulation has been done
  117527. */
  117528. onAfterPhysicsObservable: Observable<Scene>;
  117529. }
  117530. interface AbstractMesh {
  117531. /** @hidden */
  117532. _physicsImpostor: Nullable<PhysicsImpostor>;
  117533. /**
  117534. * Gets or sets impostor used for physic simulation
  117535. * @see http://doc.babylonjs.com/features/physics_engine
  117536. */
  117537. physicsImpostor: Nullable<PhysicsImpostor>;
  117538. /**
  117539. * Gets the current physics impostor
  117540. * @see http://doc.babylonjs.com/features/physics_engine
  117541. * @returns a physics impostor or null
  117542. */
  117543. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  117544. /** Apply a physic impulse to the mesh
  117545. * @param force defines the force to apply
  117546. * @param contactPoint defines where to apply the force
  117547. * @returns the current mesh
  117548. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  117549. */
  117550. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  117551. /**
  117552. * Creates a physic joint between two meshes
  117553. * @param otherMesh defines the other mesh to use
  117554. * @param pivot1 defines the pivot to use on this mesh
  117555. * @param pivot2 defines the pivot to use on the other mesh
  117556. * @param options defines additional options (can be plugin dependent)
  117557. * @returns the current mesh
  117558. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  117559. */
  117560. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  117561. /** @hidden */
  117562. _disposePhysicsObserver: Nullable<Observer<Node>>;
  117563. }
  117564. /**
  117565. * Defines the physics engine scene component responsible to manage a physics engine
  117566. */
  117567. export class PhysicsEngineSceneComponent implements ISceneComponent {
  117568. /**
  117569. * The component name helpful to identify the component in the list of scene components.
  117570. */
  117571. readonly name: string;
  117572. /**
  117573. * The scene the component belongs to.
  117574. */
  117575. scene: Scene;
  117576. /**
  117577. * Creates a new instance of the component for the given scene
  117578. * @param scene Defines the scene to register the component in
  117579. */
  117580. constructor(scene: Scene);
  117581. /**
  117582. * Registers the component in a given scene
  117583. */
  117584. register(): void;
  117585. /**
  117586. * Rebuilds the elements related to this component in case of
  117587. * context lost for instance.
  117588. */
  117589. rebuild(): void;
  117590. /**
  117591. * Disposes the component and the associated ressources
  117592. */
  117593. dispose(): void;
  117594. }
  117595. }
  117596. declare module BABYLON {
  117597. /**
  117598. * A helper for physics simulations
  117599. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117600. */
  117601. export class PhysicsHelper {
  117602. private _scene;
  117603. private _physicsEngine;
  117604. /**
  117605. * Initializes the Physics helper
  117606. * @param scene Babylon.js scene
  117607. */
  117608. constructor(scene: Scene);
  117609. /**
  117610. * Applies a radial explosion impulse
  117611. * @param origin the origin of the explosion
  117612. * @param radiusOrEventOptions the radius or the options of radial explosion
  117613. * @param strength the explosion strength
  117614. * @param falloff possible options: Constant & Linear. Defaults to Constant
  117615. * @returns A physics radial explosion event, or null
  117616. */
  117617. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  117618. /**
  117619. * Applies a radial explosion force
  117620. * @param origin the origin of the explosion
  117621. * @param radiusOrEventOptions the radius or the options of radial explosion
  117622. * @param strength the explosion strength
  117623. * @param falloff possible options: Constant & Linear. Defaults to Constant
  117624. * @returns A physics radial explosion event, or null
  117625. */
  117626. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  117627. /**
  117628. * Creates a gravitational field
  117629. * @param origin the origin of the explosion
  117630. * @param radiusOrEventOptions the radius or the options of radial explosion
  117631. * @param strength the explosion strength
  117632. * @param falloff possible options: Constant & Linear. Defaults to Constant
  117633. * @returns A physics gravitational field event, or null
  117634. */
  117635. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  117636. /**
  117637. * Creates a physics updraft event
  117638. * @param origin the origin of the updraft
  117639. * @param radiusOrEventOptions the radius or the options of the updraft
  117640. * @param strength the strength of the updraft
  117641. * @param height the height of the updraft
  117642. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  117643. * @returns A physics updraft event, or null
  117644. */
  117645. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  117646. /**
  117647. * Creates a physics vortex event
  117648. * @param origin the of the vortex
  117649. * @param radiusOrEventOptions the radius or the options of the vortex
  117650. * @param strength the strength of the vortex
  117651. * @param height the height of the vortex
  117652. * @returns a Physics vortex event, or null
  117653. * A physics vortex event or null
  117654. */
  117655. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  117656. }
  117657. /**
  117658. * Represents a physics radial explosion event
  117659. */
  117660. class PhysicsRadialExplosionEvent {
  117661. private _scene;
  117662. private _options;
  117663. private _sphere;
  117664. private _dataFetched;
  117665. /**
  117666. * Initializes a radial explosioin event
  117667. * @param _scene BabylonJS scene
  117668. * @param _options The options for the vortex event
  117669. */
  117670. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  117671. /**
  117672. * Returns the data related to the radial explosion event (sphere).
  117673. * @returns The radial explosion event data
  117674. */
  117675. getData(): PhysicsRadialExplosionEventData;
  117676. /**
  117677. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  117678. * @param impostor A physics imposter
  117679. * @param origin the origin of the explosion
  117680. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  117681. */
  117682. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  117683. /**
  117684. * Triggers affecterd impostors callbacks
  117685. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  117686. */
  117687. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  117688. /**
  117689. * Disposes the sphere.
  117690. * @param force Specifies if the sphere should be disposed by force
  117691. */
  117692. dispose(force?: boolean): void;
  117693. /*** Helpers ***/
  117694. private _prepareSphere;
  117695. private _intersectsWithSphere;
  117696. }
  117697. /**
  117698. * Represents a gravitational field event
  117699. */
  117700. class PhysicsGravitationalFieldEvent {
  117701. private _physicsHelper;
  117702. private _scene;
  117703. private _origin;
  117704. private _options;
  117705. private _tickCallback;
  117706. private _sphere;
  117707. private _dataFetched;
  117708. /**
  117709. * Initializes the physics gravitational field event
  117710. * @param _physicsHelper A physics helper
  117711. * @param _scene BabylonJS scene
  117712. * @param _origin The origin position of the gravitational field event
  117713. * @param _options The options for the vortex event
  117714. */
  117715. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  117716. /**
  117717. * Returns the data related to the gravitational field event (sphere).
  117718. * @returns A gravitational field event
  117719. */
  117720. getData(): PhysicsGravitationalFieldEventData;
  117721. /**
  117722. * Enables the gravitational field.
  117723. */
  117724. enable(): void;
  117725. /**
  117726. * Disables the gravitational field.
  117727. */
  117728. disable(): void;
  117729. /**
  117730. * Disposes the sphere.
  117731. * @param force The force to dispose from the gravitational field event
  117732. */
  117733. dispose(force?: boolean): void;
  117734. private _tick;
  117735. }
  117736. /**
  117737. * Represents a physics updraft event
  117738. */
  117739. class PhysicsUpdraftEvent {
  117740. private _scene;
  117741. private _origin;
  117742. private _options;
  117743. private _physicsEngine;
  117744. private _originTop;
  117745. private _originDirection;
  117746. private _tickCallback;
  117747. private _cylinder;
  117748. private _cylinderPosition;
  117749. private _dataFetched;
  117750. /**
  117751. * Initializes the physics updraft event
  117752. * @param _scene BabylonJS scene
  117753. * @param _origin The origin position of the updraft
  117754. * @param _options The options for the updraft event
  117755. */
  117756. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  117757. /**
  117758. * Returns the data related to the updraft event (cylinder).
  117759. * @returns A physics updraft event
  117760. */
  117761. getData(): PhysicsUpdraftEventData;
  117762. /**
  117763. * Enables the updraft.
  117764. */
  117765. enable(): void;
  117766. /**
  117767. * Disables the updraft.
  117768. */
  117769. disable(): void;
  117770. /**
  117771. * Disposes the cylinder.
  117772. * @param force Specifies if the updraft should be disposed by force
  117773. */
  117774. dispose(force?: boolean): void;
  117775. private getImpostorHitData;
  117776. private _tick;
  117777. /*** Helpers ***/
  117778. private _prepareCylinder;
  117779. private _intersectsWithCylinder;
  117780. }
  117781. /**
  117782. * Represents a physics vortex event
  117783. */
  117784. class PhysicsVortexEvent {
  117785. private _scene;
  117786. private _origin;
  117787. private _options;
  117788. private _physicsEngine;
  117789. private _originTop;
  117790. private _tickCallback;
  117791. private _cylinder;
  117792. private _cylinderPosition;
  117793. private _dataFetched;
  117794. /**
  117795. * Initializes the physics vortex event
  117796. * @param _scene The BabylonJS scene
  117797. * @param _origin The origin position of the vortex
  117798. * @param _options The options for the vortex event
  117799. */
  117800. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  117801. /**
  117802. * Returns the data related to the vortex event (cylinder).
  117803. * @returns The physics vortex event data
  117804. */
  117805. getData(): PhysicsVortexEventData;
  117806. /**
  117807. * Enables the vortex.
  117808. */
  117809. enable(): void;
  117810. /**
  117811. * Disables the cortex.
  117812. */
  117813. disable(): void;
  117814. /**
  117815. * Disposes the sphere.
  117816. * @param force
  117817. */
  117818. dispose(force?: boolean): void;
  117819. private getImpostorHitData;
  117820. private _tick;
  117821. /*** Helpers ***/
  117822. private _prepareCylinder;
  117823. private _intersectsWithCylinder;
  117824. }
  117825. /**
  117826. * Options fot the radial explosion event
  117827. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117828. */
  117829. export class PhysicsRadialExplosionEventOptions {
  117830. /**
  117831. * The radius of the sphere for the radial explosion.
  117832. */
  117833. radius: number;
  117834. /**
  117835. * The strenth of the explosion.
  117836. */
  117837. strength: number;
  117838. /**
  117839. * The strenght of the force in correspondence to the distance of the affected object
  117840. */
  117841. falloff: PhysicsRadialImpulseFalloff;
  117842. /**
  117843. * Sphere options for the radial explosion.
  117844. */
  117845. sphere: {
  117846. segments: number;
  117847. diameter: number;
  117848. };
  117849. /**
  117850. * Sphere options for the radial explosion.
  117851. */
  117852. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  117853. }
  117854. /**
  117855. * Options fot the updraft event
  117856. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117857. */
  117858. export class PhysicsUpdraftEventOptions {
  117859. /**
  117860. * The radius of the cylinder for the vortex
  117861. */
  117862. radius: number;
  117863. /**
  117864. * The strenth of the updraft.
  117865. */
  117866. strength: number;
  117867. /**
  117868. * The height of the cylinder for the updraft.
  117869. */
  117870. height: number;
  117871. /**
  117872. * The mode for the the updraft.
  117873. */
  117874. updraftMode: PhysicsUpdraftMode;
  117875. }
  117876. /**
  117877. * Options fot the vortex event
  117878. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117879. */
  117880. export class PhysicsVortexEventOptions {
  117881. /**
  117882. * The radius of the cylinder for the vortex
  117883. */
  117884. radius: number;
  117885. /**
  117886. * The strenth of the vortex.
  117887. */
  117888. strength: number;
  117889. /**
  117890. * The height of the cylinder for the vortex.
  117891. */
  117892. height: number;
  117893. /**
  117894. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  117895. */
  117896. centripetalForceThreshold: number;
  117897. /**
  117898. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  117899. */
  117900. centripetalForceMultiplier: number;
  117901. /**
  117902. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  117903. */
  117904. centrifugalForceMultiplier: number;
  117905. /**
  117906. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  117907. */
  117908. updraftForceMultiplier: number;
  117909. }
  117910. /**
  117911. * The strenght of the force in correspondence to the distance of the affected object
  117912. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117913. */
  117914. export enum PhysicsRadialImpulseFalloff {
  117915. /** Defines that impulse is constant in strength across it's whole radius */
  117916. Constant = 0,
  117917. /** Defines that impulse gets weaker if it's further from the origin */
  117918. Linear = 1
  117919. }
  117920. /**
  117921. * The strength of the force in correspondence to the distance of the affected object
  117922. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117923. */
  117924. export enum PhysicsUpdraftMode {
  117925. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  117926. Center = 0,
  117927. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  117928. Perpendicular = 1
  117929. }
  117930. /**
  117931. * Interface for a physics hit data
  117932. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117933. */
  117934. export interface PhysicsHitData {
  117935. /**
  117936. * The force applied at the contact point
  117937. */
  117938. force: Vector3;
  117939. /**
  117940. * The contact point
  117941. */
  117942. contactPoint: Vector3;
  117943. /**
  117944. * The distance from the origin to the contact point
  117945. */
  117946. distanceFromOrigin: number;
  117947. }
  117948. /**
  117949. * Interface for radial explosion event data
  117950. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117951. */
  117952. export interface PhysicsRadialExplosionEventData {
  117953. /**
  117954. * A sphere used for the radial explosion event
  117955. */
  117956. sphere: Mesh;
  117957. }
  117958. /**
  117959. * Interface for gravitational field event data
  117960. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117961. */
  117962. export interface PhysicsGravitationalFieldEventData {
  117963. /**
  117964. * A sphere mesh used for the gravitational field event
  117965. */
  117966. sphere: Mesh;
  117967. }
  117968. /**
  117969. * Interface for updraft event data
  117970. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117971. */
  117972. export interface PhysicsUpdraftEventData {
  117973. /**
  117974. * A cylinder used for the updraft event
  117975. */
  117976. cylinder: Mesh;
  117977. }
  117978. /**
  117979. * Interface for vortex event data
  117980. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117981. */
  117982. export interface PhysicsVortexEventData {
  117983. /**
  117984. * A cylinder used for the vortex event
  117985. */
  117986. cylinder: Mesh;
  117987. }
  117988. /**
  117989. * Interface for an affected physics impostor
  117990. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117991. */
  117992. export interface PhysicsAffectedImpostorWithData {
  117993. /**
  117994. * The impostor affected by the effect
  117995. */
  117996. impostor: PhysicsImpostor;
  117997. /**
  117998. * The data about the hit/horce from the explosion
  117999. */
  118000. hitData: PhysicsHitData;
  118001. }
  118002. }
  118003. declare module BABYLON {
  118004. /** @hidden */
  118005. export var blackAndWhitePixelShader: {
  118006. name: string;
  118007. shader: string;
  118008. };
  118009. }
  118010. declare module BABYLON {
  118011. /**
  118012. * Post process used to render in black and white
  118013. */
  118014. export class BlackAndWhitePostProcess extends PostProcess {
  118015. /**
  118016. * Linear about to convert he result to black and white (default: 1)
  118017. */
  118018. degree: number;
  118019. /**
  118020. * Creates a black and white post process
  118021. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  118022. * @param name The name of the effect.
  118023. * @param options The required width/height ratio to downsize to before computing the render pass.
  118024. * @param camera The camera to apply the render pass to.
  118025. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118026. * @param engine The engine which the post process will be applied. (default: current engine)
  118027. * @param reusable If the post process can be reused on the same frame. (default: false)
  118028. */
  118029. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118030. }
  118031. }
  118032. declare module BABYLON {
  118033. /**
  118034. * This represents a set of one or more post processes in Babylon.
  118035. * A post process can be used to apply a shader to a texture after it is rendered.
  118036. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118037. */
  118038. export class PostProcessRenderEffect {
  118039. private _postProcesses;
  118040. private _getPostProcesses;
  118041. private _singleInstance;
  118042. private _cameras;
  118043. private _indicesForCamera;
  118044. /**
  118045. * Name of the effect
  118046. * @hidden
  118047. */
  118048. _name: string;
  118049. /**
  118050. * Instantiates a post process render effect.
  118051. * A post process can be used to apply a shader to a texture after it is rendered.
  118052. * @param engine The engine the effect is tied to
  118053. * @param name The name of the effect
  118054. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  118055. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  118056. */
  118057. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  118058. /**
  118059. * Checks if all the post processes in the effect are supported.
  118060. */
  118061. readonly isSupported: boolean;
  118062. /**
  118063. * Updates the current state of the effect
  118064. * @hidden
  118065. */
  118066. _update(): void;
  118067. /**
  118068. * Attaches the effect on cameras
  118069. * @param cameras The camera to attach to.
  118070. * @hidden
  118071. */
  118072. _attachCameras(cameras: Camera): void;
  118073. /**
  118074. * Attaches the effect on cameras
  118075. * @param cameras The camera to attach to.
  118076. * @hidden
  118077. */
  118078. _attachCameras(cameras: Camera[]): void;
  118079. /**
  118080. * Detaches the effect on cameras
  118081. * @param cameras The camera to detatch from.
  118082. * @hidden
  118083. */
  118084. _detachCameras(cameras: Camera): void;
  118085. /**
  118086. * Detatches the effect on cameras
  118087. * @param cameras The camera to detatch from.
  118088. * @hidden
  118089. */
  118090. _detachCameras(cameras: Camera[]): void;
  118091. /**
  118092. * Enables the effect on given cameras
  118093. * @param cameras The camera to enable.
  118094. * @hidden
  118095. */
  118096. _enable(cameras: Camera): void;
  118097. /**
  118098. * Enables the effect on given cameras
  118099. * @param cameras The camera to enable.
  118100. * @hidden
  118101. */
  118102. _enable(cameras: Nullable<Camera[]>): void;
  118103. /**
  118104. * Disables the effect on the given cameras
  118105. * @param cameras The camera to disable.
  118106. * @hidden
  118107. */
  118108. _disable(cameras: Camera): void;
  118109. /**
  118110. * Disables the effect on the given cameras
  118111. * @param cameras The camera to disable.
  118112. * @hidden
  118113. */
  118114. _disable(cameras: Nullable<Camera[]>): void;
  118115. /**
  118116. * Gets a list of the post processes contained in the effect.
  118117. * @param camera The camera to get the post processes on.
  118118. * @returns The list of the post processes in the effect.
  118119. */
  118120. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  118121. }
  118122. }
  118123. declare module BABYLON {
  118124. /** @hidden */
  118125. export var extractHighlightsPixelShader: {
  118126. name: string;
  118127. shader: string;
  118128. };
  118129. }
  118130. declare module BABYLON {
  118131. /**
  118132. * 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.
  118133. */
  118134. export class ExtractHighlightsPostProcess extends PostProcess {
  118135. /**
  118136. * The luminance threshold, pixels below this value will be set to black.
  118137. */
  118138. threshold: number;
  118139. /** @hidden */
  118140. _exposure: number;
  118141. /**
  118142. * Post process which has the input texture to be used when performing highlight extraction
  118143. * @hidden
  118144. */
  118145. _inputPostProcess: Nullable<PostProcess>;
  118146. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118147. }
  118148. }
  118149. declare module BABYLON {
  118150. /** @hidden */
  118151. export var bloomMergePixelShader: {
  118152. name: string;
  118153. shader: string;
  118154. };
  118155. }
  118156. declare module BABYLON {
  118157. /**
  118158. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  118159. */
  118160. export class BloomMergePostProcess extends PostProcess {
  118161. /** Weight of the bloom to be added to the original input. */
  118162. weight: number;
  118163. /**
  118164. * Creates a new instance of @see BloomMergePostProcess
  118165. * @param name The name of the effect.
  118166. * @param originalFromInput Post process which's input will be used for the merge.
  118167. * @param blurred Blurred highlights post process which's output will be used.
  118168. * @param weight Weight of the bloom to be added to the original input.
  118169. * @param options The required width/height ratio to downsize to before computing the render pass.
  118170. * @param camera The camera to apply the render pass to.
  118171. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118172. * @param engine The engine which the post process will be applied. (default: current engine)
  118173. * @param reusable If the post process can be reused on the same frame. (default: false)
  118174. * @param textureType Type of textures used when performing the post process. (default: 0)
  118175. * @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)
  118176. */
  118177. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  118178. /** Weight of the bloom to be added to the original input. */
  118179. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118180. }
  118181. }
  118182. declare module BABYLON {
  118183. /**
  118184. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  118185. */
  118186. export class BloomEffect extends PostProcessRenderEffect {
  118187. private bloomScale;
  118188. /**
  118189. * @hidden Internal
  118190. */
  118191. _effects: Array<PostProcess>;
  118192. /**
  118193. * @hidden Internal
  118194. */
  118195. _downscale: ExtractHighlightsPostProcess;
  118196. private _blurX;
  118197. private _blurY;
  118198. private _merge;
  118199. /**
  118200. * The luminance threshold to find bright areas of the image to bloom.
  118201. */
  118202. threshold: number;
  118203. /**
  118204. * The strength of the bloom.
  118205. */
  118206. weight: number;
  118207. /**
  118208. * Specifies the size of the bloom blur kernel, relative to the final output size
  118209. */
  118210. kernel: number;
  118211. /**
  118212. * Creates a new instance of @see BloomEffect
  118213. * @param scene The scene the effect belongs to.
  118214. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  118215. * @param bloomKernel The size of the kernel to be used when applying the blur.
  118216. * @param bloomWeight The the strength of bloom.
  118217. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  118218. * @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)
  118219. */
  118220. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  118221. /**
  118222. * Disposes each of the internal effects for a given camera.
  118223. * @param camera The camera to dispose the effect on.
  118224. */
  118225. disposeEffects(camera: Camera): void;
  118226. /**
  118227. * @hidden Internal
  118228. */
  118229. _updateEffects(): void;
  118230. /**
  118231. * Internal
  118232. * @returns if all the contained post processes are ready.
  118233. * @hidden
  118234. */
  118235. _isReady(): boolean;
  118236. }
  118237. }
  118238. declare module BABYLON {
  118239. /** @hidden */
  118240. export var chromaticAberrationPixelShader: {
  118241. name: string;
  118242. shader: string;
  118243. };
  118244. }
  118245. declare module BABYLON {
  118246. /**
  118247. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  118248. */
  118249. export class ChromaticAberrationPostProcess extends PostProcess {
  118250. /**
  118251. * The amount of seperation of rgb channels (default: 30)
  118252. */
  118253. aberrationAmount: number;
  118254. /**
  118255. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  118256. */
  118257. radialIntensity: number;
  118258. /**
  118259. * 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))
  118260. */
  118261. direction: Vector2;
  118262. /**
  118263. * 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))
  118264. */
  118265. centerPosition: Vector2;
  118266. /**
  118267. * Creates a new instance ChromaticAberrationPostProcess
  118268. * @param name The name of the effect.
  118269. * @param screenWidth The width of the screen to apply the effect on.
  118270. * @param screenHeight The height of the screen to apply the effect on.
  118271. * @param options The required width/height ratio to downsize to before computing the render pass.
  118272. * @param camera The camera to apply the render pass to.
  118273. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118274. * @param engine The engine which the post process will be applied. (default: current engine)
  118275. * @param reusable If the post process can be reused on the same frame. (default: false)
  118276. * @param textureType Type of textures used when performing the post process. (default: 0)
  118277. * @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)
  118278. */
  118279. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118280. }
  118281. }
  118282. declare module BABYLON {
  118283. /** @hidden */
  118284. export var circleOfConfusionPixelShader: {
  118285. name: string;
  118286. shader: string;
  118287. };
  118288. }
  118289. declare module BABYLON {
  118290. /**
  118291. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  118292. */
  118293. export class CircleOfConfusionPostProcess extends PostProcess {
  118294. /**
  118295. * 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.
  118296. */
  118297. lensSize: number;
  118298. /**
  118299. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  118300. */
  118301. fStop: number;
  118302. /**
  118303. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  118304. */
  118305. focusDistance: number;
  118306. /**
  118307. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  118308. */
  118309. focalLength: number;
  118310. private _depthTexture;
  118311. /**
  118312. * Creates a new instance CircleOfConfusionPostProcess
  118313. * @param name The name of the effect.
  118314. * @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.
  118315. * @param options The required width/height ratio to downsize to before computing the render pass.
  118316. * @param camera The camera to apply the render pass to.
  118317. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118318. * @param engine The engine which the post process will be applied. (default: current engine)
  118319. * @param reusable If the post process can be reused on the same frame. (default: false)
  118320. * @param textureType Type of textures used when performing the post process. (default: 0)
  118321. * @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)
  118322. */
  118323. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118324. /**
  118325. * 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.
  118326. */
  118327. depthTexture: RenderTargetTexture;
  118328. }
  118329. }
  118330. declare module BABYLON {
  118331. /** @hidden */
  118332. export var colorCorrectionPixelShader: {
  118333. name: string;
  118334. shader: string;
  118335. };
  118336. }
  118337. declare module BABYLON {
  118338. /**
  118339. *
  118340. * This post-process allows the modification of rendered colors by using
  118341. * a 'look-up table' (LUT). This effect is also called Color Grading.
  118342. *
  118343. * The object needs to be provided an url to a texture containing the color
  118344. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  118345. * Use an image editing software to tweak the LUT to match your needs.
  118346. *
  118347. * For an example of a color LUT, see here:
  118348. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  118349. * For explanations on color grading, see here:
  118350. * @see http://udn.epicgames.com/Three/ColorGrading.html
  118351. *
  118352. */
  118353. export class ColorCorrectionPostProcess extends PostProcess {
  118354. private _colorTableTexture;
  118355. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118356. }
  118357. }
  118358. declare module BABYLON {
  118359. /** @hidden */
  118360. export var convolutionPixelShader: {
  118361. name: string;
  118362. shader: string;
  118363. };
  118364. }
  118365. declare module BABYLON {
  118366. /**
  118367. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  118368. * input texture to perform effects such as edge detection or sharpening
  118369. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  118370. */
  118371. export class ConvolutionPostProcess extends PostProcess {
  118372. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  118373. kernel: number[];
  118374. /**
  118375. * Creates a new instance ConvolutionPostProcess
  118376. * @param name The name of the effect.
  118377. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  118378. * @param options The required width/height ratio to downsize to before computing the render pass.
  118379. * @param camera The camera to apply the render pass to.
  118380. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118381. * @param engine The engine which the post process will be applied. (default: current engine)
  118382. * @param reusable If the post process can be reused on the same frame. (default: false)
  118383. * @param textureType Type of textures used when performing the post process. (default: 0)
  118384. */
  118385. constructor(name: string,
  118386. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  118387. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  118388. /**
  118389. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118390. */
  118391. static EdgeDetect0Kernel: number[];
  118392. /**
  118393. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118394. */
  118395. static EdgeDetect1Kernel: number[];
  118396. /**
  118397. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118398. */
  118399. static EdgeDetect2Kernel: number[];
  118400. /**
  118401. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118402. */
  118403. static SharpenKernel: number[];
  118404. /**
  118405. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118406. */
  118407. static EmbossKernel: number[];
  118408. /**
  118409. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118410. */
  118411. static GaussianKernel: number[];
  118412. }
  118413. }
  118414. declare module BABYLON {
  118415. /**
  118416. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  118417. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  118418. * based on samples that have a large difference in distance than the center pixel.
  118419. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  118420. */
  118421. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  118422. direction: Vector2;
  118423. /**
  118424. * Creates a new instance CircleOfConfusionPostProcess
  118425. * @param name The name of the effect.
  118426. * @param scene The scene the effect belongs to.
  118427. * @param direction The direction the blur should be applied.
  118428. * @param kernel The size of the kernel used to blur.
  118429. * @param options The required width/height ratio to downsize to before computing the render pass.
  118430. * @param camera The camera to apply the render pass to.
  118431. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  118432. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  118433. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118434. * @param engine The engine which the post process will be applied. (default: current engine)
  118435. * @param reusable If the post process can be reused on the same frame. (default: false)
  118436. * @param textureType Type of textures used when performing the post process. (default: 0)
  118437. * @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)
  118438. */
  118439. 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);
  118440. }
  118441. }
  118442. declare module BABYLON {
  118443. /** @hidden */
  118444. export var depthOfFieldMergePixelShader: {
  118445. name: string;
  118446. shader: string;
  118447. };
  118448. }
  118449. declare module BABYLON {
  118450. /**
  118451. * Options to be set when merging outputs from the default pipeline.
  118452. */
  118453. export class DepthOfFieldMergePostProcessOptions {
  118454. /**
  118455. * The original image to merge on top of
  118456. */
  118457. originalFromInput: PostProcess;
  118458. /**
  118459. * Parameters to perform the merge of the depth of field effect
  118460. */
  118461. depthOfField?: {
  118462. circleOfConfusion: PostProcess;
  118463. blurSteps: Array<PostProcess>;
  118464. };
  118465. /**
  118466. * Parameters to perform the merge of bloom effect
  118467. */
  118468. bloom?: {
  118469. blurred: PostProcess;
  118470. weight: number;
  118471. };
  118472. }
  118473. /**
  118474. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  118475. */
  118476. export class DepthOfFieldMergePostProcess extends PostProcess {
  118477. private blurSteps;
  118478. /**
  118479. * Creates a new instance of DepthOfFieldMergePostProcess
  118480. * @param name The name of the effect.
  118481. * @param originalFromInput Post process which's input will be used for the merge.
  118482. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  118483. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  118484. * @param options The required width/height ratio to downsize to before computing the render pass.
  118485. * @param camera The camera to apply the render pass to.
  118486. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118487. * @param engine The engine which the post process will be applied. (default: current engine)
  118488. * @param reusable If the post process can be reused on the same frame. (default: false)
  118489. * @param textureType Type of textures used when performing the post process. (default: 0)
  118490. * @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)
  118491. */
  118492. 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);
  118493. /**
  118494. * Updates the effect with the current post process compile time values and recompiles the shader.
  118495. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  118496. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  118497. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  118498. * @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
  118499. * @param onCompiled Called when the shader has been compiled.
  118500. * @param onError Called if there is an error when compiling a shader.
  118501. */
  118502. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  118503. }
  118504. }
  118505. declare module BABYLON {
  118506. /**
  118507. * Specifies the level of max blur that should be applied when using the depth of field effect
  118508. */
  118509. export enum DepthOfFieldEffectBlurLevel {
  118510. /**
  118511. * Subtle blur
  118512. */
  118513. Low = 0,
  118514. /**
  118515. * Medium blur
  118516. */
  118517. Medium = 1,
  118518. /**
  118519. * Large blur
  118520. */
  118521. High = 2
  118522. }
  118523. /**
  118524. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  118525. */
  118526. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  118527. private _circleOfConfusion;
  118528. /**
  118529. * @hidden Internal, blurs from high to low
  118530. */
  118531. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  118532. private _depthOfFieldBlurY;
  118533. private _dofMerge;
  118534. /**
  118535. * @hidden Internal post processes in depth of field effect
  118536. */
  118537. _effects: Array<PostProcess>;
  118538. /**
  118539. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  118540. */
  118541. focalLength: number;
  118542. /**
  118543. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  118544. */
  118545. fStop: number;
  118546. /**
  118547. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  118548. */
  118549. focusDistance: number;
  118550. /**
  118551. * 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.
  118552. */
  118553. lensSize: number;
  118554. /**
  118555. * Creates a new instance DepthOfFieldEffect
  118556. * @param scene The scene the effect belongs to.
  118557. * @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.
  118558. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  118559. * @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)
  118560. */
  118561. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  118562. /**
  118563. * Get the current class name of the current effet
  118564. * @returns "DepthOfFieldEffect"
  118565. */
  118566. getClassName(): string;
  118567. /**
  118568. * 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.
  118569. */
  118570. depthTexture: RenderTargetTexture;
  118571. /**
  118572. * Disposes each of the internal effects for a given camera.
  118573. * @param camera The camera to dispose the effect on.
  118574. */
  118575. disposeEffects(camera: Camera): void;
  118576. /**
  118577. * @hidden Internal
  118578. */
  118579. _updateEffects(): void;
  118580. /**
  118581. * Internal
  118582. * @returns if all the contained post processes are ready.
  118583. * @hidden
  118584. */
  118585. _isReady(): boolean;
  118586. }
  118587. }
  118588. declare module BABYLON {
  118589. /** @hidden */
  118590. export var displayPassPixelShader: {
  118591. name: string;
  118592. shader: string;
  118593. };
  118594. }
  118595. declare module BABYLON {
  118596. /**
  118597. * DisplayPassPostProcess which produces an output the same as it's input
  118598. */
  118599. export class DisplayPassPostProcess extends PostProcess {
  118600. /**
  118601. * Creates the DisplayPassPostProcess
  118602. * @param name The name of the effect.
  118603. * @param options The required width/height ratio to downsize to before computing the render pass.
  118604. * @param camera The camera to apply the render pass to.
  118605. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118606. * @param engine The engine which the post process will be applied. (default: current engine)
  118607. * @param reusable If the post process can be reused on the same frame. (default: false)
  118608. */
  118609. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118610. }
  118611. }
  118612. declare module BABYLON {
  118613. /** @hidden */
  118614. export var filterPixelShader: {
  118615. name: string;
  118616. shader: string;
  118617. };
  118618. }
  118619. declare module BABYLON {
  118620. /**
  118621. * Applies a kernel filter to the image
  118622. */
  118623. export class FilterPostProcess extends PostProcess {
  118624. /** The matrix to be applied to the image */
  118625. kernelMatrix: Matrix;
  118626. /**
  118627. *
  118628. * @param name The name of the effect.
  118629. * @param kernelMatrix The matrix to be applied to the image
  118630. * @param options The required width/height ratio to downsize to before computing the render pass.
  118631. * @param camera The camera to apply the render pass to.
  118632. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118633. * @param engine The engine which the post process will be applied. (default: current engine)
  118634. * @param reusable If the post process can be reused on the same frame. (default: false)
  118635. */
  118636. constructor(name: string,
  118637. /** The matrix to be applied to the image */
  118638. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118639. }
  118640. }
  118641. declare module BABYLON {
  118642. /** @hidden */
  118643. export var fxaaPixelShader: {
  118644. name: string;
  118645. shader: string;
  118646. };
  118647. }
  118648. declare module BABYLON {
  118649. /** @hidden */
  118650. export var fxaaVertexShader: {
  118651. name: string;
  118652. shader: string;
  118653. };
  118654. }
  118655. declare module BABYLON {
  118656. /**
  118657. * Fxaa post process
  118658. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  118659. */
  118660. export class FxaaPostProcess extends PostProcess {
  118661. /** @hidden */
  118662. texelWidth: number;
  118663. /** @hidden */
  118664. texelHeight: number;
  118665. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  118666. private _getDefines;
  118667. }
  118668. }
  118669. declare module BABYLON {
  118670. /** @hidden */
  118671. export var grainPixelShader: {
  118672. name: string;
  118673. shader: string;
  118674. };
  118675. }
  118676. declare module BABYLON {
  118677. /**
  118678. * The GrainPostProcess adds noise to the image at mid luminance levels
  118679. */
  118680. export class GrainPostProcess extends PostProcess {
  118681. /**
  118682. * The intensity of the grain added (default: 30)
  118683. */
  118684. intensity: number;
  118685. /**
  118686. * If the grain should be randomized on every frame
  118687. */
  118688. animated: boolean;
  118689. /**
  118690. * Creates a new instance of @see GrainPostProcess
  118691. * @param name The name of the effect.
  118692. * @param options The required width/height ratio to downsize to before computing the render pass.
  118693. * @param camera The camera to apply the render pass to.
  118694. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118695. * @param engine The engine which the post process will be applied. (default: current engine)
  118696. * @param reusable If the post process can be reused on the same frame. (default: false)
  118697. * @param textureType Type of textures used when performing the post process. (default: 0)
  118698. * @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)
  118699. */
  118700. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118701. }
  118702. }
  118703. declare module BABYLON {
  118704. /** @hidden */
  118705. export var highlightsPixelShader: {
  118706. name: string;
  118707. shader: string;
  118708. };
  118709. }
  118710. declare module BABYLON {
  118711. /**
  118712. * Extracts highlights from the image
  118713. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  118714. */
  118715. export class HighlightsPostProcess extends PostProcess {
  118716. /**
  118717. * Extracts highlights from the image
  118718. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  118719. * @param name The name of the effect.
  118720. * @param options The required width/height ratio to downsize to before computing the render pass.
  118721. * @param camera The camera to apply the render pass to.
  118722. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118723. * @param engine The engine which the post process will be applied. (default: current engine)
  118724. * @param reusable If the post process can be reused on the same frame. (default: false)
  118725. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  118726. */
  118727. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  118728. }
  118729. }
  118730. declare module BABYLON {
  118731. /** @hidden */
  118732. export var mrtFragmentDeclaration: {
  118733. name: string;
  118734. shader: string;
  118735. };
  118736. }
  118737. declare module BABYLON {
  118738. /** @hidden */
  118739. export var geometryPixelShader: {
  118740. name: string;
  118741. shader: string;
  118742. };
  118743. }
  118744. declare module BABYLON {
  118745. /** @hidden */
  118746. export var geometryVertexShader: {
  118747. name: string;
  118748. shader: string;
  118749. };
  118750. }
  118751. declare module BABYLON {
  118752. /** @hidden */
  118753. interface ISavedTransformationMatrix {
  118754. world: Matrix;
  118755. viewProjection: Matrix;
  118756. }
  118757. /**
  118758. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  118759. */
  118760. export class GeometryBufferRenderer {
  118761. /**
  118762. * Constant used to retrieve the position texture index in the G-Buffer textures array
  118763. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  118764. */
  118765. static readonly POSITION_TEXTURE_TYPE: number;
  118766. /**
  118767. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  118768. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  118769. */
  118770. static readonly VELOCITY_TEXTURE_TYPE: number;
  118771. /**
  118772. * Dictionary used to store the previous transformation matrices of each rendered mesh
  118773. * in order to compute objects velocities when enableVelocity is set to "true"
  118774. * @hidden
  118775. */
  118776. _previousTransformationMatrices: {
  118777. [index: number]: ISavedTransformationMatrix;
  118778. };
  118779. /**
  118780. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  118781. * in order to compute objects velocities when enableVelocity is set to "true"
  118782. * @hidden
  118783. */
  118784. _previousBonesTransformationMatrices: {
  118785. [index: number]: Float32Array;
  118786. };
  118787. /**
  118788. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  118789. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  118790. */
  118791. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  118792. private _scene;
  118793. private _multiRenderTarget;
  118794. private _ratio;
  118795. private _enablePosition;
  118796. private _enableVelocity;
  118797. private _positionIndex;
  118798. private _velocityIndex;
  118799. protected _effect: Effect;
  118800. protected _cachedDefines: string;
  118801. /**
  118802. * Set the render list (meshes to be rendered) used in the G buffer.
  118803. */
  118804. renderList: Mesh[];
  118805. /**
  118806. * Gets wether or not G buffer are supported by the running hardware.
  118807. * This requires draw buffer supports
  118808. */
  118809. readonly isSupported: boolean;
  118810. /**
  118811. * Returns the index of the given texture type in the G-Buffer textures array
  118812. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  118813. * @returns the index of the given texture type in the G-Buffer textures array
  118814. */
  118815. getTextureIndex(textureType: number): number;
  118816. /**
  118817. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  118818. */
  118819. /**
  118820. * Sets whether or not objects positions are enabled for the G buffer.
  118821. */
  118822. enablePosition: boolean;
  118823. /**
  118824. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  118825. */
  118826. /**
  118827. * Sets wether or not objects velocities are enabled for the G buffer.
  118828. */
  118829. enableVelocity: boolean;
  118830. /**
  118831. * Gets the scene associated with the buffer.
  118832. */
  118833. readonly scene: Scene;
  118834. /**
  118835. * Gets the ratio used by the buffer during its creation.
  118836. * How big is the buffer related to the main canvas.
  118837. */
  118838. readonly ratio: number;
  118839. /** @hidden */
  118840. static _SceneComponentInitialization: (scene: Scene) => void;
  118841. /**
  118842. * Creates a new G Buffer for the scene
  118843. * @param scene The scene the buffer belongs to
  118844. * @param ratio How big is the buffer related to the main canvas.
  118845. */
  118846. constructor(scene: Scene, ratio?: number);
  118847. /**
  118848. * Checks wether everything is ready to render a submesh to the G buffer.
  118849. * @param subMesh the submesh to check readiness for
  118850. * @param useInstances is the mesh drawn using instance or not
  118851. * @returns true if ready otherwise false
  118852. */
  118853. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118854. /**
  118855. * Gets the current underlying G Buffer.
  118856. * @returns the buffer
  118857. */
  118858. getGBuffer(): MultiRenderTarget;
  118859. /**
  118860. * Gets the number of samples used to render the buffer (anti aliasing).
  118861. */
  118862. /**
  118863. * Sets the number of samples used to render the buffer (anti aliasing).
  118864. */
  118865. samples: number;
  118866. /**
  118867. * Disposes the renderer and frees up associated resources.
  118868. */
  118869. dispose(): void;
  118870. protected _createRenderTargets(): void;
  118871. private _copyBonesTransformationMatrices;
  118872. }
  118873. }
  118874. declare module BABYLON {
  118875. interface Scene {
  118876. /** @hidden (Backing field) */
  118877. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  118878. /**
  118879. * Gets or Sets the current geometry buffer associated to the scene.
  118880. */
  118881. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  118882. /**
  118883. * Enables a GeometryBufferRender and associates it with the scene
  118884. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  118885. * @returns the GeometryBufferRenderer
  118886. */
  118887. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  118888. /**
  118889. * Disables the GeometryBufferRender associated with the scene
  118890. */
  118891. disableGeometryBufferRenderer(): void;
  118892. }
  118893. /**
  118894. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  118895. * in several rendering techniques.
  118896. */
  118897. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  118898. /**
  118899. * The component name helpful to identify the component in the list of scene components.
  118900. */
  118901. readonly name: string;
  118902. /**
  118903. * The scene the component belongs to.
  118904. */
  118905. scene: Scene;
  118906. /**
  118907. * Creates a new instance of the component for the given scene
  118908. * @param scene Defines the scene to register the component in
  118909. */
  118910. constructor(scene: Scene);
  118911. /**
  118912. * Registers the component in a given scene
  118913. */
  118914. register(): void;
  118915. /**
  118916. * Rebuilds the elements related to this component in case of
  118917. * context lost for instance.
  118918. */
  118919. rebuild(): void;
  118920. /**
  118921. * Disposes the component and the associated ressources
  118922. */
  118923. dispose(): void;
  118924. private _gatherRenderTargets;
  118925. }
  118926. }
  118927. declare module BABYLON {
  118928. /** @hidden */
  118929. export var motionBlurPixelShader: {
  118930. name: string;
  118931. shader: string;
  118932. };
  118933. }
  118934. declare module BABYLON {
  118935. /**
  118936. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  118937. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  118938. * As an example, all you have to do is to create the post-process:
  118939. * var mb = new BABYLON.MotionBlurPostProcess(
  118940. * 'mb', // The name of the effect.
  118941. * scene, // The scene containing the objects to blur according to their velocity.
  118942. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  118943. * camera // The camera to apply the render pass to.
  118944. * );
  118945. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  118946. */
  118947. export class MotionBlurPostProcess extends PostProcess {
  118948. /**
  118949. * Defines how much the image is blurred by the movement. Default value is equal to 1
  118950. */
  118951. motionStrength: number;
  118952. /**
  118953. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  118954. */
  118955. /**
  118956. * Sets the number of iterations to be used for motion blur quality
  118957. */
  118958. motionBlurSamples: number;
  118959. private _motionBlurSamples;
  118960. private _geometryBufferRenderer;
  118961. /**
  118962. * Creates a new instance MotionBlurPostProcess
  118963. * @param name The name of the effect.
  118964. * @param scene The scene containing the objects to blur according to their velocity.
  118965. * @param options The required width/height ratio to downsize to before computing the render pass.
  118966. * @param camera The camera to apply the render pass to.
  118967. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118968. * @param engine The engine which the post process will be applied. (default: current engine)
  118969. * @param reusable If the post process can be reused on the same frame. (default: false)
  118970. * @param textureType Type of textures used when performing the post process. (default: 0)
  118971. * @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)
  118972. */
  118973. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118974. /**
  118975. * Excludes the given skinned mesh from computing bones velocities.
  118976. * 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.
  118977. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  118978. */
  118979. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  118980. /**
  118981. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  118982. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  118983. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  118984. */
  118985. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  118986. /**
  118987. * Disposes the post process.
  118988. * @param camera The camera to dispose the post process on.
  118989. */
  118990. dispose(camera?: Camera): void;
  118991. }
  118992. }
  118993. declare module BABYLON {
  118994. /** @hidden */
  118995. export var refractionPixelShader: {
  118996. name: string;
  118997. shader: string;
  118998. };
  118999. }
  119000. declare module BABYLON {
  119001. /**
  119002. * Post process which applies a refractin texture
  119003. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  119004. */
  119005. export class RefractionPostProcess extends PostProcess {
  119006. /** the base color of the refraction (used to taint the rendering) */
  119007. color: Color3;
  119008. /** simulated refraction depth */
  119009. depth: number;
  119010. /** the coefficient of the base color (0 to remove base color tainting) */
  119011. colorLevel: number;
  119012. private _refTexture;
  119013. private _ownRefractionTexture;
  119014. /**
  119015. * Gets or sets the refraction texture
  119016. * Please note that you are responsible for disposing the texture if you set it manually
  119017. */
  119018. refractionTexture: Texture;
  119019. /**
  119020. * Initializes the RefractionPostProcess
  119021. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  119022. * @param name The name of the effect.
  119023. * @param refractionTextureUrl Url of the refraction texture to use
  119024. * @param color the base color of the refraction (used to taint the rendering)
  119025. * @param depth simulated refraction depth
  119026. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  119027. * @param camera The camera to apply the render pass to.
  119028. * @param options The required width/height ratio to downsize to before computing the render pass.
  119029. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119030. * @param engine The engine which the post process will be applied. (default: current engine)
  119031. * @param reusable If the post process can be reused on the same frame. (default: false)
  119032. */
  119033. constructor(name: string, refractionTextureUrl: string,
  119034. /** the base color of the refraction (used to taint the rendering) */
  119035. color: Color3,
  119036. /** simulated refraction depth */
  119037. depth: number,
  119038. /** the coefficient of the base color (0 to remove base color tainting) */
  119039. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  119040. /**
  119041. * Disposes of the post process
  119042. * @param camera Camera to dispose post process on
  119043. */
  119044. dispose(camera: Camera): void;
  119045. }
  119046. }
  119047. declare module BABYLON {
  119048. /** @hidden */
  119049. export var sharpenPixelShader: {
  119050. name: string;
  119051. shader: string;
  119052. };
  119053. }
  119054. declare module BABYLON {
  119055. /**
  119056. * The SharpenPostProcess applies a sharpen kernel to every pixel
  119057. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  119058. */
  119059. export class SharpenPostProcess extends PostProcess {
  119060. /**
  119061. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  119062. */
  119063. colorAmount: number;
  119064. /**
  119065. * How much sharpness should be applied (default: 0.3)
  119066. */
  119067. edgeAmount: number;
  119068. /**
  119069. * Creates a new instance ConvolutionPostProcess
  119070. * @param name The name of the effect.
  119071. * @param options The required width/height ratio to downsize to before computing the render pass.
  119072. * @param camera The camera to apply the render pass to.
  119073. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119074. * @param engine The engine which the post process will be applied. (default: current engine)
  119075. * @param reusable If the post process can be reused on the same frame. (default: false)
  119076. * @param textureType Type of textures used when performing the post process. (default: 0)
  119077. * @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)
  119078. */
  119079. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  119080. }
  119081. }
  119082. declare module BABYLON {
  119083. /**
  119084. * PostProcessRenderPipeline
  119085. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  119086. */
  119087. export class PostProcessRenderPipeline {
  119088. private engine;
  119089. private _renderEffects;
  119090. private _renderEffectsForIsolatedPass;
  119091. /**
  119092. * List of inspectable custom properties (used by the Inspector)
  119093. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  119094. */
  119095. inspectableCustomProperties: IInspectable[];
  119096. /**
  119097. * @hidden
  119098. */
  119099. protected _cameras: Camera[];
  119100. /** @hidden */
  119101. _name: string;
  119102. /**
  119103. * Gets pipeline name
  119104. */
  119105. readonly name: string;
  119106. /**
  119107. * Initializes a PostProcessRenderPipeline
  119108. * @param engine engine to add the pipeline to
  119109. * @param name name of the pipeline
  119110. */
  119111. constructor(engine: Engine, name: string);
  119112. /**
  119113. * Gets the class name
  119114. * @returns "PostProcessRenderPipeline"
  119115. */
  119116. getClassName(): string;
  119117. /**
  119118. * If all the render effects in the pipeline are supported
  119119. */
  119120. readonly isSupported: boolean;
  119121. /**
  119122. * Adds an effect to the pipeline
  119123. * @param renderEffect the effect to add
  119124. */
  119125. addEffect(renderEffect: PostProcessRenderEffect): void;
  119126. /** @hidden */
  119127. _rebuild(): void;
  119128. /** @hidden */
  119129. _enableEffect(renderEffectName: string, cameras: Camera): void;
  119130. /** @hidden */
  119131. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  119132. /** @hidden */
  119133. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  119134. /** @hidden */
  119135. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  119136. /** @hidden */
  119137. _attachCameras(cameras: Camera, unique: boolean): void;
  119138. /** @hidden */
  119139. _attachCameras(cameras: Camera[], unique: boolean): void;
  119140. /** @hidden */
  119141. _detachCameras(cameras: Camera): void;
  119142. /** @hidden */
  119143. _detachCameras(cameras: Nullable<Camera[]>): void;
  119144. /** @hidden */
  119145. _update(): void;
  119146. /** @hidden */
  119147. _reset(): void;
  119148. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  119149. /**
  119150. * Disposes of the pipeline
  119151. */
  119152. dispose(): void;
  119153. }
  119154. }
  119155. declare module BABYLON {
  119156. /**
  119157. * PostProcessRenderPipelineManager class
  119158. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  119159. */
  119160. export class PostProcessRenderPipelineManager {
  119161. private _renderPipelines;
  119162. /**
  119163. * Initializes a PostProcessRenderPipelineManager
  119164. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  119165. */
  119166. constructor();
  119167. /**
  119168. * Gets the list of supported render pipelines
  119169. */
  119170. readonly supportedPipelines: PostProcessRenderPipeline[];
  119171. /**
  119172. * Adds a pipeline to the manager
  119173. * @param renderPipeline The pipeline to add
  119174. */
  119175. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  119176. /**
  119177. * Attaches a camera to the pipeline
  119178. * @param renderPipelineName The name of the pipeline to attach to
  119179. * @param cameras the camera to attach
  119180. * @param unique if the camera can be attached multiple times to the pipeline
  119181. */
  119182. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  119183. /**
  119184. * Detaches a camera from the pipeline
  119185. * @param renderPipelineName The name of the pipeline to detach from
  119186. * @param cameras the camera to detach
  119187. */
  119188. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  119189. /**
  119190. * Enables an effect by name on a pipeline
  119191. * @param renderPipelineName the name of the pipeline to enable the effect in
  119192. * @param renderEffectName the name of the effect to enable
  119193. * @param cameras the cameras that the effect should be enabled on
  119194. */
  119195. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  119196. /**
  119197. * Disables an effect by name on a pipeline
  119198. * @param renderPipelineName the name of the pipeline to disable the effect in
  119199. * @param renderEffectName the name of the effect to disable
  119200. * @param cameras the cameras that the effect should be disabled on
  119201. */
  119202. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  119203. /**
  119204. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  119205. */
  119206. update(): void;
  119207. /** @hidden */
  119208. _rebuild(): void;
  119209. /**
  119210. * Disposes of the manager and pipelines
  119211. */
  119212. dispose(): void;
  119213. }
  119214. }
  119215. declare module BABYLON {
  119216. interface Scene {
  119217. /** @hidden (Backing field) */
  119218. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  119219. /**
  119220. * Gets the postprocess render pipeline manager
  119221. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  119222. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  119223. */
  119224. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  119225. }
  119226. /**
  119227. * Defines the Render Pipeline scene component responsible to rendering pipelines
  119228. */
  119229. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  119230. /**
  119231. * The component name helpfull to identify the component in the list of scene components.
  119232. */
  119233. readonly name: string;
  119234. /**
  119235. * The scene the component belongs to.
  119236. */
  119237. scene: Scene;
  119238. /**
  119239. * Creates a new instance of the component for the given scene
  119240. * @param scene Defines the scene to register the component in
  119241. */
  119242. constructor(scene: Scene);
  119243. /**
  119244. * Registers the component in a given scene
  119245. */
  119246. register(): void;
  119247. /**
  119248. * Rebuilds the elements related to this component in case of
  119249. * context lost for instance.
  119250. */
  119251. rebuild(): void;
  119252. /**
  119253. * Disposes the component and the associated ressources
  119254. */
  119255. dispose(): void;
  119256. private _gatherRenderTargets;
  119257. }
  119258. }
  119259. declare module BABYLON {
  119260. /**
  119261. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  119262. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  119263. */
  119264. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  119265. private _scene;
  119266. private _camerasToBeAttached;
  119267. /**
  119268. * ID of the sharpen post process,
  119269. */
  119270. private readonly SharpenPostProcessId;
  119271. /**
  119272. * @ignore
  119273. * ID of the image processing post process;
  119274. */
  119275. readonly ImageProcessingPostProcessId: string;
  119276. /**
  119277. * @ignore
  119278. * ID of the Fast Approximate Anti-Aliasing post process;
  119279. */
  119280. readonly FxaaPostProcessId: string;
  119281. /**
  119282. * ID of the chromatic aberration post process,
  119283. */
  119284. private readonly ChromaticAberrationPostProcessId;
  119285. /**
  119286. * ID of the grain post process
  119287. */
  119288. private readonly GrainPostProcessId;
  119289. /**
  119290. * Sharpen post process which will apply a sharpen convolution to enhance edges
  119291. */
  119292. sharpen: SharpenPostProcess;
  119293. private _sharpenEffect;
  119294. private bloom;
  119295. /**
  119296. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  119297. */
  119298. depthOfField: DepthOfFieldEffect;
  119299. /**
  119300. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  119301. */
  119302. fxaa: FxaaPostProcess;
  119303. /**
  119304. * Image post processing pass used to perform operations such as tone mapping or color grading.
  119305. */
  119306. imageProcessing: ImageProcessingPostProcess;
  119307. /**
  119308. * Chromatic aberration post process which will shift rgb colors in the image
  119309. */
  119310. chromaticAberration: ChromaticAberrationPostProcess;
  119311. private _chromaticAberrationEffect;
  119312. /**
  119313. * Grain post process which add noise to the image
  119314. */
  119315. grain: GrainPostProcess;
  119316. private _grainEffect;
  119317. /**
  119318. * Glow post process which adds a glow to emissive areas of the image
  119319. */
  119320. private _glowLayer;
  119321. /**
  119322. * Animations which can be used to tweak settings over a period of time
  119323. */
  119324. animations: Animation[];
  119325. private _imageProcessingConfigurationObserver;
  119326. private _sharpenEnabled;
  119327. private _bloomEnabled;
  119328. private _depthOfFieldEnabled;
  119329. private _depthOfFieldBlurLevel;
  119330. private _fxaaEnabled;
  119331. private _imageProcessingEnabled;
  119332. private _defaultPipelineTextureType;
  119333. private _bloomScale;
  119334. private _chromaticAberrationEnabled;
  119335. private _grainEnabled;
  119336. private _buildAllowed;
  119337. /**
  119338. * Gets active scene
  119339. */
  119340. readonly scene: Scene;
  119341. /**
  119342. * Enable or disable the sharpen process from the pipeline
  119343. */
  119344. sharpenEnabled: boolean;
  119345. private _resizeObserver;
  119346. private _hardwareScaleLevel;
  119347. private _bloomKernel;
  119348. /**
  119349. * Specifies the size of the bloom blur kernel, relative to the final output size
  119350. */
  119351. bloomKernel: number;
  119352. /**
  119353. * Specifies the weight of the bloom in the final rendering
  119354. */
  119355. private _bloomWeight;
  119356. /**
  119357. * Specifies the luma threshold for the area that will be blurred by the bloom
  119358. */
  119359. private _bloomThreshold;
  119360. private _hdr;
  119361. /**
  119362. * The strength of the bloom.
  119363. */
  119364. bloomWeight: number;
  119365. /**
  119366. * The strength of the bloom.
  119367. */
  119368. bloomThreshold: number;
  119369. /**
  119370. * The scale of the bloom, lower value will provide better performance.
  119371. */
  119372. bloomScale: number;
  119373. /**
  119374. * Enable or disable the bloom from the pipeline
  119375. */
  119376. bloomEnabled: boolean;
  119377. private _rebuildBloom;
  119378. /**
  119379. * If the depth of field is enabled.
  119380. */
  119381. depthOfFieldEnabled: boolean;
  119382. /**
  119383. * Blur level of the depth of field effect. (Higher blur will effect performance)
  119384. */
  119385. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  119386. /**
  119387. * If the anti aliasing is enabled.
  119388. */
  119389. fxaaEnabled: boolean;
  119390. private _samples;
  119391. /**
  119392. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  119393. */
  119394. samples: number;
  119395. /**
  119396. * If image processing is enabled.
  119397. */
  119398. imageProcessingEnabled: boolean;
  119399. /**
  119400. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  119401. */
  119402. glowLayerEnabled: boolean;
  119403. /**
  119404. * Gets the glow layer (or null if not defined)
  119405. */
  119406. readonly glowLayer: Nullable<GlowLayer>;
  119407. /**
  119408. * Enable or disable the chromaticAberration process from the pipeline
  119409. */
  119410. chromaticAberrationEnabled: boolean;
  119411. /**
  119412. * Enable or disable the grain process from the pipeline
  119413. */
  119414. grainEnabled: boolean;
  119415. /**
  119416. * @constructor
  119417. * @param name - The rendering pipeline name (default: "")
  119418. * @param hdr - If high dynamic range textures should be used (default: true)
  119419. * @param scene - The scene linked to this pipeline (default: the last created scene)
  119420. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  119421. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  119422. */
  119423. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  119424. /**
  119425. * Get the class name
  119426. * @returns "DefaultRenderingPipeline"
  119427. */
  119428. getClassName(): string;
  119429. /**
  119430. * Force the compilation of the entire pipeline.
  119431. */
  119432. prepare(): void;
  119433. private _hasCleared;
  119434. private _prevPostProcess;
  119435. private _prevPrevPostProcess;
  119436. private _setAutoClearAndTextureSharing;
  119437. private _depthOfFieldSceneObserver;
  119438. private _buildPipeline;
  119439. private _disposePostProcesses;
  119440. /**
  119441. * Adds a camera to the pipeline
  119442. * @param camera the camera to be added
  119443. */
  119444. addCamera(camera: Camera): void;
  119445. /**
  119446. * Removes a camera from the pipeline
  119447. * @param camera the camera to remove
  119448. */
  119449. removeCamera(camera: Camera): void;
  119450. /**
  119451. * Dispose of the pipeline and stop all post processes
  119452. */
  119453. dispose(): void;
  119454. /**
  119455. * Serialize the rendering pipeline (Used when exporting)
  119456. * @returns the serialized object
  119457. */
  119458. serialize(): any;
  119459. /**
  119460. * Parse the serialized pipeline
  119461. * @param source Source pipeline.
  119462. * @param scene The scene to load the pipeline to.
  119463. * @param rootUrl The URL of the serialized pipeline.
  119464. * @returns An instantiated pipeline from the serialized object.
  119465. */
  119466. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  119467. }
  119468. }
  119469. declare module BABYLON {
  119470. /** @hidden */
  119471. export var lensHighlightsPixelShader: {
  119472. name: string;
  119473. shader: string;
  119474. };
  119475. }
  119476. declare module BABYLON {
  119477. /** @hidden */
  119478. export var depthOfFieldPixelShader: {
  119479. name: string;
  119480. shader: string;
  119481. };
  119482. }
  119483. declare module BABYLON {
  119484. /**
  119485. * BABYLON.JS Chromatic Aberration GLSL Shader
  119486. * Author: Olivier Guyot
  119487. * Separates very slightly R, G and B colors on the edges of the screen
  119488. * Inspired by Francois Tarlier & Martins Upitis
  119489. */
  119490. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  119491. /**
  119492. * @ignore
  119493. * The chromatic aberration PostProcess id in the pipeline
  119494. */
  119495. LensChromaticAberrationEffect: string;
  119496. /**
  119497. * @ignore
  119498. * The highlights enhancing PostProcess id in the pipeline
  119499. */
  119500. HighlightsEnhancingEffect: string;
  119501. /**
  119502. * @ignore
  119503. * The depth-of-field PostProcess id in the pipeline
  119504. */
  119505. LensDepthOfFieldEffect: string;
  119506. private _scene;
  119507. private _depthTexture;
  119508. private _grainTexture;
  119509. private _chromaticAberrationPostProcess;
  119510. private _highlightsPostProcess;
  119511. private _depthOfFieldPostProcess;
  119512. private _edgeBlur;
  119513. private _grainAmount;
  119514. private _chromaticAberration;
  119515. private _distortion;
  119516. private _highlightsGain;
  119517. private _highlightsThreshold;
  119518. private _dofDistance;
  119519. private _dofAperture;
  119520. private _dofDarken;
  119521. private _dofPentagon;
  119522. private _blurNoise;
  119523. /**
  119524. * @constructor
  119525. *
  119526. * Effect parameters are as follow:
  119527. * {
  119528. * chromatic_aberration: number; // from 0 to x (1 for realism)
  119529. * edge_blur: number; // from 0 to x (1 for realism)
  119530. * distortion: number; // from 0 to x (1 for realism)
  119531. * grain_amount: number; // from 0 to 1
  119532. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  119533. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  119534. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  119535. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  119536. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  119537. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  119538. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  119539. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  119540. * }
  119541. * Note: if an effect parameter is unset, effect is disabled
  119542. *
  119543. * @param name The rendering pipeline name
  119544. * @param parameters - An object containing all parameters (see above)
  119545. * @param scene The scene linked to this pipeline
  119546. * @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)
  119547. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119548. */
  119549. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  119550. /**
  119551. * Get the class name
  119552. * @returns "LensRenderingPipeline"
  119553. */
  119554. getClassName(): string;
  119555. /**
  119556. * Gets associated scene
  119557. */
  119558. readonly scene: Scene;
  119559. /**
  119560. * Gets or sets the edge blur
  119561. */
  119562. edgeBlur: number;
  119563. /**
  119564. * Gets or sets the grain amount
  119565. */
  119566. grainAmount: number;
  119567. /**
  119568. * Gets or sets the chromatic aberration amount
  119569. */
  119570. chromaticAberration: number;
  119571. /**
  119572. * Gets or sets the depth of field aperture
  119573. */
  119574. dofAperture: number;
  119575. /**
  119576. * Gets or sets the edge distortion
  119577. */
  119578. edgeDistortion: number;
  119579. /**
  119580. * Gets or sets the depth of field distortion
  119581. */
  119582. dofDistortion: number;
  119583. /**
  119584. * Gets or sets the darken out of focus amount
  119585. */
  119586. darkenOutOfFocus: number;
  119587. /**
  119588. * Gets or sets a boolean indicating if blur noise is enabled
  119589. */
  119590. blurNoise: boolean;
  119591. /**
  119592. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  119593. */
  119594. pentagonBokeh: boolean;
  119595. /**
  119596. * Gets or sets the highlight grain amount
  119597. */
  119598. highlightsGain: number;
  119599. /**
  119600. * Gets or sets the highlight threshold
  119601. */
  119602. highlightsThreshold: number;
  119603. /**
  119604. * Sets the amount of blur at the edges
  119605. * @param amount blur amount
  119606. */
  119607. setEdgeBlur(amount: number): void;
  119608. /**
  119609. * Sets edge blur to 0
  119610. */
  119611. disableEdgeBlur(): void;
  119612. /**
  119613. * Sets the amout of grain
  119614. * @param amount Amount of grain
  119615. */
  119616. setGrainAmount(amount: number): void;
  119617. /**
  119618. * Set grain amount to 0
  119619. */
  119620. disableGrain(): void;
  119621. /**
  119622. * Sets the chromatic aberration amount
  119623. * @param amount amount of chromatic aberration
  119624. */
  119625. setChromaticAberration(amount: number): void;
  119626. /**
  119627. * Sets chromatic aberration amount to 0
  119628. */
  119629. disableChromaticAberration(): void;
  119630. /**
  119631. * Sets the EdgeDistortion amount
  119632. * @param amount amount of EdgeDistortion
  119633. */
  119634. setEdgeDistortion(amount: number): void;
  119635. /**
  119636. * Sets edge distortion to 0
  119637. */
  119638. disableEdgeDistortion(): void;
  119639. /**
  119640. * Sets the FocusDistance amount
  119641. * @param amount amount of FocusDistance
  119642. */
  119643. setFocusDistance(amount: number): void;
  119644. /**
  119645. * Disables depth of field
  119646. */
  119647. disableDepthOfField(): void;
  119648. /**
  119649. * Sets the Aperture amount
  119650. * @param amount amount of Aperture
  119651. */
  119652. setAperture(amount: number): void;
  119653. /**
  119654. * Sets the DarkenOutOfFocus amount
  119655. * @param amount amount of DarkenOutOfFocus
  119656. */
  119657. setDarkenOutOfFocus(amount: number): void;
  119658. private _pentagonBokehIsEnabled;
  119659. /**
  119660. * Creates a pentagon bokeh effect
  119661. */
  119662. enablePentagonBokeh(): void;
  119663. /**
  119664. * Disables the pentagon bokeh effect
  119665. */
  119666. disablePentagonBokeh(): void;
  119667. /**
  119668. * Enables noise blur
  119669. */
  119670. enableNoiseBlur(): void;
  119671. /**
  119672. * Disables noise blur
  119673. */
  119674. disableNoiseBlur(): void;
  119675. /**
  119676. * Sets the HighlightsGain amount
  119677. * @param amount amount of HighlightsGain
  119678. */
  119679. setHighlightsGain(amount: number): void;
  119680. /**
  119681. * Sets the HighlightsThreshold amount
  119682. * @param amount amount of HighlightsThreshold
  119683. */
  119684. setHighlightsThreshold(amount: number): void;
  119685. /**
  119686. * Disables highlights
  119687. */
  119688. disableHighlights(): void;
  119689. /**
  119690. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  119691. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  119692. */
  119693. dispose(disableDepthRender?: boolean): void;
  119694. private _createChromaticAberrationPostProcess;
  119695. private _createHighlightsPostProcess;
  119696. private _createDepthOfFieldPostProcess;
  119697. private _createGrainTexture;
  119698. }
  119699. }
  119700. declare module BABYLON {
  119701. /** @hidden */
  119702. export var ssao2PixelShader: {
  119703. name: string;
  119704. shader: string;
  119705. };
  119706. }
  119707. declare module BABYLON {
  119708. /** @hidden */
  119709. export var ssaoCombinePixelShader: {
  119710. name: string;
  119711. shader: string;
  119712. };
  119713. }
  119714. declare module BABYLON {
  119715. /**
  119716. * Render pipeline to produce ssao effect
  119717. */
  119718. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  119719. /**
  119720. * @ignore
  119721. * The PassPostProcess id in the pipeline that contains the original scene color
  119722. */
  119723. SSAOOriginalSceneColorEffect: string;
  119724. /**
  119725. * @ignore
  119726. * The SSAO PostProcess id in the pipeline
  119727. */
  119728. SSAORenderEffect: string;
  119729. /**
  119730. * @ignore
  119731. * The horizontal blur PostProcess id in the pipeline
  119732. */
  119733. SSAOBlurHRenderEffect: string;
  119734. /**
  119735. * @ignore
  119736. * The vertical blur PostProcess id in the pipeline
  119737. */
  119738. SSAOBlurVRenderEffect: string;
  119739. /**
  119740. * @ignore
  119741. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  119742. */
  119743. SSAOCombineRenderEffect: string;
  119744. /**
  119745. * The output strength of the SSAO post-process. Default value is 1.0.
  119746. */
  119747. totalStrength: number;
  119748. /**
  119749. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  119750. */
  119751. maxZ: number;
  119752. /**
  119753. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  119754. */
  119755. minZAspect: number;
  119756. private _samples;
  119757. /**
  119758. * Number of samples used for the SSAO calculations. Default value is 8
  119759. */
  119760. samples: number;
  119761. private _textureSamples;
  119762. /**
  119763. * Number of samples to use for antialiasing
  119764. */
  119765. textureSamples: number;
  119766. /**
  119767. * Ratio object used for SSAO ratio and blur ratio
  119768. */
  119769. private _ratio;
  119770. /**
  119771. * Dynamically generated sphere sampler.
  119772. */
  119773. private _sampleSphere;
  119774. /**
  119775. * Blur filter offsets
  119776. */
  119777. private _samplerOffsets;
  119778. private _expensiveBlur;
  119779. /**
  119780. * If bilateral blur should be used
  119781. */
  119782. expensiveBlur: boolean;
  119783. /**
  119784. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  119785. */
  119786. radius: number;
  119787. /**
  119788. * The base color of the SSAO post-process
  119789. * The final result is "base + ssao" between [0, 1]
  119790. */
  119791. base: number;
  119792. /**
  119793. * Support test.
  119794. */
  119795. static readonly IsSupported: boolean;
  119796. private _scene;
  119797. private _depthTexture;
  119798. private _normalTexture;
  119799. private _randomTexture;
  119800. private _originalColorPostProcess;
  119801. private _ssaoPostProcess;
  119802. private _blurHPostProcess;
  119803. private _blurVPostProcess;
  119804. private _ssaoCombinePostProcess;
  119805. private _firstUpdate;
  119806. /**
  119807. * Gets active scene
  119808. */
  119809. readonly scene: Scene;
  119810. /**
  119811. * @constructor
  119812. * @param name The rendering pipeline name
  119813. * @param scene The scene linked to this pipeline
  119814. * @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 }
  119815. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119816. */
  119817. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  119818. /**
  119819. * Get the class name
  119820. * @returns "SSAO2RenderingPipeline"
  119821. */
  119822. getClassName(): string;
  119823. /**
  119824. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  119825. */
  119826. dispose(disableGeometryBufferRenderer?: boolean): void;
  119827. private _createBlurPostProcess;
  119828. /** @hidden */
  119829. _rebuild(): void;
  119830. private _bits;
  119831. private _radicalInverse_VdC;
  119832. private _hammersley;
  119833. private _hemisphereSample_uniform;
  119834. private _generateHemisphere;
  119835. private _createSSAOPostProcess;
  119836. private _createSSAOCombinePostProcess;
  119837. private _createRandomTexture;
  119838. /**
  119839. * Serialize the rendering pipeline (Used when exporting)
  119840. * @returns the serialized object
  119841. */
  119842. serialize(): any;
  119843. /**
  119844. * Parse the serialized pipeline
  119845. * @param source Source pipeline.
  119846. * @param scene The scene to load the pipeline to.
  119847. * @param rootUrl The URL of the serialized pipeline.
  119848. * @returns An instantiated pipeline from the serialized object.
  119849. */
  119850. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  119851. }
  119852. }
  119853. declare module BABYLON {
  119854. /** @hidden */
  119855. export var ssaoPixelShader: {
  119856. name: string;
  119857. shader: string;
  119858. };
  119859. }
  119860. declare module BABYLON {
  119861. /**
  119862. * Render pipeline to produce ssao effect
  119863. */
  119864. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  119865. /**
  119866. * @ignore
  119867. * The PassPostProcess id in the pipeline that contains the original scene color
  119868. */
  119869. SSAOOriginalSceneColorEffect: string;
  119870. /**
  119871. * @ignore
  119872. * The SSAO PostProcess id in the pipeline
  119873. */
  119874. SSAORenderEffect: string;
  119875. /**
  119876. * @ignore
  119877. * The horizontal blur PostProcess id in the pipeline
  119878. */
  119879. SSAOBlurHRenderEffect: string;
  119880. /**
  119881. * @ignore
  119882. * The vertical blur PostProcess id in the pipeline
  119883. */
  119884. SSAOBlurVRenderEffect: string;
  119885. /**
  119886. * @ignore
  119887. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  119888. */
  119889. SSAOCombineRenderEffect: string;
  119890. /**
  119891. * The output strength of the SSAO post-process. Default value is 1.0.
  119892. */
  119893. totalStrength: number;
  119894. /**
  119895. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  119896. */
  119897. radius: number;
  119898. /**
  119899. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  119900. * Must not be equal to fallOff and superior to fallOff.
  119901. * Default value is 0.0075
  119902. */
  119903. area: number;
  119904. /**
  119905. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  119906. * Must not be equal to area and inferior to area.
  119907. * Default value is 0.000001
  119908. */
  119909. fallOff: number;
  119910. /**
  119911. * The base color of the SSAO post-process
  119912. * The final result is "base + ssao" between [0, 1]
  119913. */
  119914. base: number;
  119915. private _scene;
  119916. private _depthTexture;
  119917. private _randomTexture;
  119918. private _originalColorPostProcess;
  119919. private _ssaoPostProcess;
  119920. private _blurHPostProcess;
  119921. private _blurVPostProcess;
  119922. private _ssaoCombinePostProcess;
  119923. private _firstUpdate;
  119924. /**
  119925. * Gets active scene
  119926. */
  119927. readonly scene: Scene;
  119928. /**
  119929. * @constructor
  119930. * @param name - The rendering pipeline name
  119931. * @param scene - The scene linked to this pipeline
  119932. * @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 }
  119933. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  119934. */
  119935. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  119936. /**
  119937. * Get the class name
  119938. * @returns "SSAORenderingPipeline"
  119939. */
  119940. getClassName(): string;
  119941. /**
  119942. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  119943. */
  119944. dispose(disableDepthRender?: boolean): void;
  119945. private _createBlurPostProcess;
  119946. /** @hidden */
  119947. _rebuild(): void;
  119948. private _createSSAOPostProcess;
  119949. private _createSSAOCombinePostProcess;
  119950. private _createRandomTexture;
  119951. }
  119952. }
  119953. declare module BABYLON {
  119954. /** @hidden */
  119955. export var standardPixelShader: {
  119956. name: string;
  119957. shader: string;
  119958. };
  119959. }
  119960. declare module BABYLON {
  119961. /**
  119962. * Standard rendering pipeline
  119963. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  119964. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  119965. */
  119966. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  119967. /**
  119968. * Public members
  119969. */
  119970. /**
  119971. * Post-process which contains the original scene color before the pipeline applies all the effects
  119972. */
  119973. originalPostProcess: Nullable<PostProcess>;
  119974. /**
  119975. * Post-process used to down scale an image x4
  119976. */
  119977. downSampleX4PostProcess: Nullable<PostProcess>;
  119978. /**
  119979. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  119980. */
  119981. brightPassPostProcess: Nullable<PostProcess>;
  119982. /**
  119983. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  119984. */
  119985. blurHPostProcesses: PostProcess[];
  119986. /**
  119987. * Post-process array storing all the vertical blur post-processes used by the pipeline
  119988. */
  119989. blurVPostProcesses: PostProcess[];
  119990. /**
  119991. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  119992. */
  119993. textureAdderPostProcess: Nullable<PostProcess>;
  119994. /**
  119995. * Post-process used to create volumetric lighting effect
  119996. */
  119997. volumetricLightPostProcess: Nullable<PostProcess>;
  119998. /**
  119999. * Post-process used to smooth the previous volumetric light post-process on the X axis
  120000. */
  120001. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  120002. /**
  120003. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  120004. */
  120005. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  120006. /**
  120007. * Post-process used to merge the volumetric light effect and the real scene color
  120008. */
  120009. volumetricLightMergePostProces: Nullable<PostProcess>;
  120010. /**
  120011. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  120012. */
  120013. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  120014. /**
  120015. * Base post-process used to calculate the average luminance of the final image for HDR
  120016. */
  120017. luminancePostProcess: Nullable<PostProcess>;
  120018. /**
  120019. * Post-processes used to create down sample post-processes in order to get
  120020. * the average luminance of the final image for HDR
  120021. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  120022. */
  120023. luminanceDownSamplePostProcesses: PostProcess[];
  120024. /**
  120025. * Post-process used to create a HDR effect (light adaptation)
  120026. */
  120027. hdrPostProcess: Nullable<PostProcess>;
  120028. /**
  120029. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  120030. */
  120031. textureAdderFinalPostProcess: Nullable<PostProcess>;
  120032. /**
  120033. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  120034. */
  120035. lensFlareFinalPostProcess: Nullable<PostProcess>;
  120036. /**
  120037. * Post-process used to merge the final HDR post-process and the real scene color
  120038. */
  120039. hdrFinalPostProcess: Nullable<PostProcess>;
  120040. /**
  120041. * Post-process used to create a lens flare effect
  120042. */
  120043. lensFlarePostProcess: Nullable<PostProcess>;
  120044. /**
  120045. * Post-process that merges the result of the lens flare post-process and the real scene color
  120046. */
  120047. lensFlareComposePostProcess: Nullable<PostProcess>;
  120048. /**
  120049. * Post-process used to create a motion blur effect
  120050. */
  120051. motionBlurPostProcess: Nullable<PostProcess>;
  120052. /**
  120053. * Post-process used to create a depth of field effect
  120054. */
  120055. depthOfFieldPostProcess: Nullable<PostProcess>;
  120056. /**
  120057. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  120058. */
  120059. fxaaPostProcess: Nullable<FxaaPostProcess>;
  120060. /**
  120061. * Represents the brightness threshold in order to configure the illuminated surfaces
  120062. */
  120063. brightThreshold: number;
  120064. /**
  120065. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  120066. */
  120067. blurWidth: number;
  120068. /**
  120069. * Sets if the blur for highlighted surfaces must be only horizontal
  120070. */
  120071. horizontalBlur: boolean;
  120072. /**
  120073. * Gets the overall exposure used by the pipeline
  120074. */
  120075. /**
  120076. * Sets the overall exposure used by the pipeline
  120077. */
  120078. exposure: number;
  120079. /**
  120080. * Texture used typically to simulate "dirty" on camera lens
  120081. */
  120082. lensTexture: Nullable<Texture>;
  120083. /**
  120084. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  120085. */
  120086. volumetricLightCoefficient: number;
  120087. /**
  120088. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  120089. */
  120090. volumetricLightPower: number;
  120091. /**
  120092. * Used the set the blur intensity to smooth the volumetric lights
  120093. */
  120094. volumetricLightBlurScale: number;
  120095. /**
  120096. * Light (spot or directional) used to generate the volumetric lights rays
  120097. * The source light must have a shadow generate so the pipeline can get its
  120098. * depth map
  120099. */
  120100. sourceLight: Nullable<SpotLight | DirectionalLight>;
  120101. /**
  120102. * For eye adaptation, represents the minimum luminance the eye can see
  120103. */
  120104. hdrMinimumLuminance: number;
  120105. /**
  120106. * For eye adaptation, represents the decrease luminance speed
  120107. */
  120108. hdrDecreaseRate: number;
  120109. /**
  120110. * For eye adaptation, represents the increase luminance speed
  120111. */
  120112. hdrIncreaseRate: number;
  120113. /**
  120114. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  120115. */
  120116. /**
  120117. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  120118. */
  120119. hdrAutoExposure: boolean;
  120120. /**
  120121. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  120122. */
  120123. lensColorTexture: Nullable<Texture>;
  120124. /**
  120125. * The overall strengh for the lens flare effect
  120126. */
  120127. lensFlareStrength: number;
  120128. /**
  120129. * Dispersion coefficient for lens flare ghosts
  120130. */
  120131. lensFlareGhostDispersal: number;
  120132. /**
  120133. * Main lens flare halo width
  120134. */
  120135. lensFlareHaloWidth: number;
  120136. /**
  120137. * Based on the lens distortion effect, defines how much the lens flare result
  120138. * is distorted
  120139. */
  120140. lensFlareDistortionStrength: number;
  120141. /**
  120142. * Lens star texture must be used to simulate rays on the flares and is available
  120143. * in the documentation
  120144. */
  120145. lensStarTexture: Nullable<Texture>;
  120146. /**
  120147. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  120148. * flare effect by taking account of the dirt texture
  120149. */
  120150. lensFlareDirtTexture: Nullable<Texture>;
  120151. /**
  120152. * Represents the focal length for the depth of field effect
  120153. */
  120154. depthOfFieldDistance: number;
  120155. /**
  120156. * Represents the blur intensity for the blurred part of the depth of field effect
  120157. */
  120158. depthOfFieldBlurWidth: number;
  120159. /**
  120160. * Gets how much the image is blurred by the movement while using the motion blur post-process
  120161. */
  120162. /**
  120163. * Sets how much the image is blurred by the movement while using the motion blur post-process
  120164. */
  120165. motionStrength: number;
  120166. /**
  120167. * Gets wether or not the motion blur post-process is object based or screen based.
  120168. */
  120169. /**
  120170. * Sets wether or not the motion blur post-process should be object based or screen based
  120171. */
  120172. objectBasedMotionBlur: boolean;
  120173. /**
  120174. * List of animations for the pipeline (IAnimatable implementation)
  120175. */
  120176. animations: Animation[];
  120177. /**
  120178. * Private members
  120179. */
  120180. private _scene;
  120181. private _currentDepthOfFieldSource;
  120182. private _basePostProcess;
  120183. private _fixedExposure;
  120184. private _currentExposure;
  120185. private _hdrAutoExposure;
  120186. private _hdrCurrentLuminance;
  120187. private _motionStrength;
  120188. private _isObjectBasedMotionBlur;
  120189. private _floatTextureType;
  120190. private _ratio;
  120191. private _bloomEnabled;
  120192. private _depthOfFieldEnabled;
  120193. private _vlsEnabled;
  120194. private _lensFlareEnabled;
  120195. private _hdrEnabled;
  120196. private _motionBlurEnabled;
  120197. private _fxaaEnabled;
  120198. private _motionBlurSamples;
  120199. private _volumetricLightStepsCount;
  120200. private _samples;
  120201. /**
  120202. * @ignore
  120203. * Specifies if the bloom pipeline is enabled
  120204. */
  120205. BloomEnabled: boolean;
  120206. /**
  120207. * @ignore
  120208. * Specifies if the depth of field pipeline is enabed
  120209. */
  120210. DepthOfFieldEnabled: boolean;
  120211. /**
  120212. * @ignore
  120213. * Specifies if the lens flare pipeline is enabed
  120214. */
  120215. LensFlareEnabled: boolean;
  120216. /**
  120217. * @ignore
  120218. * Specifies if the HDR pipeline is enabled
  120219. */
  120220. HDREnabled: boolean;
  120221. /**
  120222. * @ignore
  120223. * Specifies if the volumetric lights scattering effect is enabled
  120224. */
  120225. VLSEnabled: boolean;
  120226. /**
  120227. * @ignore
  120228. * Specifies if the motion blur effect is enabled
  120229. */
  120230. MotionBlurEnabled: boolean;
  120231. /**
  120232. * Specifies if anti-aliasing is enabled
  120233. */
  120234. fxaaEnabled: boolean;
  120235. /**
  120236. * Specifies the number of steps used to calculate the volumetric lights
  120237. * Typically in interval [50, 200]
  120238. */
  120239. volumetricLightStepsCount: number;
  120240. /**
  120241. * Specifies the number of samples used for the motion blur effect
  120242. * Typically in interval [16, 64]
  120243. */
  120244. motionBlurSamples: number;
  120245. /**
  120246. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  120247. */
  120248. samples: number;
  120249. /**
  120250. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  120251. * @constructor
  120252. * @param name The rendering pipeline name
  120253. * @param scene The scene linked to this pipeline
  120254. * @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)
  120255. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  120256. * @param cameras The array of cameras that the rendering pipeline will be attached to
  120257. */
  120258. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  120259. private _buildPipeline;
  120260. private _createDownSampleX4PostProcess;
  120261. private _createBrightPassPostProcess;
  120262. private _createBlurPostProcesses;
  120263. private _createTextureAdderPostProcess;
  120264. private _createVolumetricLightPostProcess;
  120265. private _createLuminancePostProcesses;
  120266. private _createHdrPostProcess;
  120267. private _createLensFlarePostProcess;
  120268. private _createDepthOfFieldPostProcess;
  120269. private _createMotionBlurPostProcess;
  120270. private _getDepthTexture;
  120271. private _disposePostProcesses;
  120272. /**
  120273. * Dispose of the pipeline and stop all post processes
  120274. */
  120275. dispose(): void;
  120276. /**
  120277. * Serialize the rendering pipeline (Used when exporting)
  120278. * @returns the serialized object
  120279. */
  120280. serialize(): any;
  120281. /**
  120282. * Parse the serialized pipeline
  120283. * @param source Source pipeline.
  120284. * @param scene The scene to load the pipeline to.
  120285. * @param rootUrl The URL of the serialized pipeline.
  120286. * @returns An instantiated pipeline from the serialized object.
  120287. */
  120288. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  120289. /**
  120290. * Luminance steps
  120291. */
  120292. static LuminanceSteps: number;
  120293. }
  120294. }
  120295. declare module BABYLON {
  120296. /** @hidden */
  120297. export var tonemapPixelShader: {
  120298. name: string;
  120299. shader: string;
  120300. };
  120301. }
  120302. declare module BABYLON {
  120303. /** Defines operator used for tonemapping */
  120304. export enum TonemappingOperator {
  120305. /** Hable */
  120306. Hable = 0,
  120307. /** Reinhard */
  120308. Reinhard = 1,
  120309. /** HejiDawson */
  120310. HejiDawson = 2,
  120311. /** Photographic */
  120312. Photographic = 3
  120313. }
  120314. /**
  120315. * Defines a post process to apply tone mapping
  120316. */
  120317. export class TonemapPostProcess extends PostProcess {
  120318. private _operator;
  120319. /** Defines the required exposure adjustement */
  120320. exposureAdjustment: number;
  120321. /**
  120322. * Creates a new TonemapPostProcess
  120323. * @param name defines the name of the postprocess
  120324. * @param _operator defines the operator to use
  120325. * @param exposureAdjustment defines the required exposure adjustement
  120326. * @param camera defines the camera to use (can be null)
  120327. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  120328. * @param engine defines the hosting engine (can be ignore if camera is set)
  120329. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  120330. */
  120331. constructor(name: string, _operator: TonemappingOperator,
  120332. /** Defines the required exposure adjustement */
  120333. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  120334. }
  120335. }
  120336. declare module BABYLON {
  120337. /** @hidden */
  120338. export var depthVertexShader: {
  120339. name: string;
  120340. shader: string;
  120341. };
  120342. }
  120343. declare module BABYLON {
  120344. /** @hidden */
  120345. export var volumetricLightScatteringPixelShader: {
  120346. name: string;
  120347. shader: string;
  120348. };
  120349. }
  120350. declare module BABYLON {
  120351. /** @hidden */
  120352. export var volumetricLightScatteringPassPixelShader: {
  120353. name: string;
  120354. shader: string;
  120355. };
  120356. }
  120357. declare module BABYLON {
  120358. /**
  120359. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  120360. */
  120361. export class VolumetricLightScatteringPostProcess extends PostProcess {
  120362. private _volumetricLightScatteringPass;
  120363. private _volumetricLightScatteringRTT;
  120364. private _viewPort;
  120365. private _screenCoordinates;
  120366. private _cachedDefines;
  120367. /**
  120368. * If not undefined, the mesh position is computed from the attached node position
  120369. */
  120370. attachedNode: {
  120371. position: Vector3;
  120372. };
  120373. /**
  120374. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  120375. */
  120376. customMeshPosition: Vector3;
  120377. /**
  120378. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  120379. */
  120380. useCustomMeshPosition: boolean;
  120381. /**
  120382. * If the post-process should inverse the light scattering direction
  120383. */
  120384. invert: boolean;
  120385. /**
  120386. * The internal mesh used by the post-process
  120387. */
  120388. mesh: Mesh;
  120389. /**
  120390. * @hidden
  120391. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  120392. */
  120393. useDiffuseColor: boolean;
  120394. /**
  120395. * Array containing the excluded meshes not rendered in the internal pass
  120396. */
  120397. excludedMeshes: AbstractMesh[];
  120398. /**
  120399. * Controls the overall intensity of the post-process
  120400. */
  120401. exposure: number;
  120402. /**
  120403. * Dissipates each sample's contribution in range [0, 1]
  120404. */
  120405. decay: number;
  120406. /**
  120407. * Controls the overall intensity of each sample
  120408. */
  120409. weight: number;
  120410. /**
  120411. * Controls the density of each sample
  120412. */
  120413. density: number;
  120414. /**
  120415. * @constructor
  120416. * @param name The post-process name
  120417. * @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)
  120418. * @param camera The camera that the post-process will be attached to
  120419. * @param mesh The mesh used to create the light scattering
  120420. * @param samples The post-process quality, default 100
  120421. * @param samplingModeThe post-process filtering mode
  120422. * @param engine The babylon engine
  120423. * @param reusable If the post-process is reusable
  120424. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  120425. */
  120426. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  120427. /**
  120428. * Returns the string "VolumetricLightScatteringPostProcess"
  120429. * @returns "VolumetricLightScatteringPostProcess"
  120430. */
  120431. getClassName(): string;
  120432. private _isReady;
  120433. /**
  120434. * Sets the new light position for light scattering effect
  120435. * @param position The new custom light position
  120436. */
  120437. setCustomMeshPosition(position: Vector3): void;
  120438. /**
  120439. * Returns the light position for light scattering effect
  120440. * @return Vector3 The custom light position
  120441. */
  120442. getCustomMeshPosition(): Vector3;
  120443. /**
  120444. * Disposes the internal assets and detaches the post-process from the camera
  120445. */
  120446. dispose(camera: Camera): void;
  120447. /**
  120448. * Returns the render target texture used by the post-process
  120449. * @return the render target texture used by the post-process
  120450. */
  120451. getPass(): RenderTargetTexture;
  120452. private _meshExcluded;
  120453. private _createPass;
  120454. private _updateMeshScreenCoordinates;
  120455. /**
  120456. * Creates a default mesh for the Volumeric Light Scattering post-process
  120457. * @param name The mesh name
  120458. * @param scene The scene where to create the mesh
  120459. * @return the default mesh
  120460. */
  120461. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  120462. }
  120463. }
  120464. declare module BABYLON {
  120465. interface Scene {
  120466. /** @hidden (Backing field) */
  120467. _boundingBoxRenderer: BoundingBoxRenderer;
  120468. /** @hidden (Backing field) */
  120469. _forceShowBoundingBoxes: boolean;
  120470. /**
  120471. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  120472. */
  120473. forceShowBoundingBoxes: boolean;
  120474. /**
  120475. * Gets the bounding box renderer associated with the scene
  120476. * @returns a BoundingBoxRenderer
  120477. */
  120478. getBoundingBoxRenderer(): BoundingBoxRenderer;
  120479. }
  120480. interface AbstractMesh {
  120481. /** @hidden (Backing field) */
  120482. _showBoundingBox: boolean;
  120483. /**
  120484. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  120485. */
  120486. showBoundingBox: boolean;
  120487. }
  120488. /**
  120489. * Component responsible of rendering the bounding box of the meshes in a scene.
  120490. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  120491. */
  120492. export class BoundingBoxRenderer implements ISceneComponent {
  120493. /**
  120494. * The component name helpfull to identify the component in the list of scene components.
  120495. */
  120496. readonly name: string;
  120497. /**
  120498. * The scene the component belongs to.
  120499. */
  120500. scene: Scene;
  120501. /**
  120502. * Color of the bounding box lines placed in front of an object
  120503. */
  120504. frontColor: Color3;
  120505. /**
  120506. * Color of the bounding box lines placed behind an object
  120507. */
  120508. backColor: Color3;
  120509. /**
  120510. * Defines if the renderer should show the back lines or not
  120511. */
  120512. showBackLines: boolean;
  120513. /**
  120514. * @hidden
  120515. */
  120516. renderList: SmartArray<BoundingBox>;
  120517. private _colorShader;
  120518. private _vertexBuffers;
  120519. private _indexBuffer;
  120520. private _fillIndexBuffer;
  120521. private _fillIndexData;
  120522. /**
  120523. * Instantiates a new bounding box renderer in a scene.
  120524. * @param scene the scene the renderer renders in
  120525. */
  120526. constructor(scene: Scene);
  120527. /**
  120528. * Registers the component in a given scene
  120529. */
  120530. register(): void;
  120531. private _evaluateSubMesh;
  120532. private _activeMesh;
  120533. private _prepareRessources;
  120534. private _createIndexBuffer;
  120535. /**
  120536. * Rebuilds the elements related to this component in case of
  120537. * context lost for instance.
  120538. */
  120539. rebuild(): void;
  120540. /**
  120541. * @hidden
  120542. */
  120543. reset(): void;
  120544. /**
  120545. * Render the bounding boxes of a specific rendering group
  120546. * @param renderingGroupId defines the rendering group to render
  120547. */
  120548. render(renderingGroupId: number): void;
  120549. /**
  120550. * In case of occlusion queries, we can render the occlusion bounding box through this method
  120551. * @param mesh Define the mesh to render the occlusion bounding box for
  120552. */
  120553. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  120554. /**
  120555. * Dispose and release the resources attached to this renderer.
  120556. */
  120557. dispose(): void;
  120558. }
  120559. }
  120560. declare module BABYLON {
  120561. /** @hidden */
  120562. export var depthPixelShader: {
  120563. name: string;
  120564. shader: string;
  120565. };
  120566. }
  120567. declare module BABYLON {
  120568. /**
  120569. * This represents a depth renderer in Babylon.
  120570. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  120571. */
  120572. export class DepthRenderer {
  120573. private _scene;
  120574. private _depthMap;
  120575. private _effect;
  120576. private _cachedDefines;
  120577. private _camera;
  120578. /**
  120579. * Specifiess that the depth renderer will only be used within
  120580. * the camera it is created for.
  120581. * This can help forcing its rendering during the camera processing.
  120582. */
  120583. useOnlyInActiveCamera: boolean;
  120584. /** @hidden */
  120585. static _SceneComponentInitialization: (scene: Scene) => void;
  120586. /**
  120587. * Instantiates a depth renderer
  120588. * @param scene The scene the renderer belongs to
  120589. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  120590. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  120591. */
  120592. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  120593. /**
  120594. * Creates the depth rendering effect and checks if the effect is ready.
  120595. * @param subMesh The submesh to be used to render the depth map of
  120596. * @param useInstances If multiple world instances should be used
  120597. * @returns if the depth renderer is ready to render the depth map
  120598. */
  120599. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120600. /**
  120601. * Gets the texture which the depth map will be written to.
  120602. * @returns The depth map texture
  120603. */
  120604. getDepthMap(): RenderTargetTexture;
  120605. /**
  120606. * Disposes of the depth renderer.
  120607. */
  120608. dispose(): void;
  120609. }
  120610. }
  120611. declare module BABYLON {
  120612. interface Scene {
  120613. /** @hidden (Backing field) */
  120614. _depthRenderer: {
  120615. [id: string]: DepthRenderer;
  120616. };
  120617. /**
  120618. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  120619. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  120620. * @returns the created depth renderer
  120621. */
  120622. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  120623. /**
  120624. * Disables a depth renderer for a given camera
  120625. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  120626. */
  120627. disableDepthRenderer(camera?: Nullable<Camera>): void;
  120628. }
  120629. /**
  120630. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  120631. * in several rendering techniques.
  120632. */
  120633. export class DepthRendererSceneComponent implements ISceneComponent {
  120634. /**
  120635. * The component name helpfull to identify the component in the list of scene components.
  120636. */
  120637. readonly name: string;
  120638. /**
  120639. * The scene the component belongs to.
  120640. */
  120641. scene: Scene;
  120642. /**
  120643. * Creates a new instance of the component for the given scene
  120644. * @param scene Defines the scene to register the component in
  120645. */
  120646. constructor(scene: Scene);
  120647. /**
  120648. * Registers the component in a given scene
  120649. */
  120650. register(): void;
  120651. /**
  120652. * Rebuilds the elements related to this component in case of
  120653. * context lost for instance.
  120654. */
  120655. rebuild(): void;
  120656. /**
  120657. * Disposes the component and the associated ressources
  120658. */
  120659. dispose(): void;
  120660. private _gatherRenderTargets;
  120661. private _gatherActiveCameraRenderTargets;
  120662. }
  120663. }
  120664. declare module BABYLON {
  120665. /** @hidden */
  120666. export var outlinePixelShader: {
  120667. name: string;
  120668. shader: string;
  120669. };
  120670. }
  120671. declare module BABYLON {
  120672. /** @hidden */
  120673. export var outlineVertexShader: {
  120674. name: string;
  120675. shader: string;
  120676. };
  120677. }
  120678. declare module BABYLON {
  120679. interface Scene {
  120680. /** @hidden */
  120681. _outlineRenderer: OutlineRenderer;
  120682. /**
  120683. * Gets the outline renderer associated with the scene
  120684. * @returns a OutlineRenderer
  120685. */
  120686. getOutlineRenderer(): OutlineRenderer;
  120687. }
  120688. interface AbstractMesh {
  120689. /** @hidden (Backing field) */
  120690. _renderOutline: boolean;
  120691. /**
  120692. * Gets or sets a boolean indicating if the outline must be rendered as well
  120693. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  120694. */
  120695. renderOutline: boolean;
  120696. /** @hidden (Backing field) */
  120697. _renderOverlay: boolean;
  120698. /**
  120699. * Gets or sets a boolean indicating if the overlay must be rendered as well
  120700. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  120701. */
  120702. renderOverlay: boolean;
  120703. }
  120704. /**
  120705. * This class is responsible to draw bothe outline/overlay of meshes.
  120706. * It should not be used directly but through the available method on mesh.
  120707. */
  120708. export class OutlineRenderer implements ISceneComponent {
  120709. /**
  120710. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  120711. */
  120712. private static _StencilReference;
  120713. /**
  120714. * The name of the component. Each component must have a unique name.
  120715. */
  120716. name: string;
  120717. /**
  120718. * The scene the component belongs to.
  120719. */
  120720. scene: Scene;
  120721. /**
  120722. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  120723. */
  120724. zOffset: number;
  120725. private _engine;
  120726. private _effect;
  120727. private _cachedDefines;
  120728. private _savedDepthWrite;
  120729. /**
  120730. * Instantiates a new outline renderer. (There could be only one per scene).
  120731. * @param scene Defines the scene it belongs to
  120732. */
  120733. constructor(scene: Scene);
  120734. /**
  120735. * Register the component to one instance of a scene.
  120736. */
  120737. register(): void;
  120738. /**
  120739. * Rebuilds the elements related to this component in case of
  120740. * context lost for instance.
  120741. */
  120742. rebuild(): void;
  120743. /**
  120744. * Disposes the component and the associated ressources.
  120745. */
  120746. dispose(): void;
  120747. /**
  120748. * Renders the outline in the canvas.
  120749. * @param subMesh Defines the sumesh to render
  120750. * @param batch Defines the batch of meshes in case of instances
  120751. * @param useOverlay Defines if the rendering is for the overlay or the outline
  120752. */
  120753. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  120754. /**
  120755. * Returns whether or not the outline renderer is ready for a given submesh.
  120756. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  120757. * @param subMesh Defines the submesh to check readyness for
  120758. * @param useInstances Defines wheter wee are trying to render instances or not
  120759. * @returns true if ready otherwise false
  120760. */
  120761. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120762. private _beforeRenderingMesh;
  120763. private _afterRenderingMesh;
  120764. }
  120765. }
  120766. declare module BABYLON {
  120767. /**
  120768. * Defines the list of states available for a task inside a AssetsManager
  120769. */
  120770. export enum AssetTaskState {
  120771. /**
  120772. * Initialization
  120773. */
  120774. INIT = 0,
  120775. /**
  120776. * Running
  120777. */
  120778. RUNNING = 1,
  120779. /**
  120780. * Done
  120781. */
  120782. DONE = 2,
  120783. /**
  120784. * Error
  120785. */
  120786. ERROR = 3
  120787. }
  120788. /**
  120789. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  120790. */
  120791. export abstract class AbstractAssetTask {
  120792. /**
  120793. * Task name
  120794. */ name: string;
  120795. /**
  120796. * Callback called when the task is successful
  120797. */
  120798. onSuccess: (task: any) => void;
  120799. /**
  120800. * Callback called when the task is not successful
  120801. */
  120802. onError: (task: any, message?: string, exception?: any) => void;
  120803. /**
  120804. * Creates a new AssetsManager
  120805. * @param name defines the name of the task
  120806. */
  120807. constructor(
  120808. /**
  120809. * Task name
  120810. */ name: string);
  120811. private _isCompleted;
  120812. private _taskState;
  120813. private _errorObject;
  120814. /**
  120815. * Get if the task is completed
  120816. */
  120817. readonly isCompleted: boolean;
  120818. /**
  120819. * Gets the current state of the task
  120820. */
  120821. readonly taskState: AssetTaskState;
  120822. /**
  120823. * Gets the current error object (if task is in error)
  120824. */
  120825. readonly errorObject: {
  120826. message?: string;
  120827. exception?: any;
  120828. };
  120829. /**
  120830. * Internal only
  120831. * @hidden
  120832. */
  120833. _setErrorObject(message?: string, exception?: any): void;
  120834. /**
  120835. * Execute the current task
  120836. * @param scene defines the scene where you want your assets to be loaded
  120837. * @param onSuccess is a callback called when the task is successfully executed
  120838. * @param onError is a callback called if an error occurs
  120839. */
  120840. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120841. /**
  120842. * Execute the current task
  120843. * @param scene defines the scene where you want your assets to be loaded
  120844. * @param onSuccess is a callback called when the task is successfully executed
  120845. * @param onError is a callback called if an error occurs
  120846. */
  120847. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120848. /**
  120849. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  120850. * This can be used with failed tasks that have the reason for failure fixed.
  120851. */
  120852. reset(): void;
  120853. private onErrorCallback;
  120854. private onDoneCallback;
  120855. }
  120856. /**
  120857. * Define the interface used by progress events raised during assets loading
  120858. */
  120859. export interface IAssetsProgressEvent {
  120860. /**
  120861. * Defines the number of remaining tasks to process
  120862. */
  120863. remainingCount: number;
  120864. /**
  120865. * Defines the total number of tasks
  120866. */
  120867. totalCount: number;
  120868. /**
  120869. * Defines the task that was just processed
  120870. */
  120871. task: AbstractAssetTask;
  120872. }
  120873. /**
  120874. * Class used to share progress information about assets loading
  120875. */
  120876. export class AssetsProgressEvent implements IAssetsProgressEvent {
  120877. /**
  120878. * Defines the number of remaining tasks to process
  120879. */
  120880. remainingCount: number;
  120881. /**
  120882. * Defines the total number of tasks
  120883. */
  120884. totalCount: number;
  120885. /**
  120886. * Defines the task that was just processed
  120887. */
  120888. task: AbstractAssetTask;
  120889. /**
  120890. * Creates a AssetsProgressEvent
  120891. * @param remainingCount defines the number of remaining tasks to process
  120892. * @param totalCount defines the total number of tasks
  120893. * @param task defines the task that was just processed
  120894. */
  120895. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  120896. }
  120897. /**
  120898. * Define a task used by AssetsManager to load meshes
  120899. */
  120900. export class MeshAssetTask extends AbstractAssetTask {
  120901. /**
  120902. * Defines the name of the task
  120903. */
  120904. name: string;
  120905. /**
  120906. * Defines the list of mesh's names you want to load
  120907. */
  120908. meshesNames: any;
  120909. /**
  120910. * Defines the root url to use as a base to load your meshes and associated resources
  120911. */
  120912. rootUrl: string;
  120913. /**
  120914. * Defines the filename of the scene to load from
  120915. */
  120916. sceneFilename: string;
  120917. /**
  120918. * Gets the list of loaded meshes
  120919. */
  120920. loadedMeshes: Array<AbstractMesh>;
  120921. /**
  120922. * Gets the list of loaded particle systems
  120923. */
  120924. loadedParticleSystems: Array<IParticleSystem>;
  120925. /**
  120926. * Gets the list of loaded skeletons
  120927. */
  120928. loadedSkeletons: Array<Skeleton>;
  120929. /**
  120930. * Gets the list of loaded animation groups
  120931. */
  120932. loadedAnimationGroups: Array<AnimationGroup>;
  120933. /**
  120934. * Callback called when the task is successful
  120935. */
  120936. onSuccess: (task: MeshAssetTask) => void;
  120937. /**
  120938. * Callback called when the task is successful
  120939. */
  120940. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  120941. /**
  120942. * Creates a new MeshAssetTask
  120943. * @param name defines the name of the task
  120944. * @param meshesNames defines the list of mesh's names you want to load
  120945. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  120946. * @param sceneFilename defines the filename of the scene to load from
  120947. */
  120948. constructor(
  120949. /**
  120950. * Defines the name of the task
  120951. */
  120952. name: string,
  120953. /**
  120954. * Defines the list of mesh's names you want to load
  120955. */
  120956. meshesNames: any,
  120957. /**
  120958. * Defines the root url to use as a base to load your meshes and associated resources
  120959. */
  120960. rootUrl: string,
  120961. /**
  120962. * Defines the filename of the scene to load from
  120963. */
  120964. sceneFilename: string);
  120965. /**
  120966. * Execute the current task
  120967. * @param scene defines the scene where you want your assets to be loaded
  120968. * @param onSuccess is a callback called when the task is successfully executed
  120969. * @param onError is a callback called if an error occurs
  120970. */
  120971. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120972. }
  120973. /**
  120974. * Define a task used by AssetsManager to load text content
  120975. */
  120976. export class TextFileAssetTask extends AbstractAssetTask {
  120977. /**
  120978. * Defines the name of the task
  120979. */
  120980. name: string;
  120981. /**
  120982. * Defines the location of the file to load
  120983. */
  120984. url: string;
  120985. /**
  120986. * Gets the loaded text string
  120987. */
  120988. text: string;
  120989. /**
  120990. * Callback called when the task is successful
  120991. */
  120992. onSuccess: (task: TextFileAssetTask) => void;
  120993. /**
  120994. * Callback called when the task is successful
  120995. */
  120996. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  120997. /**
  120998. * Creates a new TextFileAssetTask object
  120999. * @param name defines the name of the task
  121000. * @param url defines the location of the file to load
  121001. */
  121002. constructor(
  121003. /**
  121004. * Defines the name of the task
  121005. */
  121006. name: string,
  121007. /**
  121008. * Defines the location of the file to load
  121009. */
  121010. url: string);
  121011. /**
  121012. * Execute the current task
  121013. * @param scene defines the scene where you want your assets to be loaded
  121014. * @param onSuccess is a callback called when the task is successfully executed
  121015. * @param onError is a callback called if an error occurs
  121016. */
  121017. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121018. }
  121019. /**
  121020. * Define a task used by AssetsManager to load binary data
  121021. */
  121022. export class BinaryFileAssetTask extends AbstractAssetTask {
  121023. /**
  121024. * Defines the name of the task
  121025. */
  121026. name: string;
  121027. /**
  121028. * Defines the location of the file to load
  121029. */
  121030. url: string;
  121031. /**
  121032. * Gets the lodaded data (as an array buffer)
  121033. */
  121034. data: ArrayBuffer;
  121035. /**
  121036. * Callback called when the task is successful
  121037. */
  121038. onSuccess: (task: BinaryFileAssetTask) => void;
  121039. /**
  121040. * Callback called when the task is successful
  121041. */
  121042. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  121043. /**
  121044. * Creates a new BinaryFileAssetTask object
  121045. * @param name defines the name of the new task
  121046. * @param url defines the location of the file to load
  121047. */
  121048. constructor(
  121049. /**
  121050. * Defines the name of the task
  121051. */
  121052. name: string,
  121053. /**
  121054. * Defines the location of the file to load
  121055. */
  121056. url: string);
  121057. /**
  121058. * Execute the current task
  121059. * @param scene defines the scene where you want your assets to be loaded
  121060. * @param onSuccess is a callback called when the task is successfully executed
  121061. * @param onError is a callback called if an error occurs
  121062. */
  121063. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121064. }
  121065. /**
  121066. * Define a task used by AssetsManager to load images
  121067. */
  121068. export class ImageAssetTask extends AbstractAssetTask {
  121069. /**
  121070. * Defines the name of the task
  121071. */
  121072. name: string;
  121073. /**
  121074. * Defines the location of the image to load
  121075. */
  121076. url: string;
  121077. /**
  121078. * Gets the loaded images
  121079. */
  121080. image: HTMLImageElement;
  121081. /**
  121082. * Callback called when the task is successful
  121083. */
  121084. onSuccess: (task: ImageAssetTask) => void;
  121085. /**
  121086. * Callback called when the task is successful
  121087. */
  121088. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  121089. /**
  121090. * Creates a new ImageAssetTask
  121091. * @param name defines the name of the task
  121092. * @param url defines the location of the image to load
  121093. */
  121094. constructor(
  121095. /**
  121096. * Defines the name of the task
  121097. */
  121098. name: string,
  121099. /**
  121100. * Defines the location of the image to load
  121101. */
  121102. url: string);
  121103. /**
  121104. * Execute the current task
  121105. * @param scene defines the scene where you want your assets to be loaded
  121106. * @param onSuccess is a callback called when the task is successfully executed
  121107. * @param onError is a callback called if an error occurs
  121108. */
  121109. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121110. }
  121111. /**
  121112. * Defines the interface used by texture loading tasks
  121113. */
  121114. export interface ITextureAssetTask<TEX extends BaseTexture> {
  121115. /**
  121116. * Gets the loaded texture
  121117. */
  121118. texture: TEX;
  121119. }
  121120. /**
  121121. * Define a task used by AssetsManager to load 2D textures
  121122. */
  121123. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  121124. /**
  121125. * Defines the name of the task
  121126. */
  121127. name: string;
  121128. /**
  121129. * Defines the location of the file to load
  121130. */
  121131. url: string;
  121132. /**
  121133. * Defines if mipmap should not be generated (default is false)
  121134. */
  121135. noMipmap?: boolean | undefined;
  121136. /**
  121137. * Defines if texture must be inverted on Y axis (default is false)
  121138. */
  121139. invertY?: boolean | undefined;
  121140. /**
  121141. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  121142. */
  121143. samplingMode: number;
  121144. /**
  121145. * Gets the loaded texture
  121146. */
  121147. texture: Texture;
  121148. /**
  121149. * Callback called when the task is successful
  121150. */
  121151. onSuccess: (task: TextureAssetTask) => void;
  121152. /**
  121153. * Callback called when the task is successful
  121154. */
  121155. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  121156. /**
  121157. * Creates a new TextureAssetTask object
  121158. * @param name defines the name of the task
  121159. * @param url defines the location of the file to load
  121160. * @param noMipmap defines if mipmap should not be generated (default is false)
  121161. * @param invertY defines if texture must be inverted on Y axis (default is false)
  121162. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  121163. */
  121164. constructor(
  121165. /**
  121166. * Defines the name of the task
  121167. */
  121168. name: string,
  121169. /**
  121170. * Defines the location of the file to load
  121171. */
  121172. url: string,
  121173. /**
  121174. * Defines if mipmap should not be generated (default is false)
  121175. */
  121176. noMipmap?: boolean | undefined,
  121177. /**
  121178. * Defines if texture must be inverted on Y axis (default is false)
  121179. */
  121180. invertY?: boolean | undefined,
  121181. /**
  121182. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  121183. */
  121184. samplingMode?: number);
  121185. /**
  121186. * Execute the current task
  121187. * @param scene defines the scene where you want your assets to be loaded
  121188. * @param onSuccess is a callback called when the task is successfully executed
  121189. * @param onError is a callback called if an error occurs
  121190. */
  121191. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121192. }
  121193. /**
  121194. * Define a task used by AssetsManager to load cube textures
  121195. */
  121196. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  121197. /**
  121198. * Defines the name of the task
  121199. */
  121200. name: string;
  121201. /**
  121202. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  121203. */
  121204. url: string;
  121205. /**
  121206. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  121207. */
  121208. extensions?: string[] | undefined;
  121209. /**
  121210. * Defines if mipmaps should not be generated (default is false)
  121211. */
  121212. noMipmap?: boolean | undefined;
  121213. /**
  121214. * Defines the explicit list of files (undefined by default)
  121215. */
  121216. files?: string[] | undefined;
  121217. /**
  121218. * Gets the loaded texture
  121219. */
  121220. texture: CubeTexture;
  121221. /**
  121222. * Callback called when the task is successful
  121223. */
  121224. onSuccess: (task: CubeTextureAssetTask) => void;
  121225. /**
  121226. * Callback called when the task is successful
  121227. */
  121228. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  121229. /**
  121230. * Creates a new CubeTextureAssetTask
  121231. * @param name defines the name of the task
  121232. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  121233. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  121234. * @param noMipmap defines if mipmaps should not be generated (default is false)
  121235. * @param files defines the explicit list of files (undefined by default)
  121236. */
  121237. constructor(
  121238. /**
  121239. * Defines the name of the task
  121240. */
  121241. name: string,
  121242. /**
  121243. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  121244. */
  121245. url: string,
  121246. /**
  121247. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  121248. */
  121249. extensions?: string[] | undefined,
  121250. /**
  121251. * Defines if mipmaps should not be generated (default is false)
  121252. */
  121253. noMipmap?: boolean | undefined,
  121254. /**
  121255. * Defines the explicit list of files (undefined by default)
  121256. */
  121257. files?: string[] | undefined);
  121258. /**
  121259. * Execute the current task
  121260. * @param scene defines the scene where you want your assets to be loaded
  121261. * @param onSuccess is a callback called when the task is successfully executed
  121262. * @param onError is a callback called if an error occurs
  121263. */
  121264. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121265. }
  121266. /**
  121267. * Define a task used by AssetsManager to load HDR cube textures
  121268. */
  121269. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  121270. /**
  121271. * Defines the name of the task
  121272. */
  121273. name: string;
  121274. /**
  121275. * Defines the location of the file to load
  121276. */
  121277. url: string;
  121278. /**
  121279. * Defines the desired size (the more it increases the longer the generation will be)
  121280. */
  121281. size: number;
  121282. /**
  121283. * Defines if mipmaps should not be generated (default is false)
  121284. */
  121285. noMipmap: boolean;
  121286. /**
  121287. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  121288. */
  121289. generateHarmonics: boolean;
  121290. /**
  121291. * 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)
  121292. */
  121293. gammaSpace: boolean;
  121294. /**
  121295. * Internal Use Only
  121296. */
  121297. reserved: boolean;
  121298. /**
  121299. * Gets the loaded texture
  121300. */
  121301. texture: HDRCubeTexture;
  121302. /**
  121303. * Callback called when the task is successful
  121304. */
  121305. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  121306. /**
  121307. * Callback called when the task is successful
  121308. */
  121309. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  121310. /**
  121311. * Creates a new HDRCubeTextureAssetTask object
  121312. * @param name defines the name of the task
  121313. * @param url defines the location of the file to load
  121314. * @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.
  121315. * @param noMipmap defines if mipmaps should not be generated (default is false)
  121316. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  121317. * @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)
  121318. * @param reserved Internal use only
  121319. */
  121320. constructor(
  121321. /**
  121322. * Defines the name of the task
  121323. */
  121324. name: string,
  121325. /**
  121326. * Defines the location of the file to load
  121327. */
  121328. url: string,
  121329. /**
  121330. * Defines the desired size (the more it increases the longer the generation will be)
  121331. */
  121332. size: number,
  121333. /**
  121334. * Defines if mipmaps should not be generated (default is false)
  121335. */
  121336. noMipmap?: boolean,
  121337. /**
  121338. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  121339. */
  121340. generateHarmonics?: boolean,
  121341. /**
  121342. * 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)
  121343. */
  121344. gammaSpace?: boolean,
  121345. /**
  121346. * Internal Use Only
  121347. */
  121348. reserved?: boolean);
  121349. /**
  121350. * Execute the current task
  121351. * @param scene defines the scene where you want your assets to be loaded
  121352. * @param onSuccess is a callback called when the task is successfully executed
  121353. * @param onError is a callback called if an error occurs
  121354. */
  121355. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121356. }
  121357. /**
  121358. * Define a task used by AssetsManager to load Equirectangular cube textures
  121359. */
  121360. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  121361. /**
  121362. * Defines the name of the task
  121363. */
  121364. name: string;
  121365. /**
  121366. * Defines the location of the file to load
  121367. */
  121368. url: string;
  121369. /**
  121370. * Defines the desired size (the more it increases the longer the generation will be)
  121371. */
  121372. size: number;
  121373. /**
  121374. * Defines if mipmaps should not be generated (default is false)
  121375. */
  121376. noMipmap: boolean;
  121377. /**
  121378. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  121379. * but the standard material would require them in Gamma space) (default is true)
  121380. */
  121381. gammaSpace: boolean;
  121382. /**
  121383. * Gets the loaded texture
  121384. */
  121385. texture: EquiRectangularCubeTexture;
  121386. /**
  121387. * Callback called when the task is successful
  121388. */
  121389. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  121390. /**
  121391. * Callback called when the task is successful
  121392. */
  121393. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  121394. /**
  121395. * Creates a new EquiRectangularCubeTextureAssetTask object
  121396. * @param name defines the name of the task
  121397. * @param url defines the location of the file to load
  121398. * @param size defines the desired size (the more it increases the longer the generation will be)
  121399. * If the size is omitted this implies you are using a preprocessed cubemap.
  121400. * @param noMipmap defines if mipmaps should not be generated (default is false)
  121401. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  121402. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  121403. * (default is true)
  121404. */
  121405. constructor(
  121406. /**
  121407. * Defines the name of the task
  121408. */
  121409. name: string,
  121410. /**
  121411. * Defines the location of the file to load
  121412. */
  121413. url: string,
  121414. /**
  121415. * Defines the desired size (the more it increases the longer the generation will be)
  121416. */
  121417. size: number,
  121418. /**
  121419. * Defines if mipmaps should not be generated (default is false)
  121420. */
  121421. noMipmap?: boolean,
  121422. /**
  121423. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  121424. * but the standard material would require them in Gamma space) (default is true)
  121425. */
  121426. gammaSpace?: boolean);
  121427. /**
  121428. * Execute the current task
  121429. * @param scene defines the scene where you want your assets to be loaded
  121430. * @param onSuccess is a callback called when the task is successfully executed
  121431. * @param onError is a callback called if an error occurs
  121432. */
  121433. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121434. }
  121435. /**
  121436. * This class can be used to easily import assets into a scene
  121437. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  121438. */
  121439. export class AssetsManager {
  121440. private _scene;
  121441. private _isLoading;
  121442. protected _tasks: AbstractAssetTask[];
  121443. protected _waitingTasksCount: number;
  121444. protected _totalTasksCount: number;
  121445. /**
  121446. * Callback called when all tasks are processed
  121447. */
  121448. onFinish: (tasks: AbstractAssetTask[]) => void;
  121449. /**
  121450. * Callback called when a task is successful
  121451. */
  121452. onTaskSuccess: (task: AbstractAssetTask) => void;
  121453. /**
  121454. * Callback called when a task had an error
  121455. */
  121456. onTaskError: (task: AbstractAssetTask) => void;
  121457. /**
  121458. * Callback called when a task is done (whatever the result is)
  121459. */
  121460. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  121461. /**
  121462. * Observable called when all tasks are processed
  121463. */
  121464. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  121465. /**
  121466. * Observable called when a task had an error
  121467. */
  121468. onTaskErrorObservable: Observable<AbstractAssetTask>;
  121469. /**
  121470. * Observable called when all tasks were executed
  121471. */
  121472. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  121473. /**
  121474. * Observable called when a task is done (whatever the result is)
  121475. */
  121476. onProgressObservable: Observable<IAssetsProgressEvent>;
  121477. /**
  121478. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  121479. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121480. */
  121481. useDefaultLoadingScreen: boolean;
  121482. /**
  121483. * Creates a new AssetsManager
  121484. * @param scene defines the scene to work on
  121485. */
  121486. constructor(scene: Scene);
  121487. /**
  121488. * Add a MeshAssetTask to the list of active tasks
  121489. * @param taskName defines the name of the new task
  121490. * @param meshesNames defines the name of meshes to load
  121491. * @param rootUrl defines the root url to use to locate files
  121492. * @param sceneFilename defines the filename of the scene file
  121493. * @returns a new MeshAssetTask object
  121494. */
  121495. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  121496. /**
  121497. * Add a TextFileAssetTask to the list of active tasks
  121498. * @param taskName defines the name of the new task
  121499. * @param url defines the url of the file to load
  121500. * @returns a new TextFileAssetTask object
  121501. */
  121502. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  121503. /**
  121504. * Add a BinaryFileAssetTask to the list of active tasks
  121505. * @param taskName defines the name of the new task
  121506. * @param url defines the url of the file to load
  121507. * @returns a new BinaryFileAssetTask object
  121508. */
  121509. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  121510. /**
  121511. * Add a ImageAssetTask to the list of active tasks
  121512. * @param taskName defines the name of the new task
  121513. * @param url defines the url of the file to load
  121514. * @returns a new ImageAssetTask object
  121515. */
  121516. addImageTask(taskName: string, url: string): ImageAssetTask;
  121517. /**
  121518. * Add a TextureAssetTask to the list of active tasks
  121519. * @param taskName defines the name of the new task
  121520. * @param url defines the url of the file to load
  121521. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121522. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  121523. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  121524. * @returns a new TextureAssetTask object
  121525. */
  121526. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  121527. /**
  121528. * Add a CubeTextureAssetTask to the list of active tasks
  121529. * @param taskName defines the name of the new task
  121530. * @param url defines the url of the file to load
  121531. * @param extensions defines the extension to use to load the cube map (can be null)
  121532. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121533. * @param files defines the list of files to load (can be null)
  121534. * @returns a new CubeTextureAssetTask object
  121535. */
  121536. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  121537. /**
  121538. *
  121539. * Add a HDRCubeTextureAssetTask to the list of active tasks
  121540. * @param taskName defines the name of the new task
  121541. * @param url defines the url of the file to load
  121542. * @param size defines the size you want for the cubemap (can be null)
  121543. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121544. * @param generateHarmonics defines if you want to automatically generate (true by default)
  121545. * @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)
  121546. * @param reserved Internal use only
  121547. * @returns a new HDRCubeTextureAssetTask object
  121548. */
  121549. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  121550. /**
  121551. *
  121552. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  121553. * @param taskName defines the name of the new task
  121554. * @param url defines the url of the file to load
  121555. * @param size defines the size you want for the cubemap (can be null)
  121556. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121557. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  121558. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  121559. * @returns a new EquiRectangularCubeTextureAssetTask object
  121560. */
  121561. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  121562. /**
  121563. * Remove a task from the assets manager.
  121564. * @param task the task to remove
  121565. */
  121566. removeTask(task: AbstractAssetTask): void;
  121567. private _decreaseWaitingTasksCount;
  121568. private _runTask;
  121569. /**
  121570. * Reset the AssetsManager and remove all tasks
  121571. * @return the current instance of the AssetsManager
  121572. */
  121573. reset(): AssetsManager;
  121574. /**
  121575. * Start the loading process
  121576. * @return the current instance of the AssetsManager
  121577. */
  121578. load(): AssetsManager;
  121579. /**
  121580. * Start the loading process as an async operation
  121581. * @return a promise returning the list of failed tasks
  121582. */
  121583. loadAsync(): Promise<void>;
  121584. }
  121585. }
  121586. declare module BABYLON {
  121587. /**
  121588. * Wrapper class for promise with external resolve and reject.
  121589. */
  121590. export class Deferred<T> {
  121591. /**
  121592. * The promise associated with this deferred object.
  121593. */
  121594. readonly promise: Promise<T>;
  121595. private _resolve;
  121596. private _reject;
  121597. /**
  121598. * The resolve method of the promise associated with this deferred object.
  121599. */
  121600. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  121601. /**
  121602. * The reject method of the promise associated with this deferred object.
  121603. */
  121604. readonly reject: (reason?: any) => void;
  121605. /**
  121606. * Constructor for this deferred object.
  121607. */
  121608. constructor();
  121609. }
  121610. }
  121611. declare module BABYLON {
  121612. /**
  121613. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  121614. */
  121615. export class MeshExploder {
  121616. private _centerMesh;
  121617. private _meshes;
  121618. private _meshesOrigins;
  121619. private _toCenterVectors;
  121620. private _scaledDirection;
  121621. private _newPosition;
  121622. private _centerPosition;
  121623. /**
  121624. * Explodes meshes from a center mesh.
  121625. * @param meshes The meshes to explode.
  121626. * @param centerMesh The mesh to be center of explosion.
  121627. */
  121628. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  121629. private _setCenterMesh;
  121630. /**
  121631. * Get class name
  121632. * @returns "MeshExploder"
  121633. */
  121634. getClassName(): string;
  121635. /**
  121636. * "Exploded meshes"
  121637. * @returns Array of meshes with the centerMesh at index 0.
  121638. */
  121639. getMeshes(): Array<Mesh>;
  121640. /**
  121641. * Explodes meshes giving a specific direction
  121642. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  121643. */
  121644. explode(direction?: number): void;
  121645. }
  121646. }
  121647. declare module BABYLON {
  121648. /**
  121649. * Class used to help managing file picking and drag'n'drop
  121650. */
  121651. export class FilesInput {
  121652. /**
  121653. * List of files ready to be loaded
  121654. */
  121655. static readonly FilesToLoad: {
  121656. [key: string]: File;
  121657. };
  121658. /**
  121659. * Callback called when a file is processed
  121660. */
  121661. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  121662. private _engine;
  121663. private _currentScene;
  121664. private _sceneLoadedCallback;
  121665. private _progressCallback;
  121666. private _additionalRenderLoopLogicCallback;
  121667. private _textureLoadingCallback;
  121668. private _startingProcessingFilesCallback;
  121669. private _onReloadCallback;
  121670. private _errorCallback;
  121671. private _elementToMonitor;
  121672. private _sceneFileToLoad;
  121673. private _filesToLoad;
  121674. /**
  121675. * Creates a new FilesInput
  121676. * @param engine defines the rendering engine
  121677. * @param scene defines the hosting scene
  121678. * @param sceneLoadedCallback callback called when scene is loaded
  121679. * @param progressCallback callback called to track progress
  121680. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  121681. * @param textureLoadingCallback callback called when a texture is loading
  121682. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  121683. * @param onReloadCallback callback called when a reload is requested
  121684. * @param errorCallback callback call if an error occurs
  121685. */
  121686. 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);
  121687. private _dragEnterHandler;
  121688. private _dragOverHandler;
  121689. private _dropHandler;
  121690. /**
  121691. * Calls this function to listen to drag'n'drop events on a specific DOM element
  121692. * @param elementToMonitor defines the DOM element to track
  121693. */
  121694. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  121695. /**
  121696. * Release all associated resources
  121697. */
  121698. dispose(): void;
  121699. private renderFunction;
  121700. private drag;
  121701. private drop;
  121702. private _traverseFolder;
  121703. private _processFiles;
  121704. /**
  121705. * Load files from a drop event
  121706. * @param event defines the drop event to use as source
  121707. */
  121708. loadFiles(event: any): void;
  121709. private _processReload;
  121710. /**
  121711. * Reload the current scene from the loaded files
  121712. */
  121713. reload(): void;
  121714. }
  121715. }
  121716. declare module BABYLON {
  121717. /**
  121718. * Defines the root class used to create scene optimization to use with SceneOptimizer
  121719. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121720. */
  121721. export class SceneOptimization {
  121722. /**
  121723. * Defines the priority of this optimization (0 by default which means first in the list)
  121724. */
  121725. priority: number;
  121726. /**
  121727. * Gets a string describing the action executed by the current optimization
  121728. * @returns description string
  121729. */
  121730. getDescription(): string;
  121731. /**
  121732. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121733. * @param scene defines the current scene where to apply this optimization
  121734. * @param optimizer defines the current optimizer
  121735. * @returns true if everything that can be done was applied
  121736. */
  121737. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121738. /**
  121739. * Creates the SceneOptimization object
  121740. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121741. * @param desc defines the description associated with the optimization
  121742. */
  121743. constructor(
  121744. /**
  121745. * Defines the priority of this optimization (0 by default which means first in the list)
  121746. */
  121747. priority?: number);
  121748. }
  121749. /**
  121750. * Defines an optimization used to reduce the size of render target textures
  121751. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121752. */
  121753. export class TextureOptimization extends SceneOptimization {
  121754. /**
  121755. * Defines the priority of this optimization (0 by default which means first in the list)
  121756. */
  121757. priority: number;
  121758. /**
  121759. * 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
  121760. */
  121761. maximumSize: number;
  121762. /**
  121763. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  121764. */
  121765. step: number;
  121766. /**
  121767. * Gets a string describing the action executed by the current optimization
  121768. * @returns description string
  121769. */
  121770. getDescription(): string;
  121771. /**
  121772. * Creates the TextureOptimization object
  121773. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121774. * @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
  121775. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  121776. */
  121777. constructor(
  121778. /**
  121779. * Defines the priority of this optimization (0 by default which means first in the list)
  121780. */
  121781. priority?: number,
  121782. /**
  121783. * 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
  121784. */
  121785. maximumSize?: number,
  121786. /**
  121787. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  121788. */
  121789. step?: number);
  121790. /**
  121791. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121792. * @param scene defines the current scene where to apply this optimization
  121793. * @param optimizer defines the current optimizer
  121794. * @returns true if everything that can be done was applied
  121795. */
  121796. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121797. }
  121798. /**
  121799. * Defines an optimization used to increase or decrease the rendering resolution
  121800. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121801. */
  121802. export class HardwareScalingOptimization extends SceneOptimization {
  121803. /**
  121804. * Defines the priority of this optimization (0 by default which means first in the list)
  121805. */
  121806. priority: number;
  121807. /**
  121808. * Defines the maximum scale to use (2 by default)
  121809. */
  121810. maximumScale: number;
  121811. /**
  121812. * Defines the step to use between two passes (0.5 by default)
  121813. */
  121814. step: number;
  121815. private _currentScale;
  121816. private _directionOffset;
  121817. /**
  121818. * Gets a string describing the action executed by the current optimization
  121819. * @return description string
  121820. */
  121821. getDescription(): string;
  121822. /**
  121823. * Creates the HardwareScalingOptimization object
  121824. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121825. * @param maximumScale defines the maximum scale to use (2 by default)
  121826. * @param step defines the step to use between two passes (0.5 by default)
  121827. */
  121828. constructor(
  121829. /**
  121830. * Defines the priority of this optimization (0 by default which means first in the list)
  121831. */
  121832. priority?: number,
  121833. /**
  121834. * Defines the maximum scale to use (2 by default)
  121835. */
  121836. maximumScale?: number,
  121837. /**
  121838. * Defines the step to use between two passes (0.5 by default)
  121839. */
  121840. step?: number);
  121841. /**
  121842. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121843. * @param scene defines the current scene where to apply this optimization
  121844. * @param optimizer defines the current optimizer
  121845. * @returns true if everything that can be done was applied
  121846. */
  121847. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121848. }
  121849. /**
  121850. * Defines an optimization used to remove shadows
  121851. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121852. */
  121853. export class ShadowsOptimization extends SceneOptimization {
  121854. /**
  121855. * Gets a string describing the action executed by the current optimization
  121856. * @return description string
  121857. */
  121858. getDescription(): string;
  121859. /**
  121860. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121861. * @param scene defines the current scene where to apply this optimization
  121862. * @param optimizer defines the current optimizer
  121863. * @returns true if everything that can be done was applied
  121864. */
  121865. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121866. }
  121867. /**
  121868. * Defines an optimization used to turn post-processes off
  121869. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121870. */
  121871. export class PostProcessesOptimization extends SceneOptimization {
  121872. /**
  121873. * Gets a string describing the action executed by the current optimization
  121874. * @return description string
  121875. */
  121876. getDescription(): string;
  121877. /**
  121878. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121879. * @param scene defines the current scene where to apply this optimization
  121880. * @param optimizer defines the current optimizer
  121881. * @returns true if everything that can be done was applied
  121882. */
  121883. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121884. }
  121885. /**
  121886. * Defines an optimization used to turn lens flares off
  121887. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121888. */
  121889. export class LensFlaresOptimization extends SceneOptimization {
  121890. /**
  121891. * Gets a string describing the action executed by the current optimization
  121892. * @return description string
  121893. */
  121894. getDescription(): string;
  121895. /**
  121896. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121897. * @param scene defines the current scene where to apply this optimization
  121898. * @param optimizer defines the current optimizer
  121899. * @returns true if everything that can be done was applied
  121900. */
  121901. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121902. }
  121903. /**
  121904. * Defines an optimization based on user defined callback.
  121905. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121906. */
  121907. export class CustomOptimization extends SceneOptimization {
  121908. /**
  121909. * Callback called to apply the custom optimization.
  121910. */
  121911. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  121912. /**
  121913. * Callback called to get custom description
  121914. */
  121915. onGetDescription: () => string;
  121916. /**
  121917. * Gets a string describing the action executed by the current optimization
  121918. * @returns description string
  121919. */
  121920. getDescription(): string;
  121921. /**
  121922. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121923. * @param scene defines the current scene where to apply this optimization
  121924. * @param optimizer defines the current optimizer
  121925. * @returns true if everything that can be done was applied
  121926. */
  121927. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121928. }
  121929. /**
  121930. * Defines an optimization used to turn particles off
  121931. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121932. */
  121933. export class ParticlesOptimization extends SceneOptimization {
  121934. /**
  121935. * Gets a string describing the action executed by the current optimization
  121936. * @return description string
  121937. */
  121938. getDescription(): string;
  121939. /**
  121940. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121941. * @param scene defines the current scene where to apply this optimization
  121942. * @param optimizer defines the current optimizer
  121943. * @returns true if everything that can be done was applied
  121944. */
  121945. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121946. }
  121947. /**
  121948. * Defines an optimization used to turn render targets off
  121949. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121950. */
  121951. export class RenderTargetsOptimization extends SceneOptimization {
  121952. /**
  121953. * Gets a string describing the action executed by the current optimization
  121954. * @return description string
  121955. */
  121956. getDescription(): string;
  121957. /**
  121958. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121959. * @param scene defines the current scene where to apply this optimization
  121960. * @param optimizer defines the current optimizer
  121961. * @returns true if everything that can be done was applied
  121962. */
  121963. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121964. }
  121965. /**
  121966. * Defines an optimization used to merge meshes with compatible materials
  121967. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121968. */
  121969. export class MergeMeshesOptimization extends SceneOptimization {
  121970. private static _UpdateSelectionTree;
  121971. /**
  121972. * Gets or sets a boolean which defines if optimization octree has to be updated
  121973. */
  121974. /**
  121975. * Gets or sets a boolean which defines if optimization octree has to be updated
  121976. */
  121977. static UpdateSelectionTree: boolean;
  121978. /**
  121979. * Gets a string describing the action executed by the current optimization
  121980. * @return description string
  121981. */
  121982. getDescription(): string;
  121983. private _canBeMerged;
  121984. /**
  121985. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121986. * @param scene defines the current scene where to apply this optimization
  121987. * @param optimizer defines the current optimizer
  121988. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  121989. * @returns true if everything that can be done was applied
  121990. */
  121991. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  121992. }
  121993. /**
  121994. * Defines a list of options used by SceneOptimizer
  121995. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121996. */
  121997. export class SceneOptimizerOptions {
  121998. /**
  121999. * Defines the target frame rate to reach (60 by default)
  122000. */
  122001. targetFrameRate: number;
  122002. /**
  122003. * Defines the interval between two checkes (2000ms by default)
  122004. */
  122005. trackerDuration: number;
  122006. /**
  122007. * Gets the list of optimizations to apply
  122008. */
  122009. optimizations: SceneOptimization[];
  122010. /**
  122011. * Creates a new list of options used by SceneOptimizer
  122012. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  122013. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  122014. */
  122015. constructor(
  122016. /**
  122017. * Defines the target frame rate to reach (60 by default)
  122018. */
  122019. targetFrameRate?: number,
  122020. /**
  122021. * Defines the interval between two checkes (2000ms by default)
  122022. */
  122023. trackerDuration?: number);
  122024. /**
  122025. * Add a new optimization
  122026. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  122027. * @returns the current SceneOptimizerOptions
  122028. */
  122029. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  122030. /**
  122031. * Add a new custom optimization
  122032. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  122033. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  122034. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  122035. * @returns the current SceneOptimizerOptions
  122036. */
  122037. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  122038. /**
  122039. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  122040. * @param targetFrameRate defines the target frame rate (60 by default)
  122041. * @returns a SceneOptimizerOptions object
  122042. */
  122043. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  122044. /**
  122045. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  122046. * @param targetFrameRate defines the target frame rate (60 by default)
  122047. * @returns a SceneOptimizerOptions object
  122048. */
  122049. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  122050. /**
  122051. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  122052. * @param targetFrameRate defines the target frame rate (60 by default)
  122053. * @returns a SceneOptimizerOptions object
  122054. */
  122055. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  122056. }
  122057. /**
  122058. * Class used to run optimizations in order to reach a target frame rate
  122059. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  122060. */
  122061. export class SceneOptimizer implements IDisposable {
  122062. private _isRunning;
  122063. private _options;
  122064. private _scene;
  122065. private _currentPriorityLevel;
  122066. private _targetFrameRate;
  122067. private _trackerDuration;
  122068. private _currentFrameRate;
  122069. private _sceneDisposeObserver;
  122070. private _improvementMode;
  122071. /**
  122072. * Defines an observable called when the optimizer reaches the target frame rate
  122073. */
  122074. onSuccessObservable: Observable<SceneOptimizer>;
  122075. /**
  122076. * Defines an observable called when the optimizer enables an optimization
  122077. */
  122078. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  122079. /**
  122080. * Defines an observable called when the optimizer is not able to reach the target frame rate
  122081. */
  122082. onFailureObservable: Observable<SceneOptimizer>;
  122083. /**
  122084. * Gets a boolean indicating if the optimizer is in improvement mode
  122085. */
  122086. readonly isInImprovementMode: boolean;
  122087. /**
  122088. * Gets the current priority level (0 at start)
  122089. */
  122090. readonly currentPriorityLevel: number;
  122091. /**
  122092. * Gets the current frame rate checked by the SceneOptimizer
  122093. */
  122094. readonly currentFrameRate: number;
  122095. /**
  122096. * Gets or sets the current target frame rate (60 by default)
  122097. */
  122098. /**
  122099. * Gets or sets the current target frame rate (60 by default)
  122100. */
  122101. targetFrameRate: number;
  122102. /**
  122103. * Gets or sets the current interval between two checks (every 2000ms by default)
  122104. */
  122105. /**
  122106. * Gets or sets the current interval between two checks (every 2000ms by default)
  122107. */
  122108. trackerDuration: number;
  122109. /**
  122110. * Gets the list of active optimizations
  122111. */
  122112. readonly optimizations: SceneOptimization[];
  122113. /**
  122114. * Creates a new SceneOptimizer
  122115. * @param scene defines the scene to work on
  122116. * @param options defines the options to use with the SceneOptimizer
  122117. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  122118. * @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)
  122119. */
  122120. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  122121. /**
  122122. * Stops the current optimizer
  122123. */
  122124. stop(): void;
  122125. /**
  122126. * Reset the optimizer to initial step (current priority level = 0)
  122127. */
  122128. reset(): void;
  122129. /**
  122130. * Start the optimizer. By default it will try to reach a specific framerate
  122131. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  122132. */
  122133. start(): void;
  122134. private _checkCurrentState;
  122135. /**
  122136. * Release all resources
  122137. */
  122138. dispose(): void;
  122139. /**
  122140. * Helper function to create a SceneOptimizer with one single line of code
  122141. * @param scene defines the scene to work on
  122142. * @param options defines the options to use with the SceneOptimizer
  122143. * @param onSuccess defines a callback to call on success
  122144. * @param onFailure defines a callback to call on failure
  122145. * @returns the new SceneOptimizer object
  122146. */
  122147. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  122148. }
  122149. }
  122150. declare module BABYLON {
  122151. /**
  122152. * Class used to serialize a scene into a string
  122153. */
  122154. export class SceneSerializer {
  122155. /**
  122156. * Clear cache used by a previous serialization
  122157. */
  122158. static ClearCache(): void;
  122159. /**
  122160. * Serialize a scene into a JSON compatible object
  122161. * @param scene defines the scene to serialize
  122162. * @returns a JSON compatible object
  122163. */
  122164. static Serialize(scene: Scene): any;
  122165. /**
  122166. * Serialize a mesh into a JSON compatible object
  122167. * @param toSerialize defines the mesh to serialize
  122168. * @param withParents defines if parents must be serialized as well
  122169. * @param withChildren defines if children must be serialized as well
  122170. * @returns a JSON compatible object
  122171. */
  122172. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  122173. }
  122174. }
  122175. declare module BABYLON {
  122176. /**
  122177. * Class used to host texture specific utilities
  122178. */
  122179. export class TextureTools {
  122180. /**
  122181. * Uses the GPU to create a copy texture rescaled at a given size
  122182. * @param texture Texture to copy from
  122183. * @param width defines the desired width
  122184. * @param height defines the desired height
  122185. * @param useBilinearMode defines if bilinear mode has to be used
  122186. * @return the generated texture
  122187. */
  122188. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  122189. }
  122190. }
  122191. declare module BABYLON {
  122192. /**
  122193. * This represents the different options available for the video capture.
  122194. */
  122195. export interface VideoRecorderOptions {
  122196. /** Defines the mime type of the video. */
  122197. mimeType: string;
  122198. /** Defines the FPS the video should be recorded at. */
  122199. fps: number;
  122200. /** Defines the chunk size for the recording data. */
  122201. recordChunckSize: number;
  122202. /** The audio tracks to attach to the recording. */
  122203. audioTracks?: MediaStreamTrack[];
  122204. }
  122205. /**
  122206. * This can help with recording videos from BabylonJS.
  122207. * This is based on the available WebRTC functionalities of the browser.
  122208. *
  122209. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  122210. */
  122211. export class VideoRecorder {
  122212. private static readonly _defaultOptions;
  122213. /**
  122214. * Returns whether or not the VideoRecorder is available in your browser.
  122215. * @param engine Defines the Babylon Engine.
  122216. * @returns true if supported otherwise false.
  122217. */
  122218. static IsSupported(engine: Engine): boolean;
  122219. private readonly _options;
  122220. private _canvas;
  122221. private _mediaRecorder;
  122222. private _recordedChunks;
  122223. private _fileName;
  122224. private _resolve;
  122225. private _reject;
  122226. /**
  122227. * True when a recording is already in progress.
  122228. */
  122229. readonly isRecording: boolean;
  122230. /**
  122231. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  122232. * @param engine Defines the BabylonJS Engine you wish to record.
  122233. * @param options Defines options that can be used to customize the capture.
  122234. */
  122235. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  122236. /**
  122237. * Stops the current recording before the default capture timeout passed in the startRecording function.
  122238. */
  122239. stopRecording(): void;
  122240. /**
  122241. * Starts recording the canvas for a max duration specified in parameters.
  122242. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  122243. * If null no automatic download will start and you can rely on the promise to get the data back.
  122244. * @param maxDuration Defines the maximum recording time in seconds.
  122245. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  122246. * @return A promise callback at the end of the recording with the video data in Blob.
  122247. */
  122248. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  122249. /**
  122250. * Releases internal resources used during the recording.
  122251. */
  122252. dispose(): void;
  122253. private _handleDataAvailable;
  122254. private _handleError;
  122255. private _handleStop;
  122256. }
  122257. }
  122258. declare module BABYLON {
  122259. /**
  122260. * Class containing a set of static utilities functions for screenshots
  122261. */
  122262. export class ScreenshotTools {
  122263. /**
  122264. * Captures a screenshot of the current rendering
  122265. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  122266. * @param engine defines the rendering engine
  122267. * @param camera defines the source camera
  122268. * @param size This parameter can be set to a single number or to an object with the
  122269. * following (optional) properties: precision, width, height. If a single number is passed,
  122270. * it will be used for both width and height. If an object is passed, the screenshot size
  122271. * will be derived from the parameters. The precision property is a multiplier allowing
  122272. * rendering at a higher or lower resolution
  122273. * @param successCallback defines the callback receives a single parameter which contains the
  122274. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  122275. * src parameter of an <img> to display it
  122276. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  122277. * Check your browser for supported MIME types
  122278. */
  122279. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  122280. /**
  122281. * Generates an image screenshot from the specified camera.
  122282. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  122283. * @param engine The engine to use for rendering
  122284. * @param camera The camera to use for rendering
  122285. * @param size This parameter can be set to a single number or to an object with the
  122286. * following (optional) properties: precision, width, height. If a single number is passed,
  122287. * it will be used for both width and height. If an object is passed, the screenshot size
  122288. * will be derived from the parameters. The precision property is a multiplier allowing
  122289. * rendering at a higher or lower resolution
  122290. * @param successCallback The callback receives a single parameter which contains the
  122291. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  122292. * src parameter of an <img> to display it
  122293. * @param mimeType The MIME type of the screenshot image (default: image/png).
  122294. * Check your browser for supported MIME types
  122295. * @param samples Texture samples (default: 1)
  122296. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  122297. * @param fileName A name for for the downloaded file.
  122298. */
  122299. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  122300. }
  122301. }
  122302. declare module BABYLON {
  122303. /**
  122304. * A cursor which tracks a point on a path
  122305. */
  122306. export class PathCursor {
  122307. private path;
  122308. /**
  122309. * Stores path cursor callbacks for when an onchange event is triggered
  122310. */
  122311. private _onchange;
  122312. /**
  122313. * The value of the path cursor
  122314. */
  122315. value: number;
  122316. /**
  122317. * The animation array of the path cursor
  122318. */
  122319. animations: Animation[];
  122320. /**
  122321. * Initializes the path cursor
  122322. * @param path The path to track
  122323. */
  122324. constructor(path: Path2);
  122325. /**
  122326. * Gets the cursor point on the path
  122327. * @returns A point on the path cursor at the cursor location
  122328. */
  122329. getPoint(): Vector3;
  122330. /**
  122331. * Moves the cursor ahead by the step amount
  122332. * @param step The amount to move the cursor forward
  122333. * @returns This path cursor
  122334. */
  122335. moveAhead(step?: number): PathCursor;
  122336. /**
  122337. * Moves the cursor behind by the step amount
  122338. * @param step The amount to move the cursor back
  122339. * @returns This path cursor
  122340. */
  122341. moveBack(step?: number): PathCursor;
  122342. /**
  122343. * Moves the cursor by the step amount
  122344. * If the step amount is greater than one, an exception is thrown
  122345. * @param step The amount to move the cursor
  122346. * @returns This path cursor
  122347. */
  122348. move(step: number): PathCursor;
  122349. /**
  122350. * Ensures that the value is limited between zero and one
  122351. * @returns This path cursor
  122352. */
  122353. private ensureLimits;
  122354. /**
  122355. * Runs onchange callbacks on change (used by the animation engine)
  122356. * @returns This path cursor
  122357. */
  122358. private raiseOnChange;
  122359. /**
  122360. * Executes a function on change
  122361. * @param f A path cursor onchange callback
  122362. * @returns This path cursor
  122363. */
  122364. onchange(f: (cursor: PathCursor) => void): PathCursor;
  122365. }
  122366. }
  122367. declare module BABYLON {
  122368. /** @hidden */
  122369. export var blurPixelShader: {
  122370. name: string;
  122371. shader: string;
  122372. };
  122373. }
  122374. declare module BABYLON {
  122375. /** @hidden */
  122376. export var pointCloudVertexDeclaration: {
  122377. name: string;
  122378. shader: string;
  122379. };
  122380. }
  122381. // Mixins
  122382. interface Window {
  122383. mozIndexedDB: IDBFactory;
  122384. webkitIndexedDB: IDBFactory;
  122385. msIndexedDB: IDBFactory;
  122386. webkitURL: typeof URL;
  122387. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  122388. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  122389. WebGLRenderingContext: WebGLRenderingContext;
  122390. MSGesture: MSGesture;
  122391. CANNON: any;
  122392. AudioContext: AudioContext;
  122393. webkitAudioContext: AudioContext;
  122394. PointerEvent: any;
  122395. Math: Math;
  122396. Uint8Array: Uint8ArrayConstructor;
  122397. Float32Array: Float32ArrayConstructor;
  122398. mozURL: typeof URL;
  122399. msURL: typeof URL;
  122400. VRFrameData: any; // WebVR, from specs 1.1
  122401. DracoDecoderModule: any;
  122402. setImmediate(handler: (...args: any[]) => void): number;
  122403. }
  122404. interface HTMLCanvasElement {
  122405. requestPointerLock(): void;
  122406. msRequestPointerLock?(): void;
  122407. mozRequestPointerLock?(): void;
  122408. webkitRequestPointerLock?(): void;
  122409. /** Track wether a record is in progress */
  122410. isRecording: boolean;
  122411. /** Capture Stream method defined by some browsers */
  122412. captureStream(fps?: number): MediaStream;
  122413. }
  122414. interface CanvasRenderingContext2D {
  122415. msImageSmoothingEnabled: boolean;
  122416. }
  122417. interface MouseEvent {
  122418. mozMovementX: number;
  122419. mozMovementY: number;
  122420. webkitMovementX: number;
  122421. webkitMovementY: number;
  122422. msMovementX: number;
  122423. msMovementY: number;
  122424. }
  122425. interface Navigator {
  122426. mozGetVRDevices: (any: any) => any;
  122427. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  122428. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  122429. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  122430. webkitGetGamepads(): Gamepad[];
  122431. msGetGamepads(): Gamepad[];
  122432. webkitGamepads(): Gamepad[];
  122433. }
  122434. interface HTMLVideoElement {
  122435. mozSrcObject: any;
  122436. }
  122437. interface Math {
  122438. fround(x: number): number;
  122439. imul(a: number, b: number): number;
  122440. }
  122441. interface WebGLRenderingContext {
  122442. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  122443. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  122444. vertexAttribDivisor(index: number, divisor: number): void;
  122445. createVertexArray(): any;
  122446. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  122447. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  122448. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  122449. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  122450. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  122451. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  122452. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  122453. // Queries
  122454. createQuery(): WebGLQuery;
  122455. deleteQuery(query: WebGLQuery): void;
  122456. beginQuery(target: number, query: WebGLQuery): void;
  122457. endQuery(target: number): void;
  122458. getQueryParameter(query: WebGLQuery, pname: number): any;
  122459. getQuery(target: number, pname: number): any;
  122460. MAX_SAMPLES: number;
  122461. RGBA8: number;
  122462. READ_FRAMEBUFFER: number;
  122463. DRAW_FRAMEBUFFER: number;
  122464. UNIFORM_BUFFER: number;
  122465. HALF_FLOAT_OES: number;
  122466. RGBA16F: number;
  122467. RGBA32F: number;
  122468. R32F: number;
  122469. RG32F: number;
  122470. RGB32F: number;
  122471. R16F: number;
  122472. RG16F: number;
  122473. RGB16F: number;
  122474. RED: number;
  122475. RG: number;
  122476. R8: number;
  122477. RG8: number;
  122478. UNSIGNED_INT_24_8: number;
  122479. DEPTH24_STENCIL8: number;
  122480. /* Multiple Render Targets */
  122481. drawBuffers(buffers: number[]): void;
  122482. readBuffer(src: number): void;
  122483. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  122484. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  122485. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  122486. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  122487. // Occlusion Query
  122488. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  122489. ANY_SAMPLES_PASSED: number;
  122490. QUERY_RESULT_AVAILABLE: number;
  122491. QUERY_RESULT: number;
  122492. }
  122493. interface WebGLProgram {
  122494. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  122495. }
  122496. interface EXT_disjoint_timer_query {
  122497. QUERY_COUNTER_BITS_EXT: number;
  122498. TIME_ELAPSED_EXT: number;
  122499. TIMESTAMP_EXT: number;
  122500. GPU_DISJOINT_EXT: number;
  122501. QUERY_RESULT_EXT: number;
  122502. QUERY_RESULT_AVAILABLE_EXT: number;
  122503. queryCounterEXT(query: WebGLQuery, target: number): void;
  122504. createQueryEXT(): WebGLQuery;
  122505. beginQueryEXT(target: number, query: WebGLQuery): void;
  122506. endQueryEXT(target: number): void;
  122507. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  122508. deleteQueryEXT(query: WebGLQuery): void;
  122509. }
  122510. interface WebGLUniformLocation {
  122511. _currentState: any;
  122512. }
  122513. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  122514. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  122515. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  122516. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  122517. interface WebGLRenderingContext {
  122518. readonly RASTERIZER_DISCARD: number;
  122519. readonly DEPTH_COMPONENT24: number;
  122520. readonly TEXTURE_3D: number;
  122521. readonly TEXTURE_2D_ARRAY: number;
  122522. readonly TEXTURE_COMPARE_FUNC: number;
  122523. readonly TEXTURE_COMPARE_MODE: number;
  122524. readonly COMPARE_REF_TO_TEXTURE: number;
  122525. readonly TEXTURE_WRAP_R: number;
  122526. readonly HALF_FLOAT: number;
  122527. readonly RGB8: number;
  122528. readonly RED_INTEGER: number;
  122529. readonly RG_INTEGER: number;
  122530. readonly RGB_INTEGER: number;
  122531. readonly RGBA_INTEGER: number;
  122532. readonly R8_SNORM: number;
  122533. readonly RG8_SNORM: number;
  122534. readonly RGB8_SNORM: number;
  122535. readonly RGBA8_SNORM: number;
  122536. readonly R8I: number;
  122537. readonly RG8I: number;
  122538. readonly RGB8I: number;
  122539. readonly RGBA8I: number;
  122540. readonly R8UI: number;
  122541. readonly RG8UI: number;
  122542. readonly RGB8UI: number;
  122543. readonly RGBA8UI: number;
  122544. readonly R16I: number;
  122545. readonly RG16I: number;
  122546. readonly RGB16I: number;
  122547. readonly RGBA16I: number;
  122548. readonly R16UI: number;
  122549. readonly RG16UI: number;
  122550. readonly RGB16UI: number;
  122551. readonly RGBA16UI: number;
  122552. readonly R32I: number;
  122553. readonly RG32I: number;
  122554. readonly RGB32I: number;
  122555. readonly RGBA32I: number;
  122556. readonly R32UI: number;
  122557. readonly RG32UI: number;
  122558. readonly RGB32UI: number;
  122559. readonly RGBA32UI: number;
  122560. readonly RGB10_A2UI: number;
  122561. readonly R11F_G11F_B10F: number;
  122562. readonly RGB9_E5: number;
  122563. readonly RGB10_A2: number;
  122564. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  122565. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  122566. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  122567. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  122568. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  122569. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  122570. 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;
  122571. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  122572. readonly TRANSFORM_FEEDBACK: number;
  122573. readonly INTERLEAVED_ATTRIBS: number;
  122574. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  122575. createTransformFeedback(): WebGLTransformFeedback;
  122576. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  122577. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  122578. beginTransformFeedback(primitiveMode: number): void;
  122579. endTransformFeedback(): void;
  122580. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  122581. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  122582. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  122583. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  122584. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  122585. }
  122586. interface ImageBitmap {
  122587. readonly width: number;
  122588. readonly height: number;
  122589. close(): void;
  122590. }
  122591. interface WebGLQuery extends WebGLObject {
  122592. }
  122593. declare var WebGLQuery: {
  122594. prototype: WebGLQuery;
  122595. new(): WebGLQuery;
  122596. };
  122597. interface WebGLSampler extends WebGLObject {
  122598. }
  122599. declare var WebGLSampler: {
  122600. prototype: WebGLSampler;
  122601. new(): WebGLSampler;
  122602. };
  122603. interface WebGLSync extends WebGLObject {
  122604. }
  122605. declare var WebGLSync: {
  122606. prototype: WebGLSync;
  122607. new(): WebGLSync;
  122608. };
  122609. interface WebGLTransformFeedback extends WebGLObject {
  122610. }
  122611. declare var WebGLTransformFeedback: {
  122612. prototype: WebGLTransformFeedback;
  122613. new(): WebGLTransformFeedback;
  122614. };
  122615. interface WebGLVertexArrayObject extends WebGLObject {
  122616. }
  122617. declare var WebGLVertexArrayObject: {
  122618. prototype: WebGLVertexArrayObject;
  122619. new(): WebGLVertexArrayObject;
  122620. };
  122621. // Type definitions for WebVR API
  122622. // Project: https://w3c.github.io/webvr/
  122623. // Definitions by: six a <https://github.com/lostfictions>
  122624. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  122625. interface VRDisplay extends EventTarget {
  122626. /**
  122627. * Dictionary of capabilities describing the VRDisplay.
  122628. */
  122629. readonly capabilities: VRDisplayCapabilities;
  122630. /**
  122631. * z-depth defining the far plane of the eye view frustum
  122632. * enables mapping of values in the render target depth
  122633. * attachment to scene coordinates. Initially set to 10000.0.
  122634. */
  122635. depthFar: number;
  122636. /**
  122637. * z-depth defining the near plane of the eye view frustum
  122638. * enables mapping of values in the render target depth
  122639. * attachment to scene coordinates. Initially set to 0.01.
  122640. */
  122641. depthNear: number;
  122642. /**
  122643. * An identifier for this distinct VRDisplay. Used as an
  122644. * association point in the Gamepad API.
  122645. */
  122646. readonly displayId: number;
  122647. /**
  122648. * A display name, a user-readable name identifying it.
  122649. */
  122650. readonly displayName: string;
  122651. readonly isConnected: boolean;
  122652. readonly isPresenting: boolean;
  122653. /**
  122654. * If this VRDisplay supports room-scale experiences, the optional
  122655. * stage attribute contains details on the room-scale parameters.
  122656. */
  122657. readonly stageParameters: VRStageParameters | null;
  122658. /**
  122659. * Passing the value returned by `requestAnimationFrame` to
  122660. * `cancelAnimationFrame` will unregister the callback.
  122661. * @param handle Define the hanle of the request to cancel
  122662. */
  122663. cancelAnimationFrame(handle: number): void;
  122664. /**
  122665. * Stops presenting to the VRDisplay.
  122666. * @returns a promise to know when it stopped
  122667. */
  122668. exitPresent(): Promise<void>;
  122669. /**
  122670. * Return the current VREyeParameters for the given eye.
  122671. * @param whichEye Define the eye we want the parameter for
  122672. * @returns the eye parameters
  122673. */
  122674. getEyeParameters(whichEye: string): VREyeParameters;
  122675. /**
  122676. * Populates the passed VRFrameData with the information required to render
  122677. * the current frame.
  122678. * @param frameData Define the data structure to populate
  122679. * @returns true if ok otherwise false
  122680. */
  122681. getFrameData(frameData: VRFrameData): boolean;
  122682. /**
  122683. * Get the layers currently being presented.
  122684. * @returns the list of VR layers
  122685. */
  122686. getLayers(): VRLayer[];
  122687. /**
  122688. * Return a VRPose containing the future predicted pose of the VRDisplay
  122689. * when the current frame will be presented. The value returned will not
  122690. * change until JavaScript has returned control to the browser.
  122691. *
  122692. * The VRPose will contain the position, orientation, velocity,
  122693. * and acceleration of each of these properties.
  122694. * @returns the pose object
  122695. */
  122696. getPose(): VRPose;
  122697. /**
  122698. * Return the current instantaneous pose of the VRDisplay, with no
  122699. * prediction applied.
  122700. * @returns the current instantaneous pose
  122701. */
  122702. getImmediatePose(): VRPose;
  122703. /**
  122704. * The callback passed to `requestAnimationFrame` will be called
  122705. * any time a new frame should be rendered. When the VRDisplay is
  122706. * presenting the callback will be called at the native refresh
  122707. * rate of the HMD. When not presenting this function acts
  122708. * identically to how window.requestAnimationFrame acts. Content should
  122709. * make no assumptions of frame rate or vsync behavior as the HMD runs
  122710. * asynchronously from other displays and at differing refresh rates.
  122711. * @param callback Define the eaction to run next frame
  122712. * @returns the request handle it
  122713. */
  122714. requestAnimationFrame(callback: FrameRequestCallback): number;
  122715. /**
  122716. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  122717. * Repeat calls while already presenting will update the VRLayers being displayed.
  122718. * @param layers Define the list of layer to present
  122719. * @returns a promise to know when the request has been fulfilled
  122720. */
  122721. requestPresent(layers: VRLayer[]): Promise<void>;
  122722. /**
  122723. * Reset the pose for this display, treating its current position and
  122724. * orientation as the "origin/zero" values. VRPose.position,
  122725. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  122726. * updated when calling resetPose(). This should be called in only
  122727. * sitting-space experiences.
  122728. */
  122729. resetPose(): void;
  122730. /**
  122731. * The VRLayer provided to the VRDisplay will be captured and presented
  122732. * in the HMD. Calling this function has the same effect on the source
  122733. * canvas as any other operation that uses its source image, and canvases
  122734. * created without preserveDrawingBuffer set to true will be cleared.
  122735. * @param pose Define the pose to submit
  122736. */
  122737. submitFrame(pose?: VRPose): void;
  122738. }
  122739. declare var VRDisplay: {
  122740. prototype: VRDisplay;
  122741. new(): VRDisplay;
  122742. };
  122743. interface VRLayer {
  122744. leftBounds?: number[] | Float32Array | null;
  122745. rightBounds?: number[] | Float32Array | null;
  122746. source?: HTMLCanvasElement | null;
  122747. }
  122748. interface VRDisplayCapabilities {
  122749. readonly canPresent: boolean;
  122750. readonly hasExternalDisplay: boolean;
  122751. readonly hasOrientation: boolean;
  122752. readonly hasPosition: boolean;
  122753. readonly maxLayers: number;
  122754. }
  122755. interface VREyeParameters {
  122756. /** @deprecated */
  122757. readonly fieldOfView: VRFieldOfView;
  122758. readonly offset: Float32Array;
  122759. readonly renderHeight: number;
  122760. readonly renderWidth: number;
  122761. }
  122762. interface VRFieldOfView {
  122763. readonly downDegrees: number;
  122764. readonly leftDegrees: number;
  122765. readonly rightDegrees: number;
  122766. readonly upDegrees: number;
  122767. }
  122768. interface VRFrameData {
  122769. readonly leftProjectionMatrix: Float32Array;
  122770. readonly leftViewMatrix: Float32Array;
  122771. readonly pose: VRPose;
  122772. readonly rightProjectionMatrix: Float32Array;
  122773. readonly rightViewMatrix: Float32Array;
  122774. readonly timestamp: number;
  122775. }
  122776. interface VRPose {
  122777. readonly angularAcceleration: Float32Array | null;
  122778. readonly angularVelocity: Float32Array | null;
  122779. readonly linearAcceleration: Float32Array | null;
  122780. readonly linearVelocity: Float32Array | null;
  122781. readonly orientation: Float32Array | null;
  122782. readonly position: Float32Array | null;
  122783. readonly timestamp: number;
  122784. }
  122785. interface VRStageParameters {
  122786. sittingToStandingTransform?: Float32Array;
  122787. sizeX?: number;
  122788. sizeY?: number;
  122789. }
  122790. interface Navigator {
  122791. getVRDisplays(): Promise<VRDisplay[]>;
  122792. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  122793. }
  122794. interface Window {
  122795. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  122796. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  122797. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  122798. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  122799. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  122800. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  122801. }
  122802. interface Gamepad {
  122803. readonly displayId: number;
  122804. }
  122805. interface XRDevice {
  122806. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  122807. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  122808. }
  122809. interface XRSession {
  122810. getInputSources(): Array<any>;
  122811. baseLayer: XRWebGLLayer;
  122812. requestFrameOfReference(type: string): Promise<void>;
  122813. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  122814. end(): Promise<void>;
  122815. requestAnimationFrame: Function;
  122816. addEventListener: Function;
  122817. }
  122818. interface XRSessionCreationOptions {
  122819. outputContext?: WebGLRenderingContext | null;
  122820. immersive?: boolean;
  122821. environmentIntegration?: boolean;
  122822. }
  122823. interface XRLayer {
  122824. getViewport: Function;
  122825. framebufferWidth: number;
  122826. framebufferHeight: number;
  122827. }
  122828. interface XRView {
  122829. projectionMatrix: Float32Array;
  122830. }
  122831. interface XRFrame {
  122832. getDevicePose: Function;
  122833. getInputPose: Function;
  122834. views: Array<XRView>;
  122835. baseLayer: XRLayer;
  122836. }
  122837. interface XRFrameOfReference {
  122838. }
  122839. interface XRWebGLLayer extends XRLayer {
  122840. framebuffer: WebGLFramebuffer;
  122841. }
  122842. declare var XRWebGLLayer: {
  122843. prototype: XRWebGLLayer;
  122844. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  122845. };